23

Can I set an /etc/fstab with options=auto to be skipped if mounting fails?

The manual says, it will break the boot process if an entry with options=auto fails.

Without auto, it does not automatically mount the device on boot.

So how to make the auto entry to be ignored on failures?

ledy
  • 565

5 Answers5

17

I created a partition called /dev/sdb1 in my Ubuntu VM. But I didn’t create a filesystem for this partition and so of course it will not get mounted.

Then put following entry in fstab.

/dev/sdb1   /mnt/       auto    defaults,nobootwait     0   2

And rebooted VM. Server got rebooted with following error msg in syslog

suku@ubuntu-vm:~$ grep sdb1 /var/log/syslog
Jan 11 16:32:58 ubuntu-vm kernel: [    2.263540]  sdb: sdb1
Jan 11 16:32:59 ubuntu-vm kernel: [    4.403527] EXT3-fs (sdb1): error: can't find ext3 filesystem on dev sdb1.
Jan 11 16:32:59 ubuntu-vm kernel: [    4.410341] EXT4-fs (sdb1): VFS: Can't find ext4 filesystem
Jan 11 16:32:59 ubuntu-vm kernel: [    4.413978] FAT-fs (sdb1): bogus number of reserved sectors
Jan 11 16:32:59 ubuntu-vm kernel: [    4.414073] FAT-fs (sdb1): Can't find a valid FAT filesystem

What is nobootwait:

nobootwait can be applied to non-remote filesystems to explicitly instruct mountall(8) not to hold up the boot for them.

Giacomo1968
  • 3,553
  • 29
  • 42
Suku
  • 2,066
2

Maybe it will be better to write a script to mount something after boot? For example, put string with noauto to fstab and mount it via rc.local

dr-evil
  • 377
1

For some flavors nobootwait and for for example xfs file systems no work

Below work with UUID

UUID=718ef17e-5502-4a74-81fe-930d21f5507d /data xfs rw,noquota,nofail  0 2
abkrim
  • 425
1

nofail mounts wont prevent the system from booting on failure.

nobootwait was an upstart specific option to prevent upstart from waiting for the device.

Note that since systemd (the replacement for upstart on Ubuntu and most distributions that were using it) mounts fstab entries asynchronously, nofail is enough.

/dev/sdb1   /mnt/       auto    nofail     0   2

In the example above, auto means that the file system type will be auto detected. It could be replaced by ext4, btrfs or vfat for example.

thomas
  • 11
  • 1
0

I am not sure about your distro, but usually booting just waits with a timeout and then will boot without mounting. You can mount it automatically on run time using an udev rule, e.g. on pluggin in.

To bind directories in fstab use:

/from    /to   none bind 0 0 
Giacomo1968
  • 3,553
  • 29
  • 42
Steffen
  • 21