PDA

View Full Version : Permanent NFS Mount


colinrotherham
2005-07-20, 12:30 PM CDT
Hi, i'm pretty new to mounting NFS shares, although i've got successfully got it all to work.

How can i make it automatically mount my NFS share on boot? What do i need to add to fstab etc for it to work? It's a read-only share

ibbo
2005-07-21, 02:54 AM CDT
edit your /etc/fstab file and insert the reuired command in it.

Ibbo

CrystalCowboy
2005-07-22, 09:27 AM CDT
Make sure the mount point exists. A mount point is an empty directory
mkdir /remote_disk

The line in /etc/fstab should look something like this:
remote_server:/remote_disk /remote_disk nfs ro 0 0

First entry, location of remote disk.
second entry: local mount point
third entry, filesystem type = NFS
fourth entry, mount options. You said you wanted read-only so I put in "ro".
If you did NOT want the disk to mount automatically on reboot, a "noauto" would do it.
Many other options available. Scan the man pages for /etc/fstab and for mount.

5th and 6th entries, irrelevant to NFS, leave as 0 (zero)


Don't forget to set permission on the NFS server, usually handled in file /etc/exports and depending on the OS may require the exportfs command.

The disk should be mounted automatically on reboot. To mount it now, try
mount /remote_disk

If you are running any sort of firewall or net security, you may need to tweak that to allow NFS packets.

kosmosik
2005-07-22, 07:19 PM CDT
NFS is fine and stuff but it fails for f.e. laptops - I carry my laptop around various networks and it is instant on - well it is hibernated when I carry it. nevertheless when you turn laptop on in one network it will go thru boot and mount NFS somewhere. now you unplug your laptop in other place and there are other NFS shares but they will not mount automagically as fstab is processed ony on boot - this is a problem. so I don't use fstab for network mounts. :)

what I suggest you is to use autofs which is superior - it mounts (well attemps to) desired FS when you request to access it (via standard system calls).

quick howto (be root of course):
1. be sure to have autofs installed and running on boot (as service)
2. # mkdir /var/local/autofs
3. # mkdir /net
4. # $EDITOR /etc/auto.master
/var/local/autofs /etc/auto.net --timeout=3600
5. # $EDITOR /etc/auto.net
in this file put something like:
foo -fstype=nfs,rw,hard,intr fooserver:/foo
bar -fstype=nfs,rw,hard,intr barserver:/bar
of course you need to supply proper data concerning what you wish to mount
6. now having that done issue "service autofs restart" to tell it to reread the configuration
7. now we do some links:
# ln -s /var/local/autofs/foo /net/foo
# ln -s /var/local/autofs/bar /net/bar
8. done

Now when you do "ls /net/foo" if the server fooserver is aviable you will get it mounted and will be able to access the files. If it is not aviable (you are on other network f.e.) it will just say that there is no such dir or file. :) quite convinient. no mounting no anything. works well with SMB shares also...

oh and if you do "ls /net" it will show you what servers are aviable. here it is how it looks like on my system:
http://misc.kosmosik.ath.cx/imgs/autofs.png

CrystalCowboy
2005-07-22, 07:50 PM CDT
Yes, autofs has certain advantages, in particular stability. It doesn't actually mount a disk until someone tries to access it. Whereas with static NFS mounts, the disk is usually mounted al lthe time and if the server or network goes down, the client screams bloody murder.

Static mounting has some advantages itself; you can do a df and see what space is available, for example.