Hi, it would be nice to have a mount option "nofail" indicating that mount should not return an error if the device does not exit. This is useful for hotpluggable devices which are configured in fstab and might not exist at boot time. Matthias
Do not fail on ENOENT Introduces a new mount option "nofail" which prevents mount to fail if the device does not exist. Signed-off-by: Matthias Koenig <mkoenig@xxxxxxx> Index: util-linux-ng-2.13-rc1/mount/mount.8 =================================================================== --- util-linux-ng-2.13-rc1.orig/mount/mount.8 +++ util-linux-ng-2.13-rc1/mount/mount.8 @@ -609,6 +609,10 @@ This option implies the options (unless overridden by subsequent options, as in the option line .BR group,dev,suid ). .TP +.B nofail +Do not report errors for this device if it does not exist. +.BR fcntl (2). +.TP .B mand Allow mandatory locks on this filesystem. See .BR fcntl (2). Index: util-linux-ng-2.13-rc1/mount/mount.c =================================================================== --- util-linux-ng-2.13-rc1.orig/mount/mount.c +++ util-linux-ng-2.13-rc1/mount/mount.c @@ -182,9 +182,12 @@ static const struct opt_map opt_map[] = { "norelatime", 0, 1, MS_RELATIME }, /* Update access time without regard to mtime/ctime */ #endif + { "nofail", 0, 0, MS_COMMENT}, /* Do not fail if ENOENT on dev */ { NULL, 0, 0, 0 } }; +static int opt_nofail = 0; + static const char *opt_loopdev, *opt_vfstype, *opt_offset, *opt_encryption, *opt_speed, *opt_comment, *opt_uhelper; @@ -389,6 +392,8 @@ parse_opt(char *opt, int *mask, char **e verbose = 0; } #endif + if (streq(opt, "nofail")) + opt_nofail = 1; return; } @@ -1150,9 +1155,11 @@ try_mount_one (const char *spec0, const else if (stat (node, &statbuf)) error (_("mount: mount point %s is a symbolic link to nowhere"), node); - else if (stat (spec, &statbuf)) + else if (stat (spec, &statbuf)) { + if (opt_nofail) + goto out; error (_("mount: special device %s does not exist"), spec); - else { + } else { errno = mnt_err; perror("mount"); }