We have a colorful environment of Linux (Redhat/CentOS/SLES, and now Ubuntu) and Unix (well, not as colorful..mostly AIX). And a lot of heavy Windows use.
So I regularly get requests to mount windows shares on Linux/Unix systems.
What has inspired me to write this is working quite a bit longer than I expected on a new Ubuntu server to get it to mount a Windows share.
Here we go!
This will be a quick and dirty for you.
Assuming you can talk to the ports and there is no firewall issue of some sort (and that the SMB service itself is working and open on the server), the main problem is usually authentication
Repeat: The main problem with Samba not working is usually authentication
The first thing is to check if authentication itself is working. I use the “smbclient” command for this. It usually has better output if something is not working (though these days you can mount with “–verbose” option and get a lot of nice output also)
smbclient \\\\machinename\\foldername -U [username] [password]
Note: Any special characters in your password, like a dollar sign, may need a backslash to escape.
If my password were “pa$$word”
smbclient \\\\machinename\\foldername -U [username] pa\$\$word
When you connect, it will put you in a “shell” similar to ftp or sftp where you can use commands “ls”, “put”, “get”, etc..
When ready to mount, you will either use filesystem type “smbfs” or “cifs” depending on if you are using an older linux kernel or newer linux kernel.
Older linux kernels:
# mount -t smbfs //servername/foldername /localmountpoint -o username=myusername,password=mypassword
Newer linux kernels:
# mount -t cifs //servername/foldername /localmountpoint -o username=myusername,password=mypassword
The above *should* work on CentOS/Redhat and SLES and I imagine other Linux versions
If you have to specify a workgroup or domain, then include a “dom=domainname” in the options field
Note, including password in the command line is only if you are going to automate it somehow and don’t want to be interactively asked for your password. If mounting manually, by all means don’t include the password!!
Ubuntu is my “special” case today..and is what inspired me to write this post since I worked a lot longer than I should have.
Turns out the default install does not let you do mount, and the error was slightly misleading (in hindsight it wasn’t). It did not give an error that “cifs” was not working, it gave an error that the remote disk could not be read and was going to mount it read-only.
But then it didn’t mount it
root@ubuntu:~# mount -t cifs //servername/share1 /share1 --verbose -o user=myuser,dom=domain
mount: block device //126.96.36.199/share1 is write-protected, mounting read-only
mount: cannot mount block device //188.8.131.52/share1 read-only
What I think it should have told me is an error like the below if you try to use “smbfs”
root@ubuntu:~# mount -t smbfs //servername/share1 /share1 --verbose -o user=myuser,dom=domain
mount: unknown filesystem type 'smbfs'
Turns out you need to install the smbfs package on Ubuntu for the CIFS mount to work.
# apt-get install smbfs
And then we were happy!
Although in my research, I have found some bugginess reported in that the “mount -t cifs” did NOT work, but using “mount.cifs” did .
mount -t cifs //servername/share1 /share1 --verbose -o user=myuser,dom=domain
Did not work
mount.cifs //servername/share1 /share1 --verbose -o user=myuser,dom=domain
I wasn’t able to duplicate this particular issue, but yes … quite strange.
A last point
As most of the problems are authentication related, make sure you can actually authenticate.. Try from other machines, try from your windows machine, make sure the account is not locked!! (part of the issue I had today which compounded my debugging…arrrgghh!!)
So that’s the quick tutorial today! Good luck CIFS-ing and SMB-ing!