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 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 @@ -625,6 +625,9 @@ access on the news spool to speed up new .B nodiratime Do not update directory inode access times on this filesystem. .TP +.B nofail +Do not report errors for this device if it does not exist. +.TP .B relatime Update inode access times relative to modify or change time. Access time is only updated if the previous access time was earlier than the 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"); }