Browse SMB/CIFS shares under Linux with smbclient

As an admin, one often wants to find out whether CIFS shares can be addressed under Linux or whether these have been created correctly in terms of authorization.

The Linux program smbclient is suitable for this purpose. It works on a console basis and thus checks can be carried out here, e.g. by scripts.

A list of possible releases of a host is requested using the following command:

smbclient -L -U admin

An output, in this case on the host mm with the user mm, looks something like this:

aw@mm:~$ smbclient -L mm -U mm
WARNING: The "syslog" option is deprecated
Enter mm's password:
Domain=[WORKGROUP] OS=[Windows 6.1] Server=[Samba 4.5.16-Debian]

        Sharename       Type      Comment
        ---------       ----      -------
        storage         Disk      Storage
        dokumente       Disk      Dokumente
        mm              Disk      Multimedia
        elearning       Disk      eLearning
        IPC$            IPC       IPC Service (mm server)

If you want to connect to a share, you call the command smbclient as follows:

smbclient //mm/mm -U admin

In this case, the share mm is called on the host mm based on the user admin. The command does not end but you are now in a special “Browsing” mode which is indicated by the prompt smb: \>.

In “Browsing” mode you move with the cd command to switch to directories or ls to display the content of the current directory.

With the commands get and put files can be downloaded or uploaded via CIFS.

You don’t need more to be able to determine whether access via CIFS is possible and whether you can access the necessary resources in terms of authorization.

Test the IO performance of hard-disks/disks using Linux

Measurements by means of dd

Measure writing performance. This test can also be used with CIFS and NFS and is relatively objective:

dd if=/dev/zero of=temp.bin bs=1M count=1024 conv=fdatasync,notrunc

The parameter fdatasync only ends the dd command when the data has been completely synced. Instead, you could also use oflag=dsync which also takes caches into account and waits until they have been written.

Um ohne Puffer zu testen empfiehlt sich der Parameter oflag=direct bei dd. Zusätzlich sollte der Schreibcache der Disk ebenfalls mit

To test without a buffer, we recommend the parameter oflag=direct using dd. In addition, the write cache of the disc should deactivated using:

hdparm -W0 /dev/sda

It can be re-activated using:

hdparm -W1 /dev/sda

The reading performance can be obtained with the command

time dd if=/tmp/test.bin of=/dev/null bs=4k

bs should be matched to the source drive.

Before doing read tests, it is recommended to flush the read cache:

echo 3 | sudo tee /proc/sys/vm/drop_caches

In all tests, where caches play a role, the RAM’s performance is of course also decisive!

Determine data throughput

This point complements the information above, but comes from a different source:

if=/dev/zero of=/tmp/test1.img bs=1G count=1 oflag=dsync

Determine latency

This point complements the information above, but comes from a different source:

dd if=/dev/zero of=/tmp/test2.img bs=512 count=1000 oflag=dsync

Measurements using hdparm

To test the performance of the cache, hdparm can be used.

hdparm -Tt /dev/sda

Using -t the performance of buffered read accesses is determined. This test primarily determines the performance between disk, kernel and chipset including system caches. The optional parameter --direct bypasses system caches and shows the direct data throughput between disk, kernel and chipset.

With -T the read cache is tested, this test does not make hard disk access because it only reads from the Linux buffer cache.