Adding Windows Shares in Linux

I was recently asked to access Windows Share from within Linux. It’s not an unusual task, but it’s not common either. Windows shares are a bit confusing to Linux users because Microsoft use backslashes which are designated as an escape key in Linux. Windows shares typically use this \\Windows\Directory\Structure.

The easiest way to access a Window share is to mount it from within Linux. In this example, we have a Windows share called \\Windows\Directory\Structure. We want to mount it in Linux, so that it is available on /mnt/share. The following are the steps to take to mount Windows shares on a Linux box. I’m using Ubuntu 11.04 on this example.

Create A Directory

First, we need to create a destination mount. In this case, /mnt/share.

sudo mkdir /mnt/share

Mount The Share

Next, we will mount the Windows share using CIFS or Common Internet File System. CIFS is similar to the SMB protocol. You can use SMB as well, but CIFS worked for me.

sudo mount -t cifs //Windows/Directory/Structure
  -o username=your_username,password=your_password /mnt/share

Add To Fstab

To have a more permanent structure, we will add the Windows share to /etc/stab, so that every time Linux is rebooted, the shared drive will be mounted automatically. Jus edit the /etc/fstab file and add the following:

//Mounted/Directory/Structure /mnt/share cifs
  u<var id="yiv1712973071yui-ie-cursor"></var>sername=your_username,password=your_password, 0 0

Once the changes are made, you can mount all using this command

mount -a

Finally, you can then check if the Windows share drive is available from within /mnt/share.