Right way to mount Samba on Debian and Ubuntu

I was trying to mount Samba with following commands:

sudo apt-get update
sudo apt-get install cifs-utils

mkdir -p /mnt/smbshare
sudo mount.cifs // /mnt/smbshare -o username=admin,password=1234

Then I create a folder myshare under the samba server and run:

sudo mount.cifs // /mnt/smbshare -o username=admin,password=1234

The command mount.cifs actually equals mount -t cifs, you can use anyone.

Both were failed.

With error:

[37666.843417] CIFS: VFS: Malformed UNC in devname

and error:

[37645.799522] CIFS: VFS:  BAD_NETWORK_NAME: \\\myshare
[37645.800872] CIFS: VFS: cifs_mount failed w/return code = -2


To mount Samba, we have to specify correct server ip and Sharename.

myshare is not the correct Sharename.


Install smbclient to get the device name.

sudo apt install smbclient

Use it in the server host.

smbclient -L //
    Sharename       Type      Comment
    ---------       ----      -------
    _Home1          Disk      1a1fd0dcda5bb1ed0dd3f251eb602eb8
    IPC$            IPC       IPC Service (MAGE20 share)


sudo mount.cifs // /mnt/smbshare -o username=admin,password=1234

Here we replaced the folder name myshareto sharename _Home1.

Auto mount at os start

sudo vim /etc/smbcredentials

Add following:


Edit fstab with command:

sudo chmod 600 /etc/smbcredentials
sudo vim /etc/fstab

Get your uid and gid with id command:


add following line:

// /mnt/smbshare cifs credentials=/etc/smbcredentials,uid=1000,gid=1000,file_mode=0770,dir_mode=0770 0 0

Leave a Reply

Your email address will not be published. Required fields are marked *

Name *