NFS   和   自动挂载

  

   实验要求:

 

共享目录为 :  /share   目录需要自己创建  可建几个空文件进行测试

   2、允许网段为: 192.168.1.0/24  

共享权限为 :  可读写

设置开机自动挂载 挂载目录为: /nfs/ss

 

 

 

   实验过程:

  1、给你的PC机配置IP地址

 

   [root@localhost~]#syetem-config-network-tui

 

    我的IP为   192.168.1.34

 

然后重启网卡 是配置生效

[root@localhost~]#service network restart

 

 

2、创建共享文件夹  在文件夹中创建几个空文件并设置权限

 

[root@localhost~]#mkdir /share
 
    
[root@localhost~]#chmod 757 /share
 
    
[root@localhost~]#cd /share
 
    
[root@localhost share]#touch 1 2 3 4 5

3、由于NFS的包默认是装过的 就不需要在装了

直接修改配置文件

[root@localhost~]#vim /etc/exports

在配置文件中添加一行

/share 192.168.1.0/24(rw)

然后保存退出

4、重启服务

[root@localhost~]#service portmap restart

[root@localhost~]#service nfs restart

   

5、现在可以手动挂载测试一下了

[root@localhost~]#mount –t nfs 192.168.1.34:/share /mnt

[root@localhost~]#cd /mnt

[root@localhost~]#ll

好了手动挂载成功

接下来设置自动挂载

6、

新建自动挂载点

[root@localhost~]#mkdir /nfs

修改主配置文件

[root@localhost~]#vim /etc/auto.master

添加一行

/nfs        -rw     /etc/auto.nfs

保存退出

7、复制一个配置文件的母版   然后编辑成nfs 自动挂载的配置文件

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

[root@localhost~]#vim /etc/auto.nfs

进去之后把唯一生效的一行(cd   ……   )    注释掉

添加一行

ss       -rw    192.168.1.34:/share

保存退出

8、重启服务

[root@localhost~]#service autofs restart

好了,现在可以测试一下哈

[root@localhost~]#cd /nfs/ss

[root@localhost~]#ll

 有结果   好了  成功

转载于:https://blog.51cto.com/pbrit/340150