You are here

Easy-Peasy Ubuntu Linux NFS File Sharing

Czar's picture

In this brief blog entry I will note the steps it took for me to use the Network File System (NFS) protocol to share files between another Linux computer. All machines in this lab are either Debian GNU/Linux (unstable) or Ubuntu Linux (breezy badger 5.10 w/ back-port upgrades). After reading countless threads and comments for file sharing they all pretty much suggested SaMBa as the simplest solution. In case you aren’t familiar SaMBa software will allow a UNIX machine to act as a file server to Windows clients. SMB is fine if you _need_ to share with DOS but we don’t need that here. Another option is NFS.

NFS, Network File System, is a file sharing protocol in a UNIX network. It is the de facto UNIX standard. It is strongly associated with UNIX systems, though it can be used on any platform such as Macintosh and Microsoft Windows operating systems. Installation and configuration.
I will be doing this whole set-up through terminal seeing the shares-admin Ubuntu package gave up after a little tweaking.

First install the necessary packages from your local repository. Aptitude may be switch with apt-get for a _less then modern_ installation.

sudo aptitude -P install nfs-kernel-server nfs-common portmap
When configuring portmap do =not= bind loopback. If you do you can either edit /etc/default/portmap by hand or run:

sudo dpkg-reconfigure portmap
If you have edited the file by hand you can restart portmap via:

sudo /etc/init.d/portmap restart
Note: It is not necessary to install NFS on client machines which are not going to be sharing any of their own directories. Sharing Local Folders To specify a folder you will need to edit /etc/exports, which can be done like (replace vi for your favorite editor):

sudo vi /etc/exports
For an example I will share, with full read/write and privileges, my temporary directory. This directory will be broad casted to every local IP from 192.168.1.1 through 192.168.1.255.

/home/czar/tmp 192.168.1.1/24(rw,no_root_squash,async)

To share a read only drive, for example on a Windows NTFS drive, you can use something like the following:

/media/hdc5/music 192.168.1.1/24(ro,async)
sudo /etc/init.d/nfs-kernel-server restart
After making changes to /etc/export you can make the shares effect by issuing the:

sudo exportfs -a Use on the _Other_ PC Last you will need to mount the volume on the other computer. So, ether shift screens or SSH to lab2 and open a terminal. You can only mount into another folder which must be created.

sudo mkdir ~/music
Now mount music from lab1 into ~/music at lab2.

sudo mount 192.168.1.2:/media/hdc5/music ~/music

That’s it! Hopefully everything went well and you can now browse to ~/music locally on lab2. If you encounter errors, do not worry and read them carefully. To mount my first NFS volume felt as if it took weeks. NFS simply owns in a LAN UNIX environment. However I have seen warnings not to share via TCP/IP unless you are on a nice secured BSD system.

Archived Comments from Old blog