My script creates and mounts loop partitions (therefore requires root and cannot be run under ordinary user), prepares subvolumes, and then points mmdebstrap to it. I had to stop it from complaining about non-empty partition (option –skip=check/empty) and force it to activate usrmerge by not installing usrmerge package (option –hook-dir=/usr/share/mmdebstrap/hooks/merged-usr).
To allow for system start, /etc/fstab needs to point to appropriate subvolume; options set up by default image creation scripts (errors=remount-ro) are also not accepted by btrfs. Therefore root line in /etc/fstab should look like:
We also need to point kernel to appropriate subvolume, by adding rootflags=subvol=@root_a53 to option LINUX_KERNEL_CMDLINE_DEFAULTS in /etc/default/flash-kernel. Therefore appropriate line in calling mmdebstrap becomes:
I have never used btrfs but its man page states that it has the --rootdir option. Maybe you can try first creating a directory and then create the btrfs volume using --rootdir and thus avoid having to mount anything which needs superuser privileges?
If you just created the partition, why was it non-empty?
What happens if you do not do that?
Have you codified all of this is a script? Maybe as a patch against the reform-system-image git? You could also file a merge request and maybe it would be useful to have an option that creates a system image using btrfs?
Sorry for long time to respond - got busy with Python/PostgreSQL packages before freeze
Full script is at the bottom: use at your own risk!
As you can see in script (first half): partition is not empty, I created some subvolumes and directories there.
After recent change in Debian’s init-system-helpers (which is Essential: yes), it depends on either usrmerge or usr-is-merged packages. When hook is not added to mmdebstrap, it tries to install usrmerge which gets run quite late in installation process, and gets confused when there are existing directories and subvolumes. So it fails, and entire mmdebstrap call ends with error. I guess this would not be a problem if I haven’t created all the subvolumes.
I’m not sure if it makes sense to propose patch or merge request to reform-system-image repository - at least not yet. Current script is work in progress (I’m not using system generated by it daily), and it is (more correctly - will be) customized for my needs. But I might be wrong here - if there is something you find interesting, feel free to use it.
That sounds like a bug in usrmerge then. Can you try first creating an unmerged system using --hook-dir=/usr/share/mmdebstrap/hooks/no-merged-usr and after that is done, remove /etc/unsupported-skip-usrmerge-conversion and then replace usr-is-merged with the usrmerge package which will attempt converting the system? If that fails, then usrmerge does not support the boot, etc, usr and var btrfs subvolumes which should definitely be fixed as this will also affect existing systems with such a setup of subvolumes.
Thank you for your script! I also learned new things.