Northward Midget Pole to Pole


Mounting Windows Shares On Linux

Posted by Quinn

There must be a gazillion posts on this, so I'm just going to concentrate on what I did wrong.

First I wanted to mount the target share as NFS, but the server doesn't export to our desktop subnet at work. I saw it was running Samba, and remembered having had it working on Windows XP, so tried that. A friend at work had an /etc/fstab line that almost worked.

Turns out smbfs is deprecated and cifs is the new smbfs, so there was a documentation detour of sorts. Anyway, I contacted infrastructure and they gave me a line that worked, but included the password. My coworker's line used a credentials file, and I'd prefer that, because I'm old-school anal about including passwords in the clear and logging in as root and that kind of thing.

So, I took the infrastructure guy's fstab line, turned it into a mount command, ran it with three verbose flags, and saw it was trying to log me in as root, even though my credentials file included my own username.

The fix turned out to be to explicitly add another username option to the line:

//samba-server/dude /ext/dev/dude cifs rw,credentials=/home/dude/.ntcred/dev,username=dude,uid=dude,gid=dude,auto,user 0 0

Replace "dude" with your username everywhere. Here's my ~/.ntcred/dev file:


Replace everything with the appropriate values.  I'm not sure the domain even matters in this case, but it's the NT domain/workgroup of the share.

I think the root of the problem is the parsing of credentials files.  Apparently extraneous whitespace causes it to b0rk itself up.

Oh, and the "user" option (to allow any user to mount it, as opposed to just root, or the conflicting "user" option to samba) won't work unless you set the cifs commands suid root:

chmod +s /sbin/*mount.cifs

Your package manager will probably gripe and/or change that back whenever an upgrade comes up, and since we're using "auto" it's going to be mounted on boot, anyway, so you might as well just sudo the mount the first time and then rest easy.

While I was at it, I tried mounting a few other shares on another domain.  One works fine.  When I try to enter any subdirectories of the other, everything goes to hell.   So, whatever.  I'm done.