Retrying the mount of a remote machine
I have entries in /etc/fstab for another machine on my network: pleurotus:/ /pleurotus nfs defaults,user,bg,rsize=4096 0 0 pleurotus: /aux/home /pleurotus-home nfs defaults,user,bg,rsize=4096 0 0 pleurotus: /dos_g/Exchange /Exchange nfs defaults,user,bg,rsize=4096 0 0 However, that machine isn't always turned on. I'd like to modify these entries so that if the machine isn't detected, the mount is retried later. I've looked in the nfs man page but didn't find anything there that would indicate what's needed. So how can I implement the automatic retry of the mount? Paul
On Sat, 19 May 2001, Paul Abrahams wrote:
I have entries in /etc/fstab for another machine on my network:
pleurotus:/ /pleurotus nfs defaults,user,bg,rsize=4096 0 0 pleurotus: /aux/home /pleurotus-home nfs defaults,user,bg,rsize=4096 0 0 pleurotus: /dos_g/Exchange /Exchange nfs defaults,user,bg,rsize=4096 0 0
However, that machine isn't always turned on. I'd like to modify these entries so that if the machine isn't detected, the mount is retried later. I've looked in the nfs man page but didn't find anything there that would indicate what's needed.
So how can I implement the automatic retry of the mount? What you can do is setting the noauto option for your nfs partitions and writing a script like
if ping -c 1 -w 1 pleurotus >/dev/null then\ mount /pleurotus mount /pleurotus-home mount /Exchange else\ sleep 300 /path/to/script fi Or you can leave the else-branch and putting it all in a crontab if you prefer.
Paul
-- dieter
dieter wrote:
On Sat, 19 May 2001, Paul Abrahams wrote:
I have entries in /etc/fstab for another machine on my network:
pleurotus:/ /pleurotus nfs defaults,user,bg,rsize=4096 0 0 pleurotus: /aux/home /pleurotus-home nfs defaults,user,bg,rsize=4096 0 0 pleurotus: /dos_g/Exchange /Exchange nfs defaults,user,bg,rsize=4096 0 0
However, that machine isn't always turned on. I'd like to modify these entries so that if the machine isn't detected, the mount is retried later. I've looked in the nfs man page but didn't find anything there that would indicate what's needed.
So how can I implement the automatic retry of the mount? What you can do is setting the noauto option for your nfs partitions and writing a script like
if ping -c 1 -w 1 pleurotus >/dev/null then\ mount /pleurotus mount /pleurotus-home mount /Exchange else\ sleep 300 /path/to/script fi
Or you can leave the else-branch and putting it all in a crontab if you prefer.
I gather, then, that there's no way to handle this in the /etc/fstab entries themselves. Too bad - I had hoped that there was. What's the advantage of noauto? With automounting, if the other machine happens to be on when the current machine starts up, then the mount happens nicely. And with auto, I can get away with the more general "mount -a". It would seem that the cleanest method would be to put "mount -a" in crontab so that it runs every couple of minutes and perhaps (via changes to the /etc/fstab entries) cause the mount to time out quickly so as not to tie up the network. That would avoid having to list the specific remote hosts in a script. Does that make sense? Paul
From Paul Abrahams to SuSE listserve about Re: [SLE] Retrying the mount of...:
I gather, then, that there's no way to handle this in the /etc/fstab entries themselves. Too bad - I had hoped that there was. At least, I never heard of it. Maybe there is :)
What's the advantage of noauto? With automounting, if the other machine happens to be on when the current machine starts up, then the mount happens nicely. And with auto, I can get away with the more general "mount -a". The noauto will prevent your machine from having a long booting time because it tries to find the nfs-server.
It would seem that the cleanest method would be to put "mount -a" in crontab so that it runs every couple of minutes and perhaps (via changes to the /etc/fstab entries) cause the mount to time out quickly so as not to tie up the network. That would avoid having to list the specific remote hosts in a script.
Does that make sense? I guess it does make sense. But I could only find in the mount man page an option for setting the timeout when using the option soft:
This option allows the kernel to time out if the nfs server is not responding for some time. The time can be specified with timeo=time. This option might be useful if your nfs server sometimes doesn't respond or will be rebooted while some pro cess tries to get a file from the server. Usually it just causes lots of trouble. I don't really know what the last sentence suggests but if I were you, I wouldn't use your nfs-partition for any critical applications. If you don't bother, your way of doing is probably cleaner than what i suggested. :) -- dieter
dieter wrote:
I could only find in the mount man page an option for setting the timeout when using the option soft:
This option allows the kernel to time out if the nfs server is not responding for some time. The time can be specified with timeo=time. This option might be useful if your nfs server sometimes doesn't respond or will be rebooted while some pro cess tries to get a file from the server. Usually it just causes lots of trouble.
It seems that the descriptions of "soft" and "timeo" in the man pages for mount and nfs are quite different. The nfs man page refers to major timeouts and hard mounting without defining them, and seems to be saying that "timeo" controls the interval of minor timeouts. The mount man page seems to imply that "timeo" provides much more direct control than that. I'm having a hard time figuring out what the timeout rules really are and how "soft" and "timeo" control them. Paul
Hi. /sbin/mk_initrd from aaa_base-2000.7.24-11.i386.rpm (latest for SuSe 7.0 as far as I know) contains: echo "creating initrd \"$ii\" for kernel \"$kk\" ($vv)" [ -d "$root_dir/lib/modules/$vv/misc" ] || error 2 "no version \"$vv\" modules found" Using kernels 2.4 the tree structure changes, and .../misc doesn't exist now, so above fails. A simple patch could be made (say, deleting "misc"), but where can I find an upgraded 'mk_initrd' for 7.0? (Testing the 7.1 one with rpm -ivh --test seems not to show problems, but who knows, and I don't know if it patches the above).
* Webillo Disperso [Sat, 19 May 2001 20:48:52 +0200]:
[ -d "$root_dir/lib/modules/$vv/misc" ] || error 2 "no version \"$vv\" modules found"
I'd just download the aaa_base package from the 7.1 ftp version and extract mk_initrd from that. 7.1 offers a 2.4.X kernel, so its mk_initrd has to cope with it. Philipp -- Penguins to save the dinosaurs -- Handelsblatt on Linux for S/390
A simpler solution is to use the automounter. You don't need to add entries in the fstab file. If one of the hosts is not on, your boot will take too long. To enable the automounter, install the autofs package (it should have been by default). Edit rc.config and set: START_AUTOFS="yes". Run: # rcautofs start (next time you boot the automounter should be started automatically.) To access the remote directories you have to go through the diretory /net. For example, # ls /net/pleurotus if the mount is successful, you should see all the directories exported by pleurotus. This should work for any other host, provided your machine is allowed by the NFS server. A short explanation: The autofs daemon watches the directory /net for any access. For example: $ ls /net/pleurotus/aux/home/file.txt It takes the first word after net, i.e. pleurotus, contacts the host with that name and asks it what directories it is exporting. Then, it creates the directory /net/pleurotus and mounts the exported directories under it. After a period without activity in the mounted directories, the daemon unmounts the directories and removes the directory it created. -- Rafael
Rafael Herrera wrote:
A simpler solution is to use the automounter. You don't need to add entries in the fstab file. If one of the hosts is not on, your boot will take too long.
To enable the automounter, install the autofs package (it should have been by default). Edit rc.config and set: START_AUTOFS="yes".
Run: # rcautofs start
(next time you boot the automounter should be started automatically.)
There are a couple of other related options in rc.config, I notice. Should USE_NIS_FOR_AUTOFS be left as "yes"? And would it be appropriate to set AUTOFS_OPTIONS to "-timeo=60"? (I assume here that the mention of timeout in the rc.config comment is an error, since NFS has a timeo option but no timeout option.)
To access the remote directories you have to go through the diretory /net. For example,
# ls /net/pleurotus
if the mount is successful, you should see all the directories exported by pleurotus. This should work for any other host, provided your machine is allowed by the NFS server.
A short explanation: The autofs daemon watches the directory /net for any access. For example:
$ ls /net/pleurotus/aux/home/file.txt
It takes the first word after net, i.e. pleurotus, contacts the host with that name and asks it what directories it is exporting. Then, it creates the directory /net/pleurotus and mounts the exported directories under it. After a period without activity in the mounted directories, the daemon unmounts the directories and removes the directory it created.
So if an autounmount occurs and the mount point is accessed a few minutes later (assuming the remote machine is alive), the program looking at the mount point won't really notice that an unmount/remount cycle has taken place, right? Paul
participants (5)
-
dieter
-
Paul Abrahams
-
Philipp Thomas
-
Rafael Herrera
-
Webillo Disperso