Ubuntu - Automount network share with autofs



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.

1. packages Installation

First thing to do is to install smbfs & automount packages :

# sudo apt-get install cifs-utils autofs

2. automount configuration

You 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 :



/mnt/server    /etc/auto.server    --timeout=6000    --ghost


Under some Ubuntu versions, the default auto.master file is having a last line +auto.master which means that the file includes itself !
You must comment or remove that last line or you will get some wierd errors while trying to browe your automount directories.
Make sure you've done it before going further (thanks to François for pointing this out  :-)

Then, create /etc/auto.server to list all the shares that should be automatically mounted under the /mnt/server root :


# /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=cifs,credentials=/etc/auto.auth    ://AddressOfServer/photo
video    -fstype=cifs,credentials=/etc/auto.auth    ://AddressOfServer/video
music    -fstype=cifs,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.


password=xxxxx (can be empty if no password)

Please note that you should not have any space before or after the '=' sign. Otherwise, your credentials won't be taken into account and you will get an access credentials error.

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.

2.1. Desktop shortcut

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.
Any application can access the server files thru :

  • /mnt/server
  • /home/youraccount/Desktop/Server

Isn't it simple  :-)

Signature Technoblog

This article is published "as is", without any warranty that it will work for your specific need.
If you think this article needs some complement, or simply if you think it saved you lots of time & trouble,
just let me know at This email address is being protected from spambots. You need JavaScript enabled to view it.. Cheers !

icon linux icon debian icon apache icon mysql icon php icon piwik icon googleplus