UFS Continue booting if UFS device is not present

Hi all,

I have a USB stick with a UFS partition that is mounted at boot (as part of the parsing of /etc/fstab).

However I want the machine to boot even when the USB is not inserted.

My /etc/fstab entry had noauto and I was mounting the USB via /etc/crontab but automount had some odd interactions, so I removed the noauto option and let the OS mount it at boot.

Is there an /etc/fstab option that will let the OS boot with AND without the USB present without the use of a script/crontab entry?

To be clear, if the USB is not present at boot, I want to boot, and I don't care to have it mounted automatically later should it be inserted.

Thanks,
Scott
 
Look into autofs(5)/automount(8). There's no option besides noauto that will help you with fstab. Any failure to mount filesystems from /etc/fstab will cause the system to stop booting and drop to single user mode.
 
Try the failok option.
 
Phishfry thanks for that but unfortunately:

Code:
Restarting file system checks:
/dev/ufs/rootfs: FILE SYSTEM CLEAN; SKIPPING CHECKS
/dev/ufs/rootfs: clean, 2594313 free (1977 frags, 324042 blocks, 0.1% fragmentation)
Can't stat /dev/gptid/cd4988e3-4164-11e9-9e37-b827ebdd491b: No such file or directory
Unknown error 3; help!
ERROR: ABORTING BOOT (sending SIGTERM to parent)!
2020-04-20T14:08:15.992629+10:00  init 1 - - /bin/sh on /etc/rc terminated abnormally, going to single user mode
Enter full pathname of shell or RETURN for /bin/sh:

My /etc/fstab line is:
Code:
/dev/gptid/cd4988e3-4164-11e9-9e37-b827ebdd491b /1      ufs     rw,noatime,failok       1       1

It does seem odd that it drops into single user as my reading of the mount.c code:
Code:
        rval = 0;
...
                                if (hasopt(fs->fs_mntops, "failok"))
                                        failok = 1;
                                else
                                        failok = 0;  
...
                                if (mountfs(fs->fs_vfstype, fs->fs_spec,
                                    fs->fs_file, init_flags, options,
                                    fs->fs_mntops) && !failok)
                                        rval = 1;
...
                exit(rval);
looks as if it should return 0 (from rval).

Well after posting all the above it seems that /etc/rc.d/fsck is where it's dying as it can't stat the device.

So I changed the pass # in /etc/fstab to zero, but of course now it doesn't get mounted when present (which I did not expect from my reading of 5 fstab()

Hmmm...
 
There's no option besides noauto that will help you with fstab. Any failure to mount filesystems from /etc/fstab will cause the system to stop booting and drop to single user mode.

That's not true in all cases. For NFS mounts the bg option will allow booting to continue if the FS can't be mounted. Although I discovered a caveat to that in the past: if mount_nfs can't DNS resolve the NFS server then it will NOT fork but rather die on the spot.
 
Yep did that. As I mentioned above the USB did not mount once I did that.

However I figured out that I had to also make the device late in /etc/fstab (which I did not have to do when the pass # was > 0).

So the way to make this work was indeed to the pass # 0, make the device mount late, and for good measure I added failok.

This means that fsck does not run against the device (and so if not present boot continues), and the mount happens late (which may mean some services would need to wait for mountlate).

It would be nice if fsck also honoured failok.

Scott
 
Yep did that. As I mentioned above the USB did not mount once I did that.

However I figured out that I had to also make the device late in /etc/fstab (which I did not have to do when the pass # was > 0).

So the way to make this work was indeed to the pass # 0, make the device mount late, and for good measure I added failok.

This means that fsck does not run against the device (and so if not present boot continues), and the mount happens late (which may mean some services would need to wait for mountlate).

It would be nice if fsck also honoured failok.

Scott

Good to know Scott,congratulations!
 
Back
Top