18

I've read several guides on mounting samba shares, but no luck yet.

I'm able to "login" to my samba share with the following command:

smbclient //vvlaptop/Documents

It asks for password, but there is no password so I just press Enter. It then successfully logs me in with the prompt smb: \>. For some reason I'm unable to mount the share. This is the command I'm using:

mount -t cifs //vvlaptop/Documents /mnt/virginia
mount error: could not resolve address for vvlaptop: Unknown error

How can I mount this device successfully?

2
  • Is not answer, but Works mount -t cifs -o username=USERNAME,password= //$(nmblookup vvlaptop|awk 'END{print $1}')/Documents /mnt/virginia
    – joseluisbz
    May 11 '17 at 15:11
  • Necro I know. See my answer for how I was actually able to use the actual name.
    – Celess
    Sep 24 '18 at 19:09
26

smbclient is able to look up host names

mount is Not able to look up host names

To mount by name you have to use a local DNS service like Avahi. Without a local DNS, you have to specify the IP address when connecting. You can use nmblookup -S WORKGROUP to discover the IP address.

mount -t cifs //192.168.0.123/Documents /mnt/virginia

Usually a better way to access shares is by using smbnetfs. This will allow you to mount many shares without root permission.

smbnetfs ~/mountdir
fusermount -u ~/mountdir # To unmount.

The manpage for smbnetfs will tell you more.

If a share requires login and password, then follow these steps.

mkdir ~/.smb
cp /etc/samba/smb.conf /etc/smbnetfs.conf ~/.smb/
touch ~/.smb/smbnetfs.auth
chmod 600 ~/.smb/*

Edit the file ~/.smb/smbnetfs.auth to insert credentials. File format

auth            "hostname" "username" "password"
1
  • 1
    One of the most helpful posts and a great question. I just fixed a similar issue where I had to nudge a fresh if of 18.04.1 for Avahi to start. Then everything worked. I suspect a lot of people end up asking these questions as maybe not realize it wasn't starting on their VM for whatever reason etc...
    – Celess
    Sep 24 '18 at 18:40
1

Try the following command:

$ mount -t cifs -o username=USERNAME,password= //vvlaptop/Documents /mnt/virginia

Additionally you can store the credentials in a file and reference that instead:

$ mount -t cifs //vvlaptop/Documents /mnt/virginia \
    -o credentials=/home/mylogin/winpasswd

Then put your credentials in that file:

username=mylogin
password=

If the credentials are part of a domain then include this in the file too:

domain=domainname

References

3
  • 1
    I appreciate your help, but that solution doesn't work. I'm not receiving an error of "incorrect user/password".
    – Sepero
    Aug 24 '14 at 21:48
  • Does adding the verbose switch, --verbose give more output? See man mount.cifs.
    – slm
    Aug 24 '14 at 21:51
  • It does not give more information
    – Sepero
    Aug 24 '14 at 22:49
1

Had the same issue trying to mount our NAS. Turns out different commands are needed for (I think it was) different formats i.e. ext 4, NTFS etc. When I eventually found the correct version I was able to mount via fstab and terminal.
We use an Iomega NAS

This fstab works

//NASIomega/Documents /mnt/nas/Documents cifs guest,uid=1000,gid=1000,rw,iocharset=utf8,_netdev,file_mode=0777,dir_mode=0777,auto 0 0

I used the number format instead of the name initially but the numbers kept changing. Failed miserably to give permanent IP addresses where needed so gave the machine a name and now it works.

However, this stopped working on our nadia and maya versions (2 different PCs). The nadia started working maybe due to an update? (not aware of doing anything to correct it despite trying). The maya still does not work. As far as i know i did not change anything. So it looks like there maybe some issues there.

0

I had the exact same symptoms, and I had to nudge Avahi to start for a fresh install of 18.04.1 (which had already been rebooted many times). Then everything worked. I suspect a lot of people end up asking these questions as maybe not realize it wasn't starting on their VM for whatever reason, etc...

Please see Rucent88's answer before reading more of mine, which was one of the most helpful posts for this issue, and the question was a great succinct question.

With fresh installs of 18.04.1, on VMware it worked out of the box. On VirtualBox I had to set the networking on VirtualBox to “Bridged Adapter” and then bump Avahi and add .local to the host name. I have installed the VMware many times and never had issues until trying VirtualBox a few days ago.


On my two day adventure I discovered it was Avahi not starting correctly on fresh 18.04.1 on the VirtualBox setups, where it seemed to start fine on fresh install VMware ones. In addition on VMware some other magic is going on as I don't have to add .local, for XXX machine name and the VMware installs I can simply use the plain Windows host name.

On VirtualBox if I did:

sudo avahi-daemon --check
sudo avahi-daemon
Daemon already running on PID 721

before this, with the added .local:

sudo mount -t cifs -o username=bob,uid=bob,gid=bob //Xxx.local/MyShare /mnt/MyShare

then it works.

Some people claim that changing nsswitch.conf should fix mount resolving the name. But after setting up winbind and adding to the list in all kinds of different ways it didn't work, and adding or removing mdns4_minimal seems to not actually affect mount. Maybe the file wasn't being used.


See also https://ubuntuforums.org/showthread.php?t=2099537 which is a super short example of someone having the problem and someone showing the syntax for fixing his command if you are just missing the differences when using Avahi resolution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.