This is a follow-up to a former question about systemd, BTRFS, /home
being an individual subvolume and the following restriction of systemd I would like to work around:
The file system where the linked unit files are located must be accessible when systemd is started (e.g. anything underneath /home or /var is not allowed, unless those directories are located on the root file system).
/home
is mounted by systemd properly, but contains service files which systemd should start during boot already as well and that doesn't work. /etc/fstab
looks like the following:
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sda1 during installation
UUID=0841ef72-e9d4-45ca-af22-a403783859c6 / btrfs noatime,nodiratime,subvol=@ 0 1
# /home was on /dev/sda1 during installation
UUID=0841ef72-e9d4-45ca-af22-a403783859c6 /home btrfs noatime,nodiratime,subvol=@home 0 2
As initrd is a compressed archive with lots of scripts, in theory it's possible to decompress that (gzip -dc /.../initrd.gz | cpio -id
), change some scripts and mount /home
additionally. I already found the following code in a file called init
which seems to be responsible for mounting /
. Following those function calls reveals parse logic for fstab
etc.
maybe_break mount
log_begin_msg "Mounting root file system"
# Always load local and nfs (since these might be needed for /etc or
# /usr, irrespective of the boot script used to mount the rootfs).
. /scripts/local
. /scripts/nfs
. /scripts/${BOOT}
parse_numeric ${ROOT}
maybe_break mountroot
mount_top
mount_premount
mountroot
log_end_msg
The problem is that I don't want to build a new initrd for each and every kernel update of Ubuntu of course.
So besides customizing the scripts manually, is there some other way to get initrd to mount additional file systems like /home
? Something like kernel parameters provided during startup, maybe some hooks one is able to trigger using special files in /
or such?
I found the following to be of interest:
if read_fstab_entry /usr; then
log_begin_msg "Mounting /usr file system"
mountfs /usr
log_end_msg
fi
If I understand correctly, this recognizes additional mount points like /usr
already. But I couldn't find something like that for /home
.