Howto add right click menu to mount smb shares in Ubuntu
February 6, 2007
This howto is based on my installed Ubuntu Edgy Eft (6.10), it might work for other versions also.
There are three steps needed here :
1. Make sure smbfs package is installed. By default Ubuntu edgy do not install smbfs package. If it is not installed yet you can install it using this command
$ sudo apt-get install smbfs
After making sure that smbfs is installed, set file permission of smbmnt and smbumount
$ sudo chmod u+s /usr/bin/smbmnt
$ sudo chmod u+s /usr/bin/smbumount
Update : I have update to 7.04 and it is not needed anymore to do chmod for smbumount.
2. Create entry in the /etc/fstab and credential file for username and password
entry in /etc/fstab will look like this :
//asterix/pub /mnt/pub smbfs noauto,rw,users,credentials
=/etc/credentials
Create credential file with the command :
$ sudo gedit /etc/credentials
The credential file content should look like this :
username=adrianus
password=mypassword
After saving the file dont forget to make it secure as it contains your password
$ sudo chmod 600 /etc/credentials
The purpose of creating the entry in fstab is to make the shortcut appear in the desktop after we mount the share, and the purpose of creating credential file is to avoid the need for typing in smb password each time we want to mount the share.
Change the italic part above with your username and password for accessing smb share.
Don’t forget to create the directory for mount point if it is not available yet.
3. Create nautilus script file in $HOME/.gnome2/nautilus-scripts/ directory
My nautilus script file name is “mount pub” the content is something like this :
#!/bin/sh
# Script to mount //asterix/pub
smbmount //asterix/pub /mnt/pub -o credentials=/etc/credentials,uid=adrianus,gid
=adrianus
Don’t forget to make the script file executable using chmod +x yourscriptfilename
4. Last but not least, chown and chgrp the directory you will be using as mount point to be owned by your username.
Now to mount the shares all I have to do is right click mouse over my desktop and choose “mount pub” from the “Scripts” menu and the shortcut icon for the drive will pop up on my desktop ![]()
To unmount I just right click my mouse over the “pub” icon on the desktop and choose “Unmount Volume”
For polishing the look, I browse the mount pub script using nautilus and assign custom icon to it so now it has harddisk icon in the right click menu.
Leave a Reply