How to transfer files between the development board and Ubuntu

For a more comprehensive method of learning embedded Linux, you can read the article I wrote before:

How to learn embedded Linux :
https://blog.csdn.net/thisway_diy/article/details/106101091

After the network communication between the development board and Ubuntu, you can transfer files between the two.

The development board mounts the Ubuntu directory via NFS

The development board does not necessarily have FTP services, SSH and other services installed, so it is not always possible to use FTP and other tools to log in to the development board.

However, the system of the development board generally comes with the mount command and supports the NFS file system. So you can execute the mount command on the development board to mount
a directory in Ubuntu. In this way, files can be transferred between the development board and Ubuntu.

The prerequisite for the development board to use NFS to mount Ubuntu is that the NFS service has been installed in Ubuntu and a directory is configured for mounting in /etc/exports.

Install and configure NFS service on Ubuntu

If you are using Ubuntu provided by us, then the NFS service is already installed.

If your Ubuntu does not have the NFS service installed, execute the following command under the premise of ensuring that Ubuntu can access the Internet:

sudo apt-get install nfs-kernel-server

Then, you have to modify /etc/exports and add something similar to the following. In the following example, the development board is allowed to access Ubuntu's /home/book directory through NFS:

/home/book *(rw,nohide,insecure,no_subtree_check,async,no_root_squash)

Finally, restart the NFS service and execute the following command on Ubuntu:

sudo /etc/init.d/nfs-kernel-server restart

You can mount yourself via NFS on Ubuntu and verify that NFS is available:

sudo mount -t nfs -o nolock,vers=3 127.0.0.1:/home/book /mnt
ls /mnt

Mount Ubuntu's NFS file system on the development board

After ensuring that the development board can ping Ubuntu, you can mount a directory in Ubuntu through NFS.

Which directories? Please check Ubutnu's /etc/exports file.

Assuming that the IP of Ubuntu is: 192.168.1.100, you can execute the following command on the development board to mount the /home/book directory of Ubuntu to the /mnt directory of the development board:

mount -t nfs -o nolock,vers=2 192.168.1.100:/home/book /mnt
// 如果不成功,就把 vers=2 改为 vers=3 或 vers=4
mount -t nfs -o nolock,vers=3 192.168.1.100:/home/book /mnt

If everything is normal, you can put the file in the /home/book directory on Ubuntu, and you can access the file from the /mnt directory on the development board.

Guess you like

Origin blog.csdn.net/thisway_diy/article/details/111474111