dumb person asks about NFS

Discuss Networking
Post Reply
User avatar
Calum
guru
guru
Posts: 1349
Joined: Fri Jan 10, 2003 11:32 am
Location: Bonny Scotland
Contact:

dumb person asks about NFS

Post by Calum »

i know nothing about NFS. i almost know nothing about networking! here is my question:

i have a laptop with debian sarge on it. it was a Xandros 2 system, and has had all the packages replaced with sarge ones via apt, so some of the coolxandros tools remain. it detected and set up all the samba stuff with my flatmates' two machines which are all connected to the laptop via a hub, which is also connected to the internet. ok so far? this stuff set itself up on its own. it works. the hub (wait, do i call it a router? think so) does the DHCP voodoo so i know nothing about what is going on.

I have bought a network card for my desktop machine. it runs red hat 9. i want to transfer a lot of stuff from the laptop (claudia) to the desktop (harvey), and i think i want to use NFS. How?

How how how? if a basic howto is available, a step by step thing that will enable me to do some setting up and see how it is done, this would be more than helpful. Googling it brings up a lot of stuff that is way over my head though.

User avatar
Void Main
Site Admin
Site Admin
Posts: 5716
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Post by Void Main »

If it's a one time thing I would not mess with NFS but use tar and ssh, or rsync. Of course if you have one machine that will stay up all the time you could create an nfs share on it and then just mount it from your client when needed. I can write up some instructions when I get home. If they were both Red Hat it would be really easy because Red Hat even comes with a graphical tool to create your shares. It's still not a big deal. Just let me know which OS is the server (up all the time) and which is the client.

User avatar
Calum
guru
guru
Posts: 1349
Joined: Fri Jan 10, 2003 11:32 am
Location: Bonny Scotland
Contact:

Post by Calum »

ok, well as per it's not so easy. neither will be up all the time, both will be treated as workstations. the red hat machine will definitely be on for a few hours at most since it's in the bedroom, and the sarge/xandros machine will be on for maybe 3 days at longest. however i would like to be able to define shares on both machines that can be seen from the other machine, and i'd like to be able to share stuff with the two windows machines, but this windows stuff can wait. also if what i just described is a bit complicated, then we can go for a one time one machine to the other solution, but ideally i'd like each machine to check for the other one's existence and then mount whatever shares i define automatically.it's be good to make a way for the shares to be mounted if the other machine is switched on at a later time too.

ok, so now you know what i want to do in layperson terms. as it happens i suspect it will be easy in xandros too, because i bet it has some gui thing also, i notice in the xandros file manager (seems to be a modified konqueror) it has little icons (like in windows, with the my computer and my documents icons) pointing to NFS shares and SAMBA shares. now i am rambling, you see how farmy network knowledge goes.

User avatar
Void Main
Site Admin
Site Admin
Posts: 5716
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Post by Void Main »

Yeah, you just have to make sure all the network services are running (portmap, nfsd, etc) and then add your share to /etc/exports and do an "exportfs -a" command. The thing is, you won't want them to automatically mount in your /etc/fstab and will want to mount and unmount them manually. If you have shares mounted and shut one of the machines down the other can become very unresponsive.

User avatar
Calum
guru
guru
Posts: 1349
Joined: Fri Jan 10, 2003 11:32 am
Location: Bonny Scotland
Contact:

Post by Calum »

so i make sure certain network services are running, then i can define shares in /etc/exports (which i presume is an NFS related config file) and i can make mountpoints and put them in my fstab (which i will have to read up on since i know nothing about what the device names will be) but make them noauto. then i can mount them from the client machine without having to go up/downstairs, providing both machines are on, yes? if this is all correct, then i should be more set to google productively.so tomorrow morning i shall look for more relevant documentation, thanks, void main! now i'm off to bed though, so goodnight!

User avatar
Void Main
Site Admin
Site Admin
Posts: 5716
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Post by Void Main »

Pretty much. You can verify that the share is available on the remote machine by typing:

$ showmount -e servername

and you can mount the share by:

# mount servername:/exported/directory /mnt/local/directory

If you want it in the /etc/fstab the type field will be "nfs" and you'll also not want it automatically mounted for reasons I mentioned before (if the remote machine is not on, it will be sloooooowwww).

User avatar
Void Main
Site Admin
Site Admin
Posts: 5716
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Post by Void Main »

Ok, if you want both to be able to act as both a client and server you'll want to make sure these services are on and started on the Red Hat box (which they should be by default if installed):

Code: Select all

# chkconfig portmap on
# chkconfig nfslock on
# chkconfig nfs on
# service portmap start (if not already started)
# service nfslock start (if not already started)
# service nfs start (if not already started)
On the Debian box you want to make sure the following services are started (which also should be by default if installed and your system is in run level 3 or higher):

Code: Select all

# /etc/init.d/portmap start
# /etc/init.d/nfs-kernel-server start
# /etc/init.d/nfs-common start
For the following examples let's say machine #1 has address 192.168.0.5 and machine #2 has address 192.168.0.10. Now that you have all of the necessary services running the only thing you have to do now is share some directories and mount them. The NFS shares are defined in the /etc/exports file as I mentioned before. Say you wanted to share /home on machine #1, you would put something like this in your /etc/exports:

Code: Select all

/home   192.168.0.10(rw)
In order to make the above newly added line take effect you must type "exportfs -a" which will export all unexported directories. What this does is allows the machine #2 to mount our "/home" directory and have read/write access. It is important that your user numbers machine between the two systems or joe might show up as owning sally's files.

Ok, go to machine #2 and type:

Code: Select all

# showmount -e 192.168.0.5
and it should return this:

Code: Select all

/home 192.168.0.10
It might show your machine's name rather than it's IP address if you have them in your /etc/hots file, or in DNS but you get the idea. Now you need to mount it. First create a directory to mount it on, maybe under /mnt and then mount the remote share. On machine #2 do this:

Code: Select all

# mkdir /mnt/home
# mount 192.168.0.5:/home /mnt/home
The mount command will automatically know this is an NFS type of file system because of the syntax (server:/sharename). Now you should be able to access machine #1's /home directory on machine #2 under /mnt/home. Mind you the "root" will not have access to the share for security reasons. If you want root to be able to access the share as well then you need to add "no_root_squash" to your share options:

Code: Select all

/home   192.168.0.10(rw,no_root_squash)
and of course re-export it (exportfs -r).

If you wanted to add it to your /etc/fstab you could add this:

Code: Select all

192.168.0.5:/home   /mnt/home   nfs   defaults   0 0
Of course since neither machine will be up 100% of the time I suggest that the mounts and umounts be done manually so make sure it doesn't automount the nfs shares:

Red Hat:

Code: Select all

# chkconfig netfs off
# service netfs stop
In Debian make sure /etc/init.d/mountnfs.sh is not linked in any of your /etc/rc*.d directories.

That's about it. See the man pages:
$ man exports
$ man exportfs
$ man nfs
$ man mount
$ man fstab

Post Reply