-------------------------------------------------------------------------------------------------------------------
搭建NFS服务:
环境是Fedora16,以下为安装过程:
安装NFS服务 #yum install portmap nfs-utils*
编辑/etc/exports
/home/work/fs/rootfs 192.168.0.0/24(rw,sync,no_root_squash)
/home/work/fs/rootfs指定哪个共享目录
192.168.0.0/24表示允许那些主机可以访问,如果是*号,表示所有主机
rw 表示可读写;sync 表示同步,no_root_squash 表示权限
启用NFS服务# systemctl enable nfs-server.service
ln -s '/lib/systemd/system/nfs-server.service' '/etc/systemd/system/multi-user.target.wants/nfs-server.service'
检查NFS服务是否被启用
# systemctl is-enabled nfs-server.service
enabled
启动NFS服务# systemctl start nfs-server.service 或者用service命令# service nfs-server restart
Redirecting to /bin/systemctl restart nfs-server.service
查看NFS服务状态# systemctl status nfs-server.service
nfs-server.service - NFS Server
Loaded: loaded (/lib/systemd/system/nfs-server.service; enabled)
Active: active (running) since Sat, 26 Oct 2013 10:33:13 +0800; 1min 46s ago
本地测试# showmount -e localhost
# mount -t nfs localhost:/home/work/fs/rootfs /home/nfs /*其中localhost是本地的地址*/
# umount /home/nfs
--------------------------------------------------------------------------------------------------------------------
在OK6410上挂载NFS:
# mount -t nfs localhost:/home/work/fs/rootfs /tmp
挂载时会出现的问题:
svc: failed to register lockdv1 RPC service (errno 111).
lockd_up: makesock failed, error=-111
mount: mounting 192.168.0.110:/home/work/fs/rootfs on /tmp failed: Connection refused
解决方法:
mount -t nfs -o nolock 192.168.0.110:/home/work/fs/rootfs /tmp
---------------------------------------------------------------------------------------------------------------------
OK6410从NFS启动:
进入U-Boot命令行模式,设置:
setenv bootargs "root=/dev/nfs nfsroot=192.168.0.110:/home/work/fs/rootfs
ip=192.168.0.120:192.168.0.110:192.168.0.1:255.255.255.0:witech.com.cn:eth0:off console=ttySAC2,115200"
保存参数:saveenv
重新启动:reset
启动的输出信息中可以看到
...
VFS: Mounted root (nfs filesystem) on device 0:14.
devtmpfs: mounted
Freeing init memory: 176K
----------munt all----------------
route: SIOCADDRT: File exists
OK!
bash-4.0# ls
bin etc linuxrc proc sys usr
dev lib mnt sbin tmp var