Mounting a CIFS filesystem directly or via fstab

authenticationfstabmount

I am encountering a problem in which mounting a remote CIFS server without an fstab entry works, but mounting through fstab does not.

The following command works:

$ sudo mount -t cifs //w.x.y.z/Home$ /mnt/dir -o domain=A,username=B,password='C',sec=ntlmssp,file_mode=0700,dir_mode=0700

However, if I instead add the following line to /etc/fstab and try to mount by the mount command (e.g., mount -a or mount /mnt/dir), I receive the error listed below:

$ tail -n 1 /etc/fstab
//w.x.y.z/Home$ /mnt/dir cifs domain=A,username=B,password='C',sec=ntlmssp,file_mode=0700,dir_mode=0700

error:

$ sudo mount /mnt/csif
mount error(13): Permission denied
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)

Explicitly setting dump and fsck pass order to 0 does not help. Both commands seem to do the same thing

Best Answer

When you type the mount command, the part password='C' is first handled by the shell and becomes password=C before it gets to the mount command. This is not done with fstab entries, so you must remove the single quotes. If your password contains special characters you can replace them by their octal code, in particular \040 for space.

Related Question