I want to use aufs to combine a few disks.I am able to mount the aufs file system using the mount command from the command line.However, when trying to mount the same through an fstab entry, it fails. Google tells me that fstab does not mount file systems in the specified order, creating this problem. I also found recommendations to add the mount command in rc.local so the aufs is mounted after fstab.I am using archlinux which uses systemd, so how can I run the mount command at boot in systemd?
How to mount aufs file system on boot in archlinux?
linux;arch linux;systemd;fstab
Systemd has native support for mounts (man systemd.mount). In fact systemd reads /etc/fstab, uses it to generate mount units, and mount the filesystems itself.Rather than relying on fstab, it's also possible to create mount units by hand. This is how system mounts like /dev, /sys, /proc, etc are handled (/usr/lib/systemd/system/*.mount). This method allows you to use systemd dependencies to ensure things get mounted in the right order.systemd mount unit files must be named after the mount point they control (man systemd.unit). As an example, I created a unit file to mount my USB backup drive to /mnt/backup. Following the naming convention, I've created /etc/systemd/system/mnt-backup.mount, with the following contents:[Unit]Description = USB backup disk[Mount]What = LABEL=david-usb-backupWhere = /mnt/backupType = ext4[Install]WantedBy = multi-user.targetI then run systemctl daemon-reload for systemd to load the unit. I can run systemctl start mnt-backup.mount to mount the disk, and/or systemctl enable mnt-backup.mount to have it started at boot.For dependencies add Requires = some-other-mnt-point.mount under the [Unit] section. Optionally, you may use BindTo rather than Requires; this will cause it to get unmounted if one of the dependencies disappears. However Requires does not affect the order in which the disks are mounted. So to make sure that the disks are mounted before aufs, use After. Edit: To expand on the use of Requires and After, the unit section might look like:[Unit]Description = USB backup diskRequires = mnt-data01.mountRequires = mnt-data02.mountRequires = mnt-data03.mountAfter = mnt-data01.mountAfter = mnt-data02.mountAfter = mnt-data03.mount