| Ubuntu - Automount network share with autofs |
|
|
|
| Écrit par Nicolas Bernaerts | |||
| Mardi, 06 Octobre 2009 00:00 | |||
|
It is more & more common to have a NAS or server at home, where you keep all the files that you need to share between your home computers or appliances. For example, if you want to share your music or video library across different computers, you will mostly need to share them thru a cifs (samba) share. This article will explain how to setup a Ubuntu workstation to automount a list of network shares. These network shares won't be mounted all the time, they will be mounted "on demand", when you need them. They will be available thru a desktop icon. The main advantage of automount approach is to have these network shares accessible thru the normal filesystem. This way, even applications which are not able to use gnomefs will be able to access files on the network shares. This setup has been done on a Ubuntu Jaunty 9.04 workstation, but it should work on any later version. Install the packagesFirst thing to do is to install smbfs & automount packages : # aptitude install smbfs autofs Setup the automount configurationYou then need to create the server automount root /mnt/server where all the network shares will be mounted. This root needs to have the proper access rights. # sudo mkdir /mnt/server # sudo chmod 0666 /mnt/server Edit /etc/auto.master to add the following line at the end of the file : /etc/auto.master /mnt/server /etc/auto.server --timeout=6000 --ghost Then, create /etc/auto.server to list all the shares that should be automatically mounted under the /mnt/server root : /etc/auto.server # /etc/auto.server # list all the shares to automount, here are some examples # you need one credential file per different username/password combination photo -fstype=smbfs,credentials=/etc/auto.auth ://AddressOfServer/photo video -fstype=smbfs,credentials=/etc/auto.auth ://AddressOfServer/video music -fstype=smbfs,credentials=/etc/auto.auth ://AddressOfServer/music You have to create as many number of credential files as needed. In this example, all the ressources are accessed with the same username/password, so only one file is needed. /etc/auto.auth username = nobody password = xxxxx (can be empty if no password) Once configuration is over, you need to restart autofs daemon for the changes to take effect. # sudo /etc/init.d/autofs restart You should now be able to automatically mount and browse /mnt/server/photo, mnt/server/video & /mnt/server/music. Ressource will be unmounted by the system after the timeout. If you want to have a direct access to these network shares from your desktop, you just need to create a symbolic link on your desktop. Here the desktop icon will be called Server : # ln -s /mnt/server /home/youraccount/Desktop/Server From now on, you can browse your server shares thru the Server icon on your desktop.
Isn't it simple :-)
|


