Mount Windows share on Linux

This post is over 3 years old, so please keep in mind that some of its content might not be relevant anymore.

Sometimes I still have to deal with Windows. :-/
This time it’s an office shared disk/device.
I was able to mount it automatically but only root could write in it. Which means that I couldn’t paste files within Nautilus (unless I started it as root obviously).

To overcome this problem I’ve added the following entry in my fstab (/etc/fstab):

NB: It’s on one line only

//192.168.0.1/deviceName$ /mountpoint cifs
domain=hq,username=myUsername,password=myPassword,
_netdev,uid=username,gid=username 0 0

where:
– “mountpoint” is where the network drive will be mounted to;
– in “uid=username,gid=username” username needs to be replaced with your LOCAL user (you can find yours with the “whoami” command);
– “myUsername” and “myPassword” need to be replaced with your windows credentials.

Here is the explanation I found on the net about the “_netdev” option:
“[..] I have specified the _netdev option. CIFS doesn’t know about this option and will throw a warning about it, but you should leave it in. This option ensures that the drives won’t get mounted if you have no network or if you are on the wrong network. It also makes sure your shares get mounted/unmounted when you switch networks. That’s because Debian’s if* scripts are triggered when your network configuration changes, and they watch all the filesystems with the _netdev option and do the right thing automagically.”
Once you have changed the fstab unmount the network drive (if it was already mounted):

sudo umount /mountpoint

and mount all fstab partitions with:

sudo mount -a

Hope it works.

Leave a Reply

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