访问网络文件系统 一.cifs yum install samba-client -y ##安装客户端软件 smbclient -L //ip ##确定访问地址 访问方式1 smbclient //ip/sharename [root@netfsclient mnt]# smbclient //172.25.254.253/westos Enter root's password: Domain=[USER-20161030DE] OS=[Windows 5.1] Server=[Windows 2000 LANManager] smb: \> [root@localhost ~]# smbclient //172.25.254.250/westos1 Enter root's password: Domain=[MYGROUP] OS=[Unix] Server=[Samba 4.1.1] smb: \> !ls anaconda-ks.cfg smb: \> ls . D 0 Thu Apr 13 11:34:37 2017 .. D 0 Thu Dec 3 09:43:01 2015 file1 N 0 Thu Apr 13 11:34:36 2017 file2 N 0 Thu Apr 13 11:34:36 2017 file3 N 0 Thu Apr 13 11:34:36 2017 file4 N 0 Thu Apr 13 11:34:36 2017 file5 N 0 Thu Apr 13 11:34:36 2017 file6 N 0 Thu Apr 13 11:34:36 2017 file7 N 0 Thu Apr 13 11:34:36 2017 file8 N 0 Thu Apr 13 11:34:36 2017 file9 N 0 Thu Apr 13 11:34:36 2017 file10 N 0 Thu Apr 13 11:34:36 2017 file11 N 0 Thu Apr 13 11:34:36 2017 file12 N 0 Thu Apr 13 11:34:36 2017 file13 N 0 Thu Apr 13 11:34:36 2017 file14 N 0 Thu Apr 13 11:34:36 2017 file15 N 0 Thu Apr 13 11:34:36 2017 file16 N 0 Thu Apr 13 11:34:36 2017 file17 N 0 Thu Apr 13 11:34:36 2017 file18 N 0 Thu Apr 13 11:34:36 2017 file19 N 0 Thu Apr 13 11:34:36 2017 file20 N 0 Thu Apr 13 11:34:36 2017 48936 blocks of size 2097152.14626 blocks available 访问方式2 mount //ip/sharename /mountpoint -o username=guest vim /etc/fstab ##### //ip/sharename /mountpoint cifs defaults,username=guest 0 0 ##### mount //172.25.254.253/westos /mnt -o username=guest 开机自动挂载cifs 方法1) vim /etc/fstab //172.25.254.253/westos /mnt cifs defaults,username=guest 0 0 方法2) vim /etc/rc.d/rc.local mount //172.25.254.253/westos /mnt -o username=guest 二.nfs 访问1--手动挂载方式 yum install nfs-client ##安装客户端软件 showmount -e ip ##显示访问地址下共享的目录 mount ip://sharename /mountpoint##临时挂载 vim /etc/fstab ##开机自动激活挂载 ###### ip://sharename /mountpoint nfs defaults 0 0 [root@localhost ~]# showmount -e 172.25.254.250 Export list for 172.25.254.250: /nfsshare/nfs5 * /nfsshare/nfs4 * /nfsshare/nfs3 * /nfsshare/nfs2 * /nfsshare/nfs1 * /content 172.25.0.0/255.255.0.0 [root@localhost ~]# mount 172.25.254.250:/nfsshare/nfs1 /mnt [root@localhost ~]# cd /mnt [root@localhost mnt]# ls file1 file2 file3 file4 file5 [root@localhost mnt]# rm -rf file1 [root@localhost mnt]# ls file2 file3 file4 file5 [root@localhost mnt]# ###### 访问2--自动挂载方式 yum install autofs ##安装自动卸载软件 systemctl start autofs ##启动服务 cd /net/ip ##进入共享目录 vim /etc/sysconfig/autofs ##配置自动卸载时间 ###### TIMEOUT=3 ###### 如何访问3--自定义挂载方式 vim /etc/auto.master ##主策略文件的策略编辑 ##### 最终挂载点的上层目录 子策略文件 ##### vim 子策略文件 ##子策略文件的策略编辑 ##### 最终挂载点 网络挂载资源 ##### systemctl restart autofs ##重启服务,使生效 /mnt /etc/auto.westos [root@localhost nfs1]# cat /etc/auto.westos * 172.25.254.250:/nfsshare/&