[RH134] 10-NFS and Samba Clients

For configuration of NFS and samba servers, see:

Here, we will only discuss the use of the client

 

1. Use of NFS clients

nfs implements a remote shared directory between Unix-like systems.

 

Suppose we already have a server that provides nfs services with an IP of 192.168.1.17.A directory/aa has already been shared.

1) Query nfs directory

[root@centos7 etc]# showmount -e 192.168.1.17

2) Mount the remote directory

[root@centos7 etc]# mount 192.168.1.17:/aa /nfs

3) Automount

Modify/etc/fstab to:

/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. Use of samba clients

samba implements shared directories between Unix-like systems and Windows.

 

1) Install smbclient command

Query which packages provide this command first:

[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

Install 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) Query Windows Shared List

First, we create a user on Window s:

C:\Users\Administrator>net user leo 111111 /add
 The command completed successfully.

The user name is leo and the password is 11111.

Then use smbclient to query which shared directories are there:

[root@centos7 etc]# smbclient -L 192.168.1.3 -U leo%52myself    

        Sharename       Type      Comment
        ---------       ----      -------
        ADMIN$          Disk      Remote Management
        C$              Disk      Default Sharing
        D$              Disk      Default Sharing
        E$              Disk      Default Sharing
        F$              Disk      Default Sharing
        G$              Disk      Default Sharing
        H$              Disk      Default Sharing
        I$              Disk      Default Sharing
        IPC$            IPC       Long-range IPC
        J$              Disk      Default Sharing
        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) Remote Access

[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

You can see that the share directory was successfully shared (note that the share directory has permissions, and leo users must have at least read permissions to access it).

4) Mount

[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.

We mounted the 192.168.1.3/share directory into the / smb directory, but found an error. The error is that there is a problem with the file system type. The shared directory uses the cifs file system, which is not available on Linux. You can use mount. <type> to view:

[root@centos7 etc]# mount.
mount.fuse  mount.nfs   mount.nfs4

So we need to install 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

Then mount (specify who uses windows):

[root@centos7 etc]# mount -o username=leo,password=111111 //192.168.1.3/share /smb

Then we can use the shared directory:

[root@centos7 smb]# ls
fengjing.mkv

5) Automount

Similarly, modify/etc/fstab to:

/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

 

 

===

Tags: CentOS yum Windows Unix

Posted on Sun, 05 Apr 2020 20:45:05 -0700 by mridang_agarwal