Setting up an NFS share

The method used to start the NFS server will depend on your distribution

NFS (Network File System) is a protocol used by UNIX/Linux computers to share disks across a network. Similar to the Common Internet File Services (CIFS) protocol used by Windows, NFS is older and more light-weight, and performs much more efficiently on UNIX and Linux systems. This month I'll be showing you how to share a directory on a Linux server using NFS, and how to mount the directory on a Linux client.

Setting up an NFS share

As an example, we'll be sharing the /home directory with all clients on a network. Sharing /home is a good idea if you're running the Network Information Service (NIS) server that I covered in the May issue, as it allows you to use the same desktop and configuration settings on every computer attached to your network.

First, open /etc/exports as root using your favourite text editor. If this file doesn't exist you will need to create it. Add the following to the file:


This line shares the /home directory with all machines on the network and allows each machine to have both read and write access to the share. Change this network address to one that is appropriate for your network. Read only access can be specified by changing (rw) to (ro).

You can individually specify a list of machines that will have access to the share, and tailor the access each machine has to the share, using a line such as:


In this example, has both read and write access to the share while has only read access. Any other machine on your network will be unable to mount the share.

The method used to start the NFS server will depend on your distribution. Under most distributions, e.g. Red Hat Linux, you can start the NFS server by typing in a shell as root:

$ /etc/init.d/nfs start

This script may have a slightly different name in your distribution. For more detailed instructions on setting up a Linux NFS server, see the NFS HOWTO:

Mounting an NFS share

NFS shares are mounted like a local hard disk, using the mount command. To mount an NFS share you will need to know the hostname or IP of the NFS server and the directory on the server in which the NFS share is located. To mount this shared /home directory, type the following in a shell as root:

$ mount -t nfs /home

This command mounts the directory /home stored on the computer at the IP under /home on the local computer. NFS shares can be added to /etc/fstab as with any normal drive. Shares in /etc/fstab are mounted upon boot. This is useful for the /home directory, as it will be needed whenever a user logs in to the computer. An example entry for /home would be: /home nfs rw,bg,hard,intr 0 0

This line background mounts the /home directory, so if the NFS server is not available upon boot your computer will not lock up while trying to mount the share.

Problems with NFS

If the connection between a client and an NFS server is broken, serious problems can occur. For example, when the NFS server is turned off, you may encounter complete lock-ups in a terminal and any applications accessing data stored on an NFS share. This is because the NFS protocol is very bad at identifying a connection drop-out and it waits to reconnect to the NFS server, rather than eventually giving up.

The solution to this problem is simple, but inconvenient. Whenever you break a connection between an NFS client and server, be sure to unmount any NFS shares from all the clients, ideally before the connection is broken. If you forget to do this and the connection between the NFS client and server is re-established, be sure to unmount and remount the shares on each client machine. If you don't remount your NFS shares, you may experience errors when reading from the NFS server. You can unmount a share by typing in a shell as root:

$ umount <mount point of share>

NFS does not include any support for user authentication to access shares. It does, however, support the UNIX/Linux permissions system. When NFS is used in conjunction with an NIS server, it is easy to restrict the access each user has to directories on NFS shares using the same permissions you would on a local hard disk.

NFS includes no user authentication, so it's best used to share system folders, such as /home and directories storing data that applications on your network may need. The Linux implementation of NFS is very good, and with suitable hardware is capable of serving hundreds of client machines. For more information on NFS under Linux, see

Join the newsletter!

Error: Please check your email address.
Rocket to Success - Your 10 Tips for Smarter ERP System Selection
Keep up with the latest tech news, reviews and previews by subscribing to the Good Gear Guide newsletter.

Alastair Cousins

PC World
Show Comments

Cool Tech

SanDisk MicroSDXC™ for Nintendo® Switch™

Learn more >

Breitling Superocean Heritage Chronographe 44

Learn more >

Toys for Boys

Family Friendly

Panasonic 4K UHD Blu-Ray Player and Full HD Recorder with Netflix - UBT1GL-K

Learn more >

Stocking Stuffer

Razer DeathAdder Expert Ergonomic Gaming Mouse

Learn more >

Christmas Gift Guide

Click for more ›

Most Popular Reviews

Latest Articles


PCW Evaluation Team

Edwina Hargreaves

WD My Cloud Home

I would recommend this device for families and small businesses who want one safe place to store all their important digital content and a way to easily share it with friends, family, business partners, or customers.

Walid Mikhael

Brother QL-820NWB Professional Label Printer

It’s easy to set up, it’s compact and quiet when printing and to top if off, the print quality is excellent. This is hands down the best printer I’ve used for printing labels.

Ben Ramsden

Sharp PN-40TC1 Huddle Board

Brainstorming, innovation, problem solving, and negotiation have all become much more productive and valuable if people can easily collaborate in real time with minimal friction.

Sarah Ieroianni

Brother QL-820NWB Professional Label Printer

The print quality also does not disappoint, it’s clear, bold, doesn’t smudge and the text is perfectly sized.

Ratchada Dunn

Sharp PN-40TC1 Huddle Board

The Huddle Board’s built in program; Sharp Touch Viewing software allows us to easily manipulate and edit our documents (jpegs and PDFs) all at the same time on the dashboard.

George Khoury

Sharp PN-40TC1 Huddle Board

The biggest perks for me would be that it comes with easy to use and comprehensive programs that make the collaboration process a whole lot more intuitive and organic

Featured Content

Product Launch Showcase

Latest Jobs

Don’t have an account? Sign up here

Don't have an account? Sign up now

Forgot password?