linux中nfs的自动挂载

nfs的自动挂载:

image

服务器段的配置:

建立一个共享文件:

[root@localhost ~]# mkdir /pub

编辑文件/etc/exports

添加下面一行

/public    192.168.10.0/24(ro)

导出共享:

[root@localhost ~]# exportfs -rv
exporting 192.168.10.0/24:/public

重启服务:

[root@localhost ~]# service nfs restart

 

 

客户端配置:

 

 

建立挂载点目录:

[root@localhost ~]# mkdir /mnt/nfs/

挂载:

[root@localhost ~]# mount 192.168.10.2:/public /mnt/nfs

[root@localhost ~]# mount
/dev/mapper/VolGroup00-LogVol00 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda1 on /boot type ext3 (rw)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
192.168.10.2:/public on /mnt/nfs type nfs (rw,addr=192.168.10.2)

 

开机挂载:

编辑文件/etc/fstab

添加

192.168.10.2:/public  /mnt/nfs   nfs   ro,soft,intr   0 0

 

 

自动挂载:

编辑文件/etc/auto.master

添加下图:

image

拷贝文件:

[root@localhost ~]# cp -p /etc/auto.misc /etc/auto.nfs

编辑文件 /etc/auto.nfs

添加下列行:

image

 

重启服务 [root@localhost ~]# service autofs restart

测试:

image

 

一分钟后:

 

image

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章