Hi folks,
I have been tinkering with user_commands.bash
for a few weeks now. It’s great! It works really well and makes it easy to put together a very customized installation.
I have become stumped on a small matter, and I think it is possible I have drifted outside the bounds of what Calamares supports but I thought I would check and see if anyone can spot something I have missed.
I have been renaming the default Btrfs subvolumes in the pre-installation section of user_commands.bash
like this:
# Use the new subvolume name, set mount options
sed -i -e "s|@home|${subvolume_name}_home|" \
-e "s|@cache|${subvolume_name}_cache|" \
-e "s|@log|${subvolume_name}_log|" \
-e "s|@|${subvolume_name}|" \
-e "s|defaults, compress=zstd:1|noatime, compress=zstd|g" /etc/calamares/modules/mount.conf
It works great, it reliably creates the subvolumes with the names I want and mounts them correctly, and adds the correct subvol=
mount option for each on into /etc/fstab
.
Recently, I started testing a setup which calls for a separate boot partition. I want /boot
in a subvolume for snapshotting purposes, and also so multiple installations can share the same boot partition. I added this, to cut in another pair of mountPoint
and subvolume
lines into /etc/calamares/modules/mount.conf
:
# Add new lines for /boot subvolume to mount.conf
sed -i "/btrfsSubvolumes:/a \ - mountPoint: /boot\n subvolume: /${subvolume_name}_boot" /etc/calamares/modules/mount.conf
This is also working great. Here is a snippet from /etc/calamares/modules/mount.conf
after the installation has completed:
[...]
btrfsSwapSubvol: /eos-swayswap
btrfsSubvolumes:
- mountPoint: /boot
subvolume: /eos-sway_boot
- mountPoint: /
subvolume: /eos-sway
- mountPoint: /home
subvolume: /eos-sway_home
- mountPoint: /var/cache
subvolume: /eos-sway_cache
- mountPoint: /var/log
subvolume: /eos-sway_log
mountOptions:
- filesystem: default
options: [ noatime ]
- filesystem: efi
options: [ fmask=0137, dmask=0027 ]
- filesystem: btrfs
options: [ noatime, compress=zstd ]
- filesystem: btrfs_swap
options: [ noatime ]
In this example, subvolume_name
is set to eos-sway
.
I thought adding these lines would be enough for this to work, because in this post the user appears to have successfully added quite a few custom subvolumes.
In my case, it doesn’t work. The subvolume does not get created. I thought perhaps Calamares cannot create this subvolume because it is not one of the default ones, which is fair enough, so I added a few additional lines in the pre-installation part of the script to create the subvolume manually (so Calamares only has to mount it).
# Define the boot partition
boot_partition="boot_partition_placeholder"
# Mount the boot partition
echo "Mounting the boot partition..."
mount -o subvolid=0 "${boot_partition}" /mnt
# Create the boot subvolume
echo "Creating the boot subvolume..."
btrfs subvolume create "/mnt/${subvolume_name}_boot"
# Unmount the boot partition
echo "Unmounting the boot partition..."
umount /mnt
This is working, in that the code is run and the subvolume gets created and everything…but Calamares is still not using it. /boot
gets mounted on the partition, not the subvolume. /etc/fstab
is not getting the subvol=eos-sway_boot
mount option (everything else about the /boot
line in fstab
is correct). All the kernels and initramfs images get dumped outside the subvolume like this:
ls -l /mnt
total 180140
drwxr-xr-x 1 root root 328 Apr 16 10:11 arch_boot
drwxr-xr-x 1 root root 0 Apr 16 16:28 eos-sway_boot
-rw------- 1 root root 58448315 Apr 16 16:41 initramfs-linux-fallback.img
-rw------- 1 root root 17584060 Apr 16 16:41 initramfs-linux.img
-rw------- 1 root root 57039092 Apr 16 16:41 initramfs-linux-lts-fallback.img
-rw------- 1 root root 17397360 Apr 16 16:41 initramfs-linux-lts.img
-rw-r--r-- 1 root root 8099840 Mar 12 13:13 intel-ucode.img
-rw-r--r-- 1 root root 12927488 Apr 10 21:47 vmlinuz-linux
-rw-r--r-- 1 root root 12952064 Apr 13 07:50 vmlinuz-linux-lts
(arch_boot
is a boot subvolume from another installation.)
The main thing that is different with this setup as compared to the other user’s thread I linked is /boot
is a separate partition, like this:
sda
├─sda1 <-- EFI
├─sda2 <-- boot (Btrfs)
└─sda3
└─live-btrfs_crypt <-- root (Btrfs)
That is to say, I have two Btrfs partitions. It seems possible Calamares supports managing subvolumes on a single filesystem only, I’m not sure.
If I move the kernels and images from the root of /boot
into the subvolume I made and add the missing subvol=
option in to /etc/fstab
after the installation completes, the installation boots fine and everything works just as intended. Those are fairly simple little tasks I could incorporate into a script that runs post-installation or something like that. Still, it seems a little hacky; I figured before I do that I should at least ask and see if anyone knows how to get it to work, or if it is even possible.
Here is the installation log: https://termbin.com/m6mx
The full user_commands.bash
script is here: https://gitlab.com/BluishHumility/eos-sway/-/blob/testing/user_commands.bash