Why can't mount read files in "/etc/fstab.d/"?

I'm trying to setup an automatically mounted volume, and noticed that there is now an /etc/fstab.d/ on my server. I created a new file in the directory with the following contents:

# backupstore: large volume
/dev/mapper/bagend-backupstore  /mnt/backupstore        ext4    auto,relatime,users,sync        0       0

But when I run mount -a the volume is not mounted. Also, when I run mount /mnt/backupstore or /dev/mapper/bagend-backupstore I get told that the system couldn't find the entry in fstab (and to pre-empt: yes, the device and mount-point are correct - I can easily mount this with mount -t ext4 /dev/mapper/bagend-backupstore /mnt/backupstore)

When I delete the file from /etc/fstab.d/ and put the entry into the main /etc/fstab file, I have no problems mounting the volume.

So, can the mount command be made to check for entries in /etc/fstab.d/ and if yes, what do I do to make it happen?


Solution 1:

  • /bin/mount cannot read /etc/fstab.d yet, only the library (libmount) can.
  • This is a known "wishlist" bug in util-linux, the package which provides mount
  • The feature has been added in the latest util-linux 2.21 (the release notes say "Use filter arg of scandir* to pickup /etc/fstab.d/*.fstab files")
  • Since even Debian Unstable (Sid) is on version 2.20-x of util-linux, I doubt we'll see 2.21 in Ubuntu until 13.04
  • If you need it sooner, you can either compile 2.21 from the kernel.org source, but I'd recommend you wait until it at least makes its way into Debian (util-linux provides a number of other critical system utilities/libraries as well)

Solution 2:

The /etc/fstab.d support has been reverted from mount(8) after upstream discussion. The mount tab directories are supported by libmount only. It's not planned to support fstab.d in mount(8) by default.

The problem is that /etc/fstab is de facto standard used on many places (libc, systemd, UI programs, ..) and it's unreal wish that all the places can be changed to support fstab.d.

Anyway, you can use a new mount(8) from util-linux >= 2.21 and a new option --fstab <path> to specify alternative mount table, this option also supports directories. It means you have to explicitly specify the directory -- mount(8) will not read it by default. See mount(8) man page for more details.