Skip navigation

This is my first post written in English. I know I’m not good enough in English, but I thought writing something in English could improve my ability in English. That’s why I’ve decided to post this one in English. I hope that somebody out there (maybe a newbie like me) will find this post useful. Feel free to correct me if I’ve made a mistake either in (something like) grammar or anything else (something technical). Okay, that’s the story, now let’s move on.

I will try to explain how to share files through NFS in GNU/Linux at this first post (I mean in English). NFS stands for Network File System, it is probably the most prominent network service using RPC. It enables Linuxers to share files in the network. By using this service, you will be able to mount files on the remote hosts (often called NFS server) as if it’s a local files.

Preparation

Generally someone who wants to share files through NFS needs at least two PCs. One PC acts as a server and the other one as a client. But you don’t need to worry if you don’t have two PCs, all you need is just to install a virtual machine software. And as we stay in the great GNU/Linux and Free/Open Source world, there are many choices available (for free) out there. For example, let’s say Virtual Box, Qemu, Xen, VMWare Server, VMWare Workstation, KVM, and many others.

I myself prefer VMWare Server to others, as it’s free (yeah it’s free now), simple, and easy to use. It’s installed on my machine running Ubuntu 7.10 a.k.a Gutsy Gibbon. If you use Ubuntu 7.10 (just like me), you may want to try Virtual Box OSE, Qemu, KVM, or Xen as it’s included in the repository. Just simply run

$ apt-get install virtualbox-ose

from terminal and Ubuntu will do the rest for you.

Another important thing is that your kernel should have been configured to support network file sistem, either built in or as a module. If it doesn’t, you may have to recompiled your kernel in order to make it supports the network file system.

As I’ve mentioned early NFS is kind of client-server software, for that reason the rest of this post will be divided into two part, the first part will explain all the things you need to do at the server side and the second for the client side.

Server Side

On the server side, you have to do three steps, first of all you must install the packages required to run a NFS server namely nfs-kernel-server, nfs-common, and portmap. Then, you need to configure your NFS server by editing /etc/exports. The last but not the least, export the directory you want to share. Here is the details

  1. Packages Installation
  2. As usual, make sure that you have configured the repository of your Ubuntu. If you have, open a terminal (Application -> Accessories -> Terminal) and run these command

    $ sudo apt-get update
    $ sudo apt-get install nfs-kernel-server
    $ sudo apt-get install nfs-common
    $ sudo apt-get install portmap

    As simple as that? Yeah, remember that you must run Ubuntu (or another Debian based distros). If you don’t, you may use the tool provided by your distro.

  3. NFS Server Configuration
  4. The main configuration of NFS Server is laid in /etc/exports, just edit this file with your favorite text editor (for this one, I choose vim). Still in terminal,

    $ sudo vim /etc/exports

    then add this line to the end of the file

    /media/multimedia *(rw,sync,no_root_squash)

    /media/multimedia is the directory or file to share (you may change this with directory or file you want to share), * means that any machine permits to mount the directory, this is not recommended instead you may change it to a single IP (192.168.0.10) or a network (192.168.0.0/24). For the rest of the options please see the manual page of /etc/exports by running

    $ man exports

  5. Exporting The Directory
  6. This is the last step at server side, but remember that you have to rerun the command below every time you make a change to the server configuration.

    $ sudo exportfs -a

Client Side

In order to mount the directory or file shared by the server, you need to follow these two steps.

  1. Installing The Required Packages
  2. Not like the server, you just need two package here. They are nfs-common and portmap.

    $ sudo apt-get install nfs-common
    $ sudo apt-get install portmap

  3. Mount The Directory
  4. Actually, this is the real action of this story (who is telling a story🙂 ). As NFS lets you treat the file shared by the server like a local file, so you don’t need anything but mount command. To mount the directory /media/multimedia that is shared by the server above, at client you need to run (supposing that the IP of the server is 192.168.0.1)

    sudo mount 192.168.0.1:/media/multimedia /media/nfs/multimedia

    Make sure that directory /media/nfs/multimedia exists, if it doesn’t make it before you run the command above.

    $ sudo mkdir -p /media/nfs/multimedia

    If you want to mount the directory automatically at boot time, you may add this line to your /etc/fstab:

    192.168.0.1:/media/multimedia/ /media/nfs/multimedia nfs rw,sync 0 0

    Remember that you still need a text editor to edit your /etc/fstab file.

    sudo vim /etc/fstab

That’s all. Huh? That’s all? Yeah.. that’s all.

Reference:

  • Linux Network Administrator’s Guide, 2nd Edition, by Olaf Kirch & Terry Dawson.
  • Komputek Tabloid 550th Edition.

8 Comments

  1. Its worth also mentioning that if you choose to mount your home directory over NFS, you will probably also want to change GDM’s priority higher in order to get your home directory to mount before loading your desktop settings!

    See: http://www.benjiegillam.com/2008/05/ubuntu-nfs-home-directory-issues/

  2. @benjiegillam
    Thx for your information.

  3. Thanks for sharing this info🙂
    Very nice and simple how to
    And your English is very good don’t worry

  4. @mike
    You’re welcome….
    Yeah…. thank you….

  5. Great guide, thanks🙂

  6. @n2j3
    you’re welcome

  7. i think your english is very good…..
    nice post…!!!!


3 Trackbacks/Pingbacks

  1. By Pages tagged "gnu" on 06 Feb 2008 at 8:36 am

    […] bookmarks tagged gnu File Sharing Through NFS saved by 1 others     Rayrocker17 bookmarked on 02/06/08 | […]

  2. By Belajar Linux Itu Mudah « Preman Terminal on 02 Mar 2012 at 7:56 am

    […] dan konfigurasi berbagai macam server, server web Apache, server email Postfix/Zimbra, Samba, FTP, NFS, dkk. Ada pula berbagai teknologi virtualisasi seperti KVM, VirtualBox, OpenVZ, Xen, LXC, atau Qemu […]

  3. By Belajar Linux Itu Mudah | belajar website on 13 Jan 2013 at 6:07 am

    […] dan konfigurasi berbagai macam server, server web Apache, server email Postfix/Zimbra, Samba, FTP, NFS, dkk. Ada pula berbagai teknologi virtualisasi seperti KVM, VirtualBox, OpenVZ, Xen, LXC, atau Qemu […]

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: