Ubuntu nfs mount LAN mount hard disk

Build an NFS server on the Ros host

1. The robot side (execution on the server side:)

1. Install the necessary packages

Install the nfs server in the robot

sudo apt-get update 
sudo apt-get install nfs-kernel-server

2. Create a directory folder to share

Create a folder for client remote access, such as our commonly used robot code snippets, etc.

sudo -p mkdir /mnt

3. Edit the configuration file


①Add NFS shared directory

sudo nano /etc/exports 

# 在文件的末尾输入自定义需要共享的文件夹路径

/home/xxx/mnt *(rw,sync,no_root_squash)      

Parameter introduction : * means that any network segment can be accessed, sync  means that the data is synchronously written to the hard disk and memory, no_root_squash means that it has super user privileges

②Set permissions for the mounted directory and modify the file user
 

sudo chmod  -R  777  /home/xxx/mnt
sudo chown  -R  777  nobody  /home/xxx/mnt   # 将指定文件的拥有者是组改为指定的用户或者组

4. Start the service

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

# 先启动NFS再重启NFS

Second, the virtual machine (client)


1. Install nfs-common and portma packages

sudo apt-get install nfs-common portmap

2. Create a directory that provides mounting

sudo mkdir /mnt

3. Mount

sudo  mount  -t  nfs  -o  nolock  192.168.0.100:/home/xxx/xxx  /mnt

# mount 是挂载的指令,-t 指定文件的类型,-t nfs 就是指定文件网络这个类型, 
# 192.168.0.100 机器人的ip地址,后面是机器人路径和挂载的路径

4. Check whether the mount is successful

cd mnt
ls

# 或者使用 df -h指令来查看系统硬盘情况。

3. Introduction to nfs related documents

/etc/exports Main configuration files
/etc/usr/exports File system maintenance commands
/var/lib/nfs/*tab Login documents for shared resources

Guess you like

Origin blog.csdn.net/m0_46259216/article/details/127985350