2

In https://askubuntu.com/a/119818/5032 qbi says:

add noauto to your fstab:

...

So the filesystem will not automatically mounted at startup. Furthermore you write a script which basically mounts your mhddfs and add it at some late point in the boot process.

But how do you do this? My mergerfs never mounts all of its drives at startup, presumably because they aren't mounted before it? It's the last entry in fstab, like this (but with more drives):

/mnt/EXT4_drive/drivepool:/mnt/NTFS_drive/drivepool:/mnt/anotherdrive/drivepool /mnt/drivepool fuse.mergerfs defaults,allow_other,minfreespace=100M 0 0

When I run df after boot, the drive name only shows some of the mount points are included, and a fraction of the space it should have with all of them, so they aren't included if they aren't ready? I have to manually run sudo umount /mnt/drivepool ; sudo mount /mnt/drivepool after boot to fix it and show all of them.

Also computer has more than once booted into "Welcome to emergency mode!" when one of the drives was being automatically fscked while it tried to mount /mnt/drivepool. This hasn't happened lately, maybe because of a change in mergerfs that lets it ignore not-ready drives instead of halting because of them?

How would I automatically mount /mnt/drivepool ASAP after everything else in fstab has successfully mounted and fscked?

3
  • Did you add it to /etc/fstab? Have you looked at the mergerfs docs? github.com/trapexit/mergerfs#srcmounts
    – trapexit
    May 16, 2016 at 11:35
  • Yes it's in fstab. Once when a drive was being fscked it put the computer into emergency mode. That hasn't happened lately but now it consistently doesn't include all the mount points it's supposed to be combining. I have to unmount and then remount to include them all.
    – endolith
    May 16, 2016 at 11:40
  • found another possibility: askubuntu.com/a/48964/5032
    – endolith
    May 18, 2016 at 16:02

1 Answer 1

7

Ok so after lots of reading:

Since Ubuntu 15.04, fstab entries are converted into systemd units (*.mount files found under /run/systemd/generator) by systemd-fstab-generator and are then mounted in no particular order, which is why mine was failing.

However systemd supports dependencies, and these can be specified using the fstab option x-systemd.requires.

x-systemd.requires=
Configures a Requires= and an After= dependency between the created mount unit and another systemd unit, such as a device or mount unit. The argument should be a unit name, or an absolute path to a device node or mount point. This option may be specified more than once. This option is particularly useful for mount point declarations that need an additional device to be around (such as an external journal device for journal file systems) or an additional mount to be in place (such as an overlay file system that merges multiple mount points). See After= and Requires= in systemd.unit(5) for details.

So for each prerequisite mount, you add a separate entry to the fstab mount, and it understands path names:

x-systemd.requires=/mnt/XP,x-systemd.requires=/mnt/NTFS_3TB,...

In my first attempt, I left out a /mnt/ and my computer refused to boot and became read-only. ಠ_ಠ To prevent this, you should also add nofail. This makes the mount point a "want" for local-fs.target instead of a "requires", so the computer will still boot if it fails.

Then when you do mount -a it will complain about

fuse: unknown option `nofail'

but it still works anyway. ಠ_ಠ

Here's my complete fstab line, which has worked every time since I changed it:

/mnt/EXT4_backup/drivepool:/mnt/WIN7_BACKUP/drivepool:/mnt/XP/drivepool:/mnt/NTFS_3TB/drivepool /mnt/drivepool fuse.mergerfs nofail,defaults,allow_other,minfreespace=100M,x-systemd.requires=/mnt/XP,x-systemd.requires=/mnt/NTFS_3TB,x-systemd.requires=/mnt/EXT4_backup,x-systemd.requires=/mnt/WIN7_BACKUP 0 0
2
  • @trapexit here is a solution
    – endolith
    May 19, 2016 at 4:48
  • That's what I needed for an overlay mount. Thanks!
    – Anwar
    Aug 16, 2017 at 10:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .