Network File System (NFS) : Ubuntu (6.06 / 6.10)

By | 2006/10/20

Update: This post has been updated based on comments by users. See comments for more details.

I realize that this might be something understood by many people but last night I went to set it up and realized I needed some documentation. The documentation that I did find was rather limited so I thought I would put together a quick tutorial for setting up NFS on an Ubuntu system.

For those that aren’t familiar with NFS here is a quick breakdown of what it might be used for.

  • Commonly used data can be stored centrally over an NFS share and accessible by networked machines.
  • Centrally store user /home directories on an NFS share allowing them to take their user settings with them on any locally networked machine.
  • Centrally share CDROM drives, USB drives and more over the network. If a machine does not have a CDROM simply share that device over NFS and get access.

Below are quick steps on installing and configuring an NFS share on your network. I set this up last night in about 5 minutes to share my media (video and audio) to the other machines on my network.

  • sudo aptitude install nfs-kernel-server (install on the central machine you want to share)
  • sudo <editor of choice> /etc/exports (this is the configuration file for NFS)

At this point you’ll have to list the devices or locations that you’d like to share and any specifics of that share. Below is an example of my entry and an explanation of each section.

/media/video *(ro,sync)

The first part of this entry, /media/video, represents the location that I want to “export” or share to the network. This, if you hadn’t guessed is the location of my video files.

The second part begins with *. *, as you probably know, represents everything or in this case everyone on the network. You can replace this with a hostname to limit just who can connect to your NFS share. In my case I want all of my local machines to connect so I’ve left it with *.

After that you see ro which defines “read-only”. All of my local machines can access the folder but none can make changes to any of the files. For now this is what I’d prefer. I’d hate for someone to “accidentally” erase half of the video files so its look but don’t touch access.

Now for the good part. How do I use the share that I’ve just setup? It’s quick and easy and uses our good friend the “mount” command. Below is an example of how I would mount the share I created above.

sudo mount media:/media/video /media/video

Here is a quick breakdown of that command. sudo, of course, to gain the privelege of running that command. mount is the same that you’d use to mount a cdrom or usb flash drive. media: represents the machine on the network. Why isn’t that an IP? I’ve specified media in my /etc/hosts file so I can make that shortcut. /media/video is the name of the remote share (as defined above) and /media/video is the location that I would like to mount to. I know it looks like some repetition but I like the organization. You could easily use anything in those places. (ie; sudo mount server:/home/user /home/Desktop/user)

note: the mount destination must already exist and must be empty to properly function.
Quickly, before I wrap this up. Below is an example of how you can set the NFS share to auto-mount on each boot. This would be helpful if you wanted to take advantage of the example above by centrally sharing /home folders.

sudo <editor of choice> /etc/fstab

Add the following entry (replacing with your specifics) to the bottom of that file.

example.hostname:/share_location /mount_location nfs rw,hard,intr 0 0

You’ll notice that the first part of the entry is very similar to the example for manually mounting the share. The last part, beginning with nfs, specifies the file system type (nfs, vfat, ext3, etc) and the last part specify the rest of the details for that nfs system.

I hope this helps anyone new to setting up an NFS share on their network. Some argue that a problem with Linux is lack of helpful documentation. Well, stick this in your pipe and smoke it.

technorati tags:, , , , ,

11 thoughts on “Network File System (NFS) : Ubuntu (6.06 / 6.10)

  1. Clint Savage

    One is that it’s really not appropriate to use the no_root_squash on most systems because it allows root users on remote systems to access root owned files on the shared files. It also allows root on the client to create files as root on the server.

    In the /etc/fstab entry, I recommend the ‘hard’ and ‘intr’ option.

    From the official nfs site:

    ‘We recommend using hard,intr on all NFS mounted file systems.’



  2. Matthew

    I’m one that is frustrated by the documentation!

    I’m trying to set up an NFS for a small home network. Samba is too slow. All I want is to create one directory that my family can put shared stuff like pictures, movies, music, etc. Still working on it after 3 days.

    I’m a noob to Linux but a 28 year veteran with PC’s starting with old Sinclair.

    How did you modify /etc/hosts file to use the ‘media’ shortcut?

    How would you do it without modifying the /etc/hosts file?

    example.hostname is found/set where? Is this the hostname/domain name set for each NIC? Does a domain have to be in the standard format (e.g. or is ‘mydomain’ good enough?

    What are the options for the fstab file?

    Still not smoking but I appreciate your taking a stab at it! :-))

  3. Ubuntu Tutorials


    check your email for a reply. I will also convert the email into a follow-up post for anyone else having trouble.

    Thanks for contacting me with questions.

  4. Matthew


    Thanks so much — all the other documentation I saw was virtually incomprehensible — designed to set up production server. I think a lot of us just want a simple file server for home and small office sharing.

    If I could impose on your expertise here — How do you set things up on the client side to use NFS?

  5. Pingback: Planeta Ubuntu » Mount Remote Directories Securely with SSH : Ubuntu (6.06.1 / 6.10)

  6. Natasha

    Hi, for me it said “mount to NFS server ‘localhost’ failed.” I also tried the name of my laptop. But I was trying to mount my fat32 shared partition(between dapper & XP), and it’s not empty. How can I do this? I’ve spent the entire day trying to find a solution – really I want to be able to SSH there from anywhere, but I thought I’d try your local NFS-server guide first. Nothing has worked for me so far (and I saw your other article too), from dyndns to no-ip to ssh sshfs to nfs to apache….phewwwww! I don’t know what to do. I’m running around in circles here. Sorry for the rant. 😉

  7. Robyn

    I’ve been trying to connect my dual-boot laptop to my dual-boot desktop for the past week, using Samba and NFS. No luck. I read your tutorial:

    Below are quick steps on installing and configuring an NFS share on your network. I set this up last night in about 5 minutes to share my media (video and audio) to the other machines on my network.
    * sudo aptitude install nfs-kernel-server

    … and after I figured out that I needed to log in as root and *how* to log in as root, because not being logged in as root sudo generated errors, and asked if I was logged in as root – I finally got those files installed.
    Then, I did part 2:

    sudo gedit /etc/exports

    …in which I placed the following entry:


    Here’s where I start getting confused. I specifically gave it that folder name because I was forgetting which folders on my desktop were actually NTFS partitions mounted with NTFS-3g and which were Ext3. I would suspect that the NTFS partitions cannot be shared using NFS. Now, in my /etc/fstab file is the statement:

    flight:/media/NFS_deskdocs /media/NFS_deskdocs nfs rw,hard,intr 0 0

    …where ‘flight’ is the name of the desktop box, ‘/media/NFS_deskdocs’ is the share location… and then ‘/media/NFS_deskdocs’ is the mount location?? I am trying to figure out what is wrong with the picture, here – being a total n00b, the:

    example.hostname:/share_location /mount_location nfs rw,hard,intr 0 0

    didn’t really give me a clue as to what I should be entering for hostname… colour me thick. I noticed you did a manual mount in the terminal – I suppose that was to test it, which I did, but it kept returning an error, like for ‘flight’, the name of my desktop:

    sudo mount flight:/media/NFS_deskdocs /media/NFS_deskdocs
    mount: can’t get address for flight

    and then, if I tried media:
    sudo mount media:/media/NFS_deskdocs /media/NFS_deskdocs
    mount: can’t get address for media

    At this point, I gave up. I’m missing something quite central, here. Where did I go wrong?
    Thanks for any help you can give…


Comments are closed.