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 only to a computer using the Windows operating system. Accessing files in the Windows OS from a GNU/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. Below is the description of 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.
sh# mount /dev/hda7 /mnt/win_d
sh# 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 for 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:
sh# mount -o loop /mnt/win_d/myiso.iso /mnt/myiso
sh# 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.
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).
sh# rc-update add nfs default
sh# /etc/init.d/portmap start
sh# rc-update add portmap default
If you ever make changes to the /etc/exportfs file, then export all your changes using:
sh# /etc/init.d/nfs reload
sh# 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.
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
Recent Comments