Systemd Mount Point Management
- May
- 17
1:13 pm Mac
Today we use systemd to manage our boot process and do nice things like reducing boot time by parallelizing operations and managing service dependencies. One area that still needs some work is /etc/fstab. We're all familiar with making entries there to mount local disks, remote filesystems and perform bind mounts through fusefs. The fstab is still a supported and convenient way to manage mounts but it isn't used directly anymore. Instead, systemd uses a component to parse the file and build standard unit files that can be handled in the normal systemd way. The parsing process is supposed to pay attention to things like file system hierarchies so that it can produce the correct dependencies so that everything gets mounted as intended during the boot process. That is of course if it worked properly. I found out the hard way that it doesn't; at least not in the combination of mounts I had in my /etc/fstab.
/dev/mapper/ingest--digitalarchives--vg-root/ ext4 errors=remount-ro 0 1
/dev/mapper/ingest--digitalarchives--vg-swap_1 none swap sw 0 0
10.20.40.13:/mnt/tank/unix/home/home nfs defaults 0 0
10.20.40.13:/mnt/tank/sftp /sftp nfs defaults 0 0
/sftp/sftp_user/reports /var/www/drupal7/sites/default/files/private/reports none bind 0 0
The fstab had the normal filesystem entries to get the machine up and running including the root slice, swap, etc. There are a few NFS mounts in there and a single bind mount. The bind mount was the one causing the issue; local filesystems and NFS mounts seem to come up fine but the bind mount depended on the NFS mount as it was a subdirectory. The bind mount would execute first and then the NFS mount that overlapped it would hang and force systemd to emergency mode.
Looking at the systemd documentation and it's handling of fstab it seemed that the dependency could manually be stated there as an option. Following examples I tried the following without success.
/sftp/sftp_user/reports /var/www/drupal7/sites/default/files/private/reports none bind,x-systemd.requires=/sftp 0 0
In the end I left the NFS mounts in the fstab and created my own unit file in /etc/systemd/system named var-www-drupal7-sites-default-files-private-reports.mount that looks like this:
[Unit]
Description=Mount for reports
After=remote-fs.target
[Mount]
What=/sftp/sftp_hslc/reports
Where=/var/www/drupal7/sites/default/files/private/reports
Type=none
Options=bind
[Install]
WantedBy=multi-user.target
This makes sure all the NFS file mounting is finished before it tries the bind mount. Now things mount in the proper order and the machine actually boots.
I suspect the problem has to do with the fact that I am using a bind mount. Perhaps the bind mounts are done before remote filesystems without regard to options specified in fstab. I could call it a bug since systemd does not interpret fstab and produce the correct intended result.
« Using Proxy Arp with pfSense | Using networksetup to add static route(s) to a Mac OS VPN » |