A NFS Story on Gentoo

I still carry the habit of storing all the large files in my Windows partitions from my bad old Windows days. That allows me to plug any kind of device into the computer and copy the files to/from it. Gnu/Linux supports all kinds of DVD writers and Pen drives too, but my friends sometimes carry such wierd devices(and mp3 players) that they can be connected to a computer using the Windows operating system only. Accessing files in the Windows OS from a linux partition is a time consuming and inefficient process – I do it using the excellent tool called Explore2FS, but its not an ideal tool for copying large amounts of files and directories. So it suits me well: store the files on the windows partitions and access them easily from both Windows and GNU/Linux(by using a simple mount command).

When I discovered that my old Debian Sarge installation was not detecting the USB port for some reason, and that its DVD-ROM has also died upon me, my only way to transfer some files to it was through the LAN. The files were contained in an ISO file on a Windows NTFS partition on a different machine. This is what I had to do to make the ISO file contents available to my USB-less, DVD-less Debian system:

I use Gentoo as my primary operating system on my personal desktop. The first job for me was to mount the local Windows partition(hda7) that contained the needed ISO file in the Gentoo filesystem.
$ mkdir /mnt/win_d
$ mount /dev/hda7 /mnt/win_d
$ ls /mnt/win_d/*.iso

The ISO file was visible. I tried to export the /mnt/win_d directory using NFS and then tried to mount the ISO file on the Debian system, but it didn't work out that way to me. Not in a mood to loose too much time over it, I mounted the ISO file on my Gentoo System itself and then exported this mounted directory:

$ mkdir /mnt/myiso
$ mount -o loop /mnt/win_d/myiso.iso /mnt/myiso
$ ls /mnt/myiso

All the files contained in the ISO file were visible. The next job is to install the NFS server and the related tools if they are already not available, and then export the /mnt/myiso directory using it.

$ emerge nfs-utils

Put the following line /etc/exports:

/mnt/myiso 192.168.0.0/255.255.255.0(async, no_subtree_check, ro, no_squash_root)

I have specified a range of IP addresses to export the directory to all the machines within the subnet. Only one IP address or a different IP address range can also specified there. Note that there should be NO space between the IP address/IP address range and the opening paranthesis that follows it. To learn more about the different options and their meanings that can be specified in the line, head on to this.

Start the nfs and portmap daemons and add them to the default runlevel(so that they start automatically at the boot time).

$ /etc/init.d/nfs start
$ rc-update add nfs default
$ /etc/init.d/portmap start
$ rc-update add portmap default

If you ever make changes to the /etc/exportfs file, then export all your changes using:

$ exportfs -ra
$ /etc/init.d/nfs reload
$ exportfs

The last command shows you all the directories that are currently exported.

Now go to the other machine(Debian in my case) and use a simple mount command to access the exported directory.

$ mkdir /mnt/remote
$ mount 192.168.0.7:/mnt/myiso /mnt/remote
$ ls /mnt/remote

You should see all the files from the exported directory. The IP address above is of the host system(Gentoo in my case) which is running the nfs daemon. Now you can use the /mnt/remote directory as any other directory on the local gnu/linux system. If the exported directory were a linux partition or a Windows FAT partition, then the write options could also have been ebabled by using the "rw" option in the /etc/exportfs file in place of the "ro" option. The following line can be added to the /etc/fstab file to mount this directory automatically at the boot time:

192.168.0.7:/mnt/myiso /mnt/remote nfs ro 0 0

The IP address, as above, is of the host system. You may be interested in this: NFS in Gentoo

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: