I believe, the patch can and must be simplified. *Current state*: The current patch creates a subvol called "@" and then makes a lot of code changes to various activities to make sure that all the activities happen on that subvol. The main brtfs volume is mounted and then root directory path (the subvolume to work on) argument is passed to all the necessary functions. This technique is based on conventions specified in https://help.ubuntu.com/community/btrfs. On this page, the only reason specified for not using default subvolume feature of btrfs is that it does not work with rootfsflags recommended in the page. I find that this convention makes it easy to examine subvolumes and organize them but makes it hard to actually use a subvolume. Typical process of reverting to a snapshot (which is a subvolume) involves switching the default subvolume and rebooting. However, in this convention, switching to a subvolume involves changing boot arguments and modifying the fstab. From a reliability point of view, this is troubling because we have to reliably update the uboot environment, grub configuration and fstab.
*Proposal*: We should use the default volume feature of the btrfs filesytem and we should not pass "subvol=@" etc. in fstab and kernel boot arguments. In fact we should not even create a default subvolume called "@". Then the patch will become very simple. No need to create subvolume, no need to pass rootfsdir to all methods, no need for extra /btrfs directory, no need to have special grub arguments and no need to have special fstab options. The patch should simply create filesystem with type 'btrfs' then treat it like any other filesystem by mounting, debootstrapping, running grub-install etc. This mostly means that the patch is not necessary. We just need to create some test cases (based on existing cases for ext4) to make sure btrfs is building/running fine. Snapshotting tools will then deal with complexity of snapshots/subvolumes. A good example is how Snapper (snapper.io) works. It creates snapshots underneath /.snapshots. When someone reverts to a snapshot, it will set the default subvolume of the btrfs filesystem and recommend a reboot. All of this can be done without the "@" subvolume. I will post a separate proposal for snapshotting in FreedomBox in more detail based on this plan. -- Sunil
signature.asc
Description: OpenPGP digital signature