Mounting an NFS directory in /etc/fstab

Issues related to applications and software problems
DK907
Posts: 71
Joined: 2011/11/21 16:32:49

Re: Mounting an NFS directory in /etc/fstab

Post by DK907 » 2011/12/04 00:30:25

[quote]
pschaff wrote:
Not a very realistic environment but I guess one has to make do with available resources. You could add the mount command in /etc/rc.d/rc.local that runs at the end of the boot.[/quote]
Thank you, that worked. I added
[code]
mount.nfs david.example.com:/shares /mnt/nfs
[/code]
to /etc/rc.d/rc.local and it worked.
I am curious to know if it is theoretically possible to use NFS to mount a directory that is on the local host at boot using /etc/fstab. It is not important because it is the results that count.

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Mounting an NFS directory in /etc/fstab

Post by TrevorH » 2011/12/04 00:38:08

I do remember doing this a few years ago and I had to amend the order of some of the start-up scripts. Looking at my CentOS 5 box which is the only one I use as an NFS server, in /etc/rc3.d I see that I have S25netfs and S60nfs which means that it will attempt to mount the NFS file systems before it has started the NFS daemons. The solution was to rename the start up script so that netfs ran after nfs.

DK907
Posts: 71
Joined: 2011/11/21 16:32:49

Re: Mounting an NFS directory in /etc/fstab

Post by DK907 » 2011/12/04 19:11:42

[quote]
TrevorH wrote:
I do remember doing this a few years ago and I had to amend the order of some of the start-up scripts. Looking at my CentOS 5 box which is the only one I use as an NFS server, in /etc/rc3.d I see that I have S25netfs and S60nfs which means that it will attempt to mount the NFS file systems before it has started the NFS daemons. The solution was to rename the start up script so that netfs ran after nfs.[/quote]
In CentOS 6, /etc/rc3.d and /etc/rc5.d both contain S24nfslock, S25netfs and S30nfs. Why would Red Hat put these startup scripts in the wrong order?. This is such an obvious problem that I cannot believe it was done by accident. I experimented with this by renaming S25netfs to S32netfs and I commented the mount.nfs4 commands that I had put in /etc/rc.d/rc.local and I uncommented the mount the nfs entries in /etc/fstab. It worked. I am glad that I learned about this problem now so I will know how to fix it when I take the RHCSA exam.

pschaff
Retired Moderator
Posts: 18276
Joined: 2006/12/13 20:15:34
Location: Tidewater, Virginia, North America
Contact:

Re: Mounting an NFS directory in /etc/fstab

Post by pschaff » 2011/12/04 19:47:54

Using the same system as the server and client for NFS is quite unusual, and one might argue of doubtful value in the real world. I doubt it is a situation that would come up on the RHCSA exam, nor one that would be considered by Red Hat when determining the order in which to start services.

User avatar
jlehtone
Posts: 4523
Joined: 2007/12/11 08:17:33
Location: Finland

Re: Mounting an NFS directory in /etc/fstab

Post by jlehtone » 2011/12/04 20:51:03

I think that the logic for startup order is clear.

Mounting foreign filesystems is probably initialization of important
resources to the use of the system. That can be important and
needed early on. There are even diskless clients that definitely
depend on mounting first.

NFS server on the other hand is a mere [i]service[/i] that a fully
operational system provides to the other machines on the network.

DK907
Posts: 71
Joined: 2011/11/21 16:32:49

Re: Mounting an NFS directory in /etc/fstab

Post by DK907 » 2011/12/04 21:45:57

[quote]
pschaff wrote:
Using the same system as the server and client for NFS is quite unusual, and one might argue of doubtful value in the real world. I doubt it is a situation that would come up on the RHCSA exam, nor one that would be considered by Red Hat when determining the order in which to start services.[/quote]
So if I shared a directory using NFS in /etc/exports and I used a different computer as a client then it would not be necessary to rename the startup scripts on the client?. In the RHCSA exam it will be possible to use virtualization to simulate a real client/server network on a single computer so I should start practicing on a computer that is capable of virtualization to get more realistic experience before I take the test.

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Mounting an NFS directory in /etc/fstab

Post by TrevorH » 2011/12/05 00:32:26

Yes, the renaming of the startup scripts is only necessary when you use the same system as nfs client and server at the same time. In normal use it wouldn't be required. Virtualisation is the real solution to your problem.

Post Reply