Automatically Mounting SMB Shares
30 January 2008
Working with Kubuntu 7.10.
One of the first things you'll want to do when working with Linux after coming from Windows is to link up with your other Windows PC's on the network. Whether it be a file library or music or just another computer to link to, you'll almost certainly want these to load on startup, instead of having to sudo mount the directory each time you log in.
You'll need to have smbfs (Samba File System) installed first.
In terminal type:
sudo apt-get install smbfs
The folder you want the share to be mounted in can be anywhere, though usually it is either in the /media or the /mnt folders.
Create this in terminal by typing:
sudo mkdir /media/share_folder
After that you need to add the mount point into fstab file.
In terminal type:
sudo kwrite /etc/fstab
Add the line:
//SMB_SHARE /media/share_folder smbfs auto,credentials=/root/.credentials,uid=1000,umask=000,user 0 0
Obviously you'll have to select the right Samba Share and also the folder you want it to be mounted in.
SAVE the file and close /etc/fstab.
You will also need to create the file /root/.credentials. Do this by typing into Terminal:
sudo kwrite /root/.credentials
and add the following text:
username=your_smb_username
password=your_smb_password
SAVE and close /root/.credentials
Then you need to make it secure by changing the permissions on the file. (From memory this sometimes causes extra issues for me when auto mounting)
In terminal type:
sudo chmod 600 /root/.credentials
Now you're ready to go. You can either reboot and watch it go, or you can reload your fstab by typing the following into Terminal:
sudo mount -a
And there you have it. How to make your samba shares automatically load on start up. The same applies for Gnome desktop - but use gedit instead of kwrite. Everything else should work.
For more info, see Matt Stone's article: Automatically Mounting Windows SMB Shares in Ubuntu v3.
'Till next time...



