Linux Mint – Mount an NFS share automatically

Linux Mint comes pre-installed with all components to mount Windows File sharing (SMB/CIFS) but does not support NFS out of the box. The following post will explain how to enable Linux Mint to mount a NFS share. Additionally the NFS share shall be mounted automatically.

Linux Mint does not come pre-installed with all utilities necessary for mounting NFS shares. The missing package “nfs-common” need to be installed with the following command.

$ sudo apt-get install nfs-common

With the missing components installed, Linux Mint is able to mount an NFS share without any problems. The following commands will mount the NFS share. The first command will create the directory the Share will be mounted to while the second command will mount the NFS share.

$ sudo /media/username/ShareName
$ sudo mount -t nfs hostname-or-IP:/sharename /media/username/ShareName

When un-mounting, the mount directory needs to be removed manually as well.

Automatically mount the NFS share

To automate these manual steps of mounting the share as well as creating the mount directory, a utility named “autofs(5)” can be used. This utility is also not installed per default. To install it, run the following command.

$ sudo apt-get install autofs

Autofs installs a few configuration files. Among them is the auto.master(5)” configuration file at /etc/auto.master” which needs to be changed. This configuration file contains the master-map for autofs. Open the /etc/auto.master configuration file in your preferred file editor.

$ sudo vim /etc/auto.master

Add the following line of configuration to the file. The first part (“/media/username/nfs”) defines the mountpoint for the map while the second is the map-file which in this case is “/etc/auto.nfs”. The filename of the map-file can be chosen and will be created later. The rest of this line are options. The “–timeout=30” defines the time (in seconds) until the directory is unmounted after not using it. The “–ghost” option tells autofs to create “ghost” directories (empty directories) of all the mount points listed in the map-file even if they are not mounted.

/media/username/nfs  /etc/auto.nfs --timeout=30 --ghost

Do not end the mointpoint with a slash as it will change the behaviour. With a slash at the end, the directory “/media/username/nfs” will be the mount point of the nfs share not “/media/username/nfs/sharename” as it is supposed to be.

Now the map-file can be created. Create the file /etc/auto.nfs and open it in your preferred file editor.

$ sudo vim /etc/auto.nfs

The file may contain one or more lines in the format shown below. Each line may represent a different nfs share to mount. The first part of the line is the mountpoint-key and will be added to the mountpoint of the master-map. In this example, the share below will be available via “/media/username/nfs/sharename”. The second part on this line is the mount-options which are used to mount the share. The third part is the location containing the “hostname” and the “path” to the share separated by colon “:”.

sharename   -fstype=nfs4,rw   hostname-or-IP:/sharename

With the share configured in the map-file, autofs can be restarted. Restarting a service in Linux Mint can be done using the following command.

$ sudo systemctl restart autofs.service

Dynamically connect via GUI

To mount NFS shares dynamically without configuring them is also possible. The idea is to enter the URL to the NFS share directly into the file explorer and get connected similar to mounting samba (CIFS) shares. This can also be achieved using the autofs utility.

Add the following line to the master-map file at “/etc/auto.master” which will enable a the mountpoint “/net/” for this purpose.

/net    -hosts -fstype=nfs4,rw

The first part in this line is again the mountpoint while the second part “-hosts” is a built-in map. This built-in map allows to mount shares dynamically by specifying the host and share like this.


Autofs will automatically connect to the server (in this example “hostname-or-IP”) and mount the share “sharename”. Only entering “/net/hostname-or-IP” will show all available shares on the server allowing you to pick one of them. This works from the GUI file explorer as well as from the command line.

Read more of my posts on my blog at

This entry was posted in Linux Administration and tagged , , , . Bookmark the permalink.