3 ms·
I've been kinda doing a similar thing with my Gentoo installation on btrfs. The btrfs subvolumes are structured like this: <root subvolume>/$(hostname)/${envi
by Teknoman117 4y ago
I've been kinda doing a similar thing with my Gentoo installation on btrfs.
The btrfs subvolumes are structured like this:
<root subvolume>/$(hostname)/${environment}/@volume (e.g. @root, @home)
snapshots look like this:
<root subvolume>/$(hostname)/${environment}/volume_$(date -u +%Y-%m-%d_%H-%M-00)
I have a few scripts "make-snapshots", "backup-snapshots", "update-shell", and "update-commit". make-snapshots creates readonly snapshots of my system, backup-snapshots does incremental backups of those to my NAS, update-shell creates a writable snapshot of @root as @root-update and drops you into a chroot environment. You can then run all the portage commands you want without fear of borking your current environment. Upon exit it checks whatever the /usr/src/linux symlink points to, copies the associated vmlinuz and initramfs images to the EFI partition, and creates/updates a boot entry in rEFInd. You can then boot either into your previous version or the update version. Once you're satisfied that your new environment works, you run "update-commit" which deletes the @root subvolume and replaces it with your current @root-update subvolume.
A change I've been considering is to drop the concept of having a @root subvolume at all. Current implementation requires two reboots: one to get from @root to @root-update, where (if it's good) you delete @root and make a writable snapshot of @root-update as @root. The second reboot is to get onto (the new) @root. An alternative might be to include the date/version in the name of the writable snapshots as well. "committing" the update would just mean setting the current booted subvolume as the "head". Future snapshots/updates will be made from that subvolume. No need for a reboot because you're currently on it with everything mounted correctly. Any writable subvolumes older than "head" would be cleaned up upon booting "head".
Could even go a step further and add something to my initramfs where if you try to boot a version where the writable subvolume has been deleted, it would make a temporary writable subvolume for it from the snapshot.