How to mount Windows Shared Folders on Linux

Well I thought I’d document how you can mount a SAMBA share on a Linux Server (in my case Ubuntu Server), I possibly have a project coming up soon where I may need to mount a Microsoft Windows based shared folder for additional storage/shared storage across multiple Linux/UNIX based web application servers.

Firstly you must make sure that your server/PC has the smbfs package installed, on Ubuntu you can install like like so..

sudo apt-get install smbfs

Once you have checked that you have that installed or installed it if your PC or server on which you want to mount the drive on then you can continue to the next step..

In this example I will be connecting to the following Windows Shared folder (\\myserver\data) and I will be mounting it on my linux server in /mnt/remote-data/.

If the folder ‘/mnt/remote-data/’ does not exist you will firstly need to create this folder like so..

sudo mkdir /mnt/remote-data

Now you can mount the Windows Shared folder like so..

sudo mount -t cifs -rw -o username=ballen,password=yourpassword //myserver/data /mnt/remote-data

If you then want to unmount the remote shared folder, you can enter the following command:

sudo umount /mnt/remote-data

You can also view all your current mounts like so:

sudo mount -l

I hope this helped some people, you can mount anywhere on your OS for example, you could mount the ‘music’ shared folder in your home directory like so…

sudo mount -t cifs -o username=ballen //myserver/music /home/ballen/Music

…but just remember that the folder needs to exist upon which you want to mount on 🙂