automount removes mountpoint upon exit
Hi list,
We use automount 4.1.3 in our Kubuntu cluster.
In this cluster, all machines mount their nfsroot ro for security reasons, except for one "master" machine which is used to maintain the nfsroot.
I discovered that every time the master machine shuts down, all the autofs mountpoints are removed. If another machine reboots while the master machine is down, autofs is unable to recreate the mountpoints and thus fails.
Is there any way to keep automount from removing the mountpoint upon exit?
Thanks for your help,
Heinrich Rebehn
University of Bremen
Physics / Electrical and Electronics Engineering
- Department of Telecommunications -
Phone : +49/421/218-4664
Fax : -3341
==> Regarding [autofs] automount removes mountpoint upon exit; Heinrich Rebehn <[email protected]> adds:
rebehn> Hi list,
rebehn> We use automount 4.1.3 in our Kubuntu cluster. In this cluster, rebehn> all machines mount their nfsroot ro for security reasons, except rebehn> for one "master" machine which is used to maintain the nfsroot. I rebehn> discovered that every time the master machine shuts down, all the rebehn> autofs mountpoints are removed. If another machine reboots while rebehn> the master machine is down, autofs is unable to recreate the rebehn> mountpoints and thus fails.
rebehn> Is there any way to keep automount from removing the mountpoint rebehn> upon exit?
Well, in the RHEL version of the package we added a patch that causes automount to only remove directories if it had created them. Thus, if you simply create the top-level automount points, those won't be removed by the demon exiting, However, if you rely on path components below the top-level, you are out of luck.
I've attached the patch, not sure if it will apply to vanilla 4.1.3.
-Jeff
daemon/automount.c renamed from daemon/automount.c.no-rmdir +13 -4
@@ -429,9 +429,17 @@ static int mount_autofs(char *path) ap.pipefd = ap.ioctlfd =-1 ;/* In case the directory doesn't exist, try to mkdir it */ -if (mkdir_path (path,0555 ) <0 && errno !=EEXIST && errno !=EROFS ) { -crit ("failed to create iautofs directory %s" , ap.path); -return -1 ; +if (mkdir_path (path,0555 ) <0 ) { +if (errno !=EEXIST && errno !=EROFS ) { +crit ("failed to create iautofs directory %s" , ap.path); +return -1 ; + } +/* If we recieve an error, and it's EEXIST or EROFS we know +the directory was not created. */ + ap.dir_created =0 ; + }else { +/* No errors so the directory was successfully created */ + ap.dir_created =1 ; }/* Pipe for kernel communications */
@@ -1349,7 +1357,7 @@ static void cleanup_exit(const char *patcloselog (); -if ((!ap.ghost || !submount) && *(path +1 ) !='-' ) +if ((!ap.ghost || !submount) && (*(path +1 ) !='-' ) && ap.dir_created)if (rmdir (path) ==-1 )warn ("failed to remove dir %s: %m" , path);
@@ -1672,6 +1680,7 @@ int main(int argc, char *argv[]) ap.exp_timeout =DEFAULT_TIMEOUT ; ap.ghost =DEFAULT_GHOST_MODE ; ap.type =LKP_INDIRECT ; + ap.dir_created =0 ;/* We haven't created the main directory yet */ opterr =0 ;while ((opt =getopt_long (argc, argv,"+hp:t:vdVg" , long_options,NULL )) !=EOF ) {
include/automount.h renamed from include/automount.h.no-rmdir +2 -0
@@ -111,6 +111,8 @@ struct autofs_point {struct lookup_mod *lookup;/* Lookup module */ enum states state;int state_pipe[2 ]; +unsigned dir_created;/* Was a directory created for this +mount? */ };/* Standard function used by daemon or modules */
Quoted 68 lines · Jeff Moyer
==> Regarding [autofs] automount removes mountpoint upon exit; Heinrich Rebehn <[email protected]> adds:
rebehn> Hi list,
rebehn> We use automount 4.1.3 in our Kubuntu cluster. In this cluster, rebehn> all machines mount their nfsroot ro for security reasons, except rebehn> for one "master" machine which is used to maintain the nfsroot. I rebehn> discovered that every time the master machine shuts down, all the rebehn> autofs mountpoints are removed. If another machine reboots while rebehn> the master machine is down, autofs is unable to recreate the rebehn> mountpoints and thus fails.
rebehn> Is there any way to keep automount from removing the mountpoint rebehn> upon exit?
Well, in the RHEL version of the package we added a patch that causes automount to only remove directories if it had created them. Thus, if you simply create the top-level automount points, those won't be removed by the demon exiting, However, if you rely on path components below the top-level, you are out of luck.
I've attached the patch, not sure if it will apply to vanilla 4.1.3.
(quoted diff) +0
-1-Jeffdaemon/automount.c renamed from daemon/automount.c.no-rmdir +13
-4@@ -429,9 +429,17 @@ static int mount_autofs(char *path) ap.pipefd = ap.ioctlfd =-1 ;/* In case the directory doesn't exist, try to mkdir it */ -if (mkdir_path (path,0555 ) <0 && errno !=EEXIST && errno !=EROFS ) { -crit ("failed to create iautofs directory %s" , ap.path); -return -1 ; +if (mkdir_path (path,0555 ) <0 ) { +if (errno !=EEXIST && errno !=EROFS ) { +crit ("failed to create iautofs directory %s" , ap.path); +return -1 ; + } +/* If we recieve an error, and it's EEXIST or EROFS we know +the directory was not created. */ + ap.dir_created =0 ; + }else { +/* No errors so the directory was successfully created */ + ap.dir_created =1 ; }/* Pipe for kernel communications */ @@ -1349,7 +1357,7 @@ static void cleanup_exit(const char *patcloselog (); -if ((!ap.ghost || !submount) && *(path +1 ) !='-' ) +if ((!ap.ghost || !submount) && (*(path +1 ) !='-' ) && ap.dir_created)if (rmdir (path) ==-1 )warn ("failed to remove dir %s: %m" , path);@@ -1672,6 +1680,7 @@ int main(int argc, char *argv[]) ap.exp_timeout =DEFAULT_TIMEOUT ; ap.ghost =DEFAULT_GHOST_MODE ; ap.type =LKP_INDIRECT ; + ap.dir_created =0 ;/* We haven't created the main directory yet */ opterr =0 ;while ((opt =getopt_long (argc, argv,"+hp:t:vdVg" , long_options,NULL )) !=EOF ) {
include/automount.h struct autofs_point { · line 118
Quoted 8 lines
include/automount.h renamed from include/automount.h.no-rmdir +2
-0@@ -111,6 +111,8 @@ struct autofs_point {struct lookup_mod *lookup;/* Lookup module */ enum states state;int state_pipe[2 ]; +unsigned dir_created;/* Was a directory created for this +mount? */ };/* Standard function used by daemon or modules */
Thank you for the patch, Jeff.
However, i failed to understand the debian package system and simply have no time to read a couple of manpages and howtos just to implement this small patch. So i simply set the immutable flag on our server and it works!
Will this patch be in the officcial version some day, so we eventually see it in debian or ubuntu?
--Heinrich
==> Regarding Re: [autofs] automount removes mountpoint upon exit; Heinrich Rebehn <[email protected]> adds:
rebehn> Jeff Moyer wrote:
rebehn> Thank you for the patch, Jeff.
rebehn> However, i failed to understand the debian package system and rebehn> simply have no time to read a couple of manpages and howtos just to rebehn> implement this small patch. So i simply set the immutable flag on rebehn> our server and it works!
rebehn> Will this patch be in the officcial version some day, so we rebehn> eventually see it in debian or ubuntu?
Yes, it already is in 4.1.4. Ask the debian maintainer to upgrade autofs to that. It's been out for some time, now.
-Jeff
Ian Kent
maintainerQuoted 9 lines · Jeff Moyer
==> Regarding Re: [autofs] automount removes mountpoint upon exit; Heinrich Rebehn <[email protected]> adds:
rebehn> Jeff Moyer wrote:
rebehn> Thank you for the patch, Jeff.
rebehn> However, i failed to understand the debian package system and rebehn> simply have no time to read a couple of manpages and howtos just to rebehn> implement this small patch. So i simply set the immutable flag on rebehn> our server and it works!
Quoted 5 lines
rebehn> Will this patch be in the officcial version some day, so we rebehn> eventually see it in debian or ubuntu?
Yes, it already is in 4.1.4. Ask the debian maintainer to upgrade autofs to that. It's been out for some time, now.
But I thought Heinrich was asking about the top directory of the mount. I don't think we check that in the same way.
I'll have a look later.
Wonder whether I check that in v5 .....
Ian
==> Regarding Re: [autofs] automount removes mountpoint upon exit; Ian Kent <[email protected]> adds:
Quoted 2 lines · Jeff Moyer
Quoted 2 lines
==> Regarding Re: [autofs] automount removes mountpoint upon exit; Heinrich Rebehn <[email protected]> adds:
rebehn> Jeff Moyer wrote:
rebehn> Thank you for the patch, Jeff.
rebehn> However, i failed to understand the debian package system and rebehn> simply have no time to read a couple of manpages and howtos just to rebehn> implement this small patch. So i simply set the immutable flag on rebehn> our server and it works!
Quoted 1 line
Quoted 1 line
rebehn> Will this patch be in the officcial version some day, so we rebehn> eventually see it in debian or ubuntu?
Quoted 3 lines
Quoted 3 lines
Yes, it already is in 4.1.4. Ask the debian maintainer to upgrade autofs to that. It's been out for some time, now.
raven> But I thought Heinrich was asking about the top directory of the mount. raven> I don't think we check that in the same way.
raven> I'll have a look later.
raven> Wonder whether I check that in v5 .....
Yeah, he's asking about the top-directory of the mount. That's exactly what that patch takes care to check for. ;)
-Jeff
Ian Kent
maintainerQuoted 18 lines · Jeff Moyer
==> Regarding Re: [autofs] automount removes mountpoint upon exit; Ian Kent <[email protected]> adds:
Quoted 2 lines · Jeff Moyer
Quoted 2 lines
==> Regarding Re: [autofs] automount removes mountpoint upon exit; Heinrich Rebehn <[email protected]> adds:
rebehn> Jeff Moyer wrote:
rebehn> Thank you for the patch, Jeff.
rebehn> However, i failed to understand the debian package system and rebehn> simply have no time to read a couple of manpages and howtos just to rebehn> implement this small patch. So i simply set the immutable flag on rebehn> our server and it works!Quoted 1 line
Quoted 1 line
rebehn> Will this patch be in the officcial version some day, so we rebehn> eventually see it in debian or ubuntu?
Quoted 3 lines
Quoted 3 lines
Yes, it already is in 4.1.4. Ask the debian maintainer to upgrade autofs to that. It's been out for some time, now.
Quoted 7 lines
raven> But I thought Heinrich was asking about the top directory of the mount. raven> I don't think we check that in the same way.
raven> I'll have a look later.
raven> Wonder whether I check that in v5 .....Yeah, he's asking about the top-directory of the mount. That's exactly what that patch takes care to check for. ;)
Oops. Maybe I'll actually pay more attention some time soon!
Ian
Quoted 2 lines · Jeff Moyer
Yes, it already is in 4.1.4. Ask the debian maintainer to upgrade autofs to that. It's been out for some time, now.
FWIW, the Debian packages for 4.1.4 beta 2 came out Februar 15th, 2005 -- 4.1.4 final June 9th, 2005.
If he's using Debian stable, he'll probably have 4.1.4 beta 2 plus a few extra patches; I'm not sure offhand if that has the patch in question or not.
/* Steinar */
Signature · 1 line
Homepage: http://www.sesse.net/