NFS和samba服務器的配置,請參考:windows
這裏,咱們只討論客戶端的使用centos
nfs實現的是類Unix系統之間的遠程共享目錄。服務器
假設咱們已經有一個提供nfs服務的服務器,IP爲192.168.1.17。其中已經共享了一個目錄/aa。app
[root@centos7 etc]# showmount -e 192.168.1.17
[root@centos7 etc]# mount 192.168.1.17:/aa /nfs
修改/etc/fstab便可:ide
/dev/mapper/centos-root / xfs defaults 0 0 UUID=01923e22-2135-4842-be98-c22b7ea968fb /boot xfs defaults 0 0 UUID=7AB0-876A /boot/efi vfat umask=0077,shortname=winnt 0 0 /dev/mapper/centos-swap swap swap defaults 0 0 192.168.1.17:/aa /nfs nfs defaults 0 0
samba實現的是類Unix系統和Windows之間的共享目錄。centos7
先查詢什麼包提供這個命令:spa
[root@centos7 etc]# yum whatprovides */smbclient Loaded plugins: fastestmirror, langpacks Determining fastest mirrors * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com ... ... samba-client-4.9.1-10.el7_7.x86_64 : Samba client programs Repo : updates Matched from: Filename : /usr/bin/smbclient
安裝 samba-client-4.9.1-10.el7_7.x86_64 :code
[root@centos7 etc]# yum install -y samba-client-4.9.1-10.el7_7.x86_64
首先,咱們在Window上建立一個用戶:blog
C:\Users\Administrator>net user leo 111111 /add
命令成功完成。
用戶名是leo,密碼是111111。ci
而後使用smbclient來查詢有哪些共享目錄:
[root@centos7 etc]# smbclient -L 192.168.1.3 -U leo%52myself Sharename Type Comment --------- ---- ------- ADMIN$ Disk 遠程管理 C$ Disk 默認共享 D$ Disk 默認共享 E$ Disk 默認共享 F$ Disk 默認共享 G$ Disk 默認共享 H$ Disk 默認共享 I$ Disk 默認共享 IPC$ IPC 遠程 IPC J$ Disk 默認共享 share Disk Reconnecting with SMB1 for workgroup listing. do_connect: Connection to 192.168.1.3 failed (Error NT_STATUS_RESOURCE_NAME_NOT_FOUND) Failed to connect with SMB1 -- no workgroup available
[root@centos7 etc]# smbclient //192.168.1.3/share -U leo%111111 Try "help" to get a list of possible commands. smb: \> dir . D 0 Sun Feb 16 20:18:42 2020 .. D 0 Sun Feb 16 20:18:42 2020 fengjing.mkv A 1472480074 Fri Feb 14 16:13:31 2020 33007103 blocks of size 4096. 9185617 blocks available
能夠看到,share目錄共享成功(注意share共享目錄的權限,leo用戶至少要有讀取權限才能訪問)。
[root@centos7 etc]# mkdir /smb [root@centos7 etc]# mount //192.168.1.3/share /smb mount: wrong fs type, bad option, bad superblock on //192.168.1.3/share, missing codepage or helper program, or other error (for several filesystems (e.g. nfs, cifs) you might need a /sbin/mount.<type> helper program) In some cases useful info is found in syslog - try dmesg | tail or so.
咱們將192.168.1.3/share目錄掛載到/smb目錄下,可是發現出錯,錯誤提示是文件系統類型有問題,共享目錄使用的是cifs文件系統,而咱們的Linux下沒有這種文件系統,能夠使用 mount.<type> 來查看:
[root@centos7 etc]# mount. mount.fuse mount.nfs mount.nfs4
因此,咱們須要安裝一下cifs:
[root@centos7 etc]# yum whatprovides */mount.cifs Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com cifs-utils-6.2-10.el7.x86_64 : Utilities for mounting and managing CIFS mounts Repo : base Matched from: Filename : /usr/sbin/mount.cifs [root@centos7 etc]# yum install -y cifs-utils-6.2-10.el7.x86_64
而後掛載(指定用windows的什麼用戶):
[root@centos7 etc]# mount -o username=leo,password=111111 //192.168.1.3/share /smb
而後,咱們就能夠使用共享目錄了:
[root@centos7 smb]# ls fengjing.mkv
5)自動掛載
一樣的,修改/etc/fstab便可:
/dev/mapper/centos-root / xfs defaults 0 0 UUID=01923e22-2135-4842-be98-c22b7ea968fb /boot xfs defaults 0 0 UUID=7AB0-876A /boot/efi vfat umask=0077,shortname=winnt 0 0 /dev/mapper/centos-swap swap swap defaults 0 0 //192.168.1.3/share /smb cifs defaults,username=leo,password=111111 0 0
mount -a
===