一、ubuntu搭建nfs服务器
开发板 访问 ubuntu的目录 1.nfs服务安装: #sudo apt-get install nfs-kernel-server nfs-common 2.工作路径配置: #sudo gedit /etc/exports,加上以下语句: / *(rw,sync,no_root_squash) 3.重启服务生效: #sudo service nfs-kernel-server restart
二、挂载的实现
启动开发板后会默认进入home目录,将mount_nfs.sh写好的shell脚本拷贝到当前目录(脚本原码给各位官爷们放到了文件的末尾,可自行拷贝),然后执行一下命令:
./mount_nfs
.sh Ubuntu的ip
/home
/share
/mnt
齐活,收工!!! cd /mnt 即可查看挂载目录后的内容啦…
shell脚本原码:
#
!/bin
/sh
#auto get ip
udhcpc
#config ip netmask gw
#ifconfig eth0 172.20.223.123 netmask 255.255.255.0
#route add default gw 172.20.223.254
serverip
=$
1
serverpath
=$
2
localpath
=$
3
echo
"usage:./mount_nfs serverip serverpath localpath"
if [ -z $serverip
]; then
echo
"serverip is NULL"
exit
1
fi
if [ -z $serverpath
]; then
echo
"serverpath is NULL"
exit
1
fi
if [ -z $localpath
]; then
localpath
=/mnt
/nfs
echo
"localpath default /mnt/nfs"
fi
mount
-o nolock
,wsize
=1024,rsize
=1024 $serverip
:$serverpath $localpath
if [ $
? = 0 ]; then
echo
"nfs mount succeed!!"
echo
"if you want to umount the serverpath"
echo
"please input umount like this: umount /mnt"
else
echo
"nfs mount failed,please check and try again!!"
fi