NFS 和 samba 服务器的配置, 请参考:
这里, 我们只讨论客户端的使用
1.NFS 客户端的使用
nfs 实现的是类 Unix 系统之间的远程共享目录.
假设我们已经有一个提供 nfs 服务的服务器, IP 为 192.168.1.17. 其中已经共享了一个目录 / aa.
1) 查询 nfs 目录
[root@centos7 etc]# showmount -e 192.168.1.17
2) 挂载远程目录
[root@centos7 etc]# mount 192.168.1.17:/aa /nfs
3) 自动挂载
修改 / 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.17:/aa /nfs nfs defaults 0 0
2.samba 客户端的使用
samba 实现的是类 Unix 系统和 Windows 之间的共享目录.
1) 安装 smbclient 命令
先查询什么包提供这个命令:
- [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 :
[root@centos7 etc]# yum install -y samba-client-4.9.1-10.el7_7.x86_64
2) 查询 Windows 的共享列表
首先, 我们在 Windows 上创建一个用户:
C:\Users\Administrator.NET user leo 111111 /add
命令成功完成.
用户名是 leo, 密码是 111111.
然后使用 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
3) 远程访问
- [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 用户至少要有读取权限才能访问).
4) 挂载
- [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
- ===
来源: https://www.cnblogs.com/leokale-zz/p/12543701.html