1. 安装nfs服务,设置nfs主目录
tom@ubuntu:/$ sudo mkdir -p /source/rootfs/
tom@ubuntu:/$ sudo chmod -R 777 /source
tom@ubuntu:/~$ sudo apt-get install nfs-kernel-server
2. 编辑/etc/exports ,配置nfs
tom@ubuntu:/tftpboot$ sudo vim /etc/exports
1 /etc/exports: the access control list for filesystems which may be exported to NFS clients. See exports(5). 2 # Example for NFSv2 and NFSv3: 3 # /srv/homes hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check) 4 # Example for NFSv4: 5 # /srv/nfs4 gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check) 6 # /srv/nfs4/homes gss/krb5i(rw,sync,no_subtree_check) 7 /source/rootfs/ *(rw,sync,no_subtree_check,no_root_squash)
3. 重启nfs服务
tom@ubuntu:/tftpboot$ sudo /etc/init.d/nfs-kernel-server restart
* Stopping NFS kernel daemon [ OK ]
* Unexporting directories for NFS kernel daemon... [ OK ]
* Exporting directories for NFS kernel daemon... [ OK ]
* Starting NFS kernel daemon [ OK ]
4. 挂载nfs共享目录
tom@ubuntu:/$ sudo mount -t nfs 192.168.0.108:/source/rootfs ~/nfs
5. 卸载共享目录
tom@ubuntu:~$ sudo umount ~/nfs/