Technically Feasible

Mounting Windows Shares with cifs in Debian Squeeze

Likeness of Michael Oldroyd
Michael Oldroyd
⚠️ This content was imported from a previous incarnation of this blog, and may contain formatting errors

openlogo-ndI run Debian Squeeze with Gnome 3 on a laptop. I mainly use this to offload my e-mail from the main machine, where I can concentrate my workflow across two screens without the constant need to ALT-Tab. This means that there is a need to share files between the Windows desktop machine and Laptop, using regular windows file shares.

I had a series of "bookmarks" that allowed me to access various Samba shares. These bookmarks (GVFS mounts) are configured in Nautilus, and really simple to set up. Unfortunately, they are not so easy to use; you can't drag and drop a file from a GVFS share into a non-supporting application (such as Google Chrome), and they don't usually generate file previews in nautilus either. This could be due to the fact that they use protocol addresses (e.g. smb://)? That means that I was having to copy files—from the shares to a local directory—before being able to work with them.

Configuring CIFS shares to mount on boot #

An alternative to GVFS is to mount shares via CIFS. This method allows you to specify your mounts in your /etc/fstab file. In my case, I had to install the cifs mount utilities first (assuming you have installed and configured sudo);

sudo apt-get install cifs-utils

Then you just need to configure the shares, adding them to the /etc/fstab file. Caution is required here of course; altering this file incorrectly can stop your system from booting. You will need to add new entries into the file that look like the following (substitute all according to your configuration):

/// cifs username=,password=,uid=,gid= 0 0

or you can store your share credentials in a separate file #

/// cifs credentials=,uid=,gid= 0 0

Finally, you need to create your mount point(s) and test that your shares work. You can do this by trying to mount them with -v for verbose output:

sudo mount -v

In testing this configuration, I am able to access network shares using this method as if I was working with local directories; there is just a bit more overhead to set up new shares. The mounts fail gracefully (the system still boots!) when the network locations aren't available. You would need to manually remount them with root privileges (or add the users option) if they become available after booting. There are a plethora of further mount options for cifs depending upon your configuration.

Image of me

Michael Oldroyd

Michael is a Software Engineer working in the North West of England.