I wanted to test out Gentoo a few months ago, but didn’t have the heart to nuke my Arch partition and start from scratch, nor was I interested in compiling my operating system in a virtual machine, so I came up with the following:
# mkfs.btrfs /dev/xxx on a freshly partitioned disk.# mount /dev/xxx /mnt # btrfs subvolume create @<root name># btrfs subvolume create <username>fstab and set the
subvol=<subvolume name> mount option.One of the fstab entrys may look like this:
UUID=<device uuid> / btrfs rw,noatime,subvol=@gentoo 0 0
This file is mostly the same on each installed distribution, all that needs to be changed is the root subvolume option’s value and boot partition.
I previously had a Gentoo chroot environment set up on Arch so I could compile
binary packages for my laptop. I never had to install Gentoo from a dedicated
installation media, rather, I just had to copy the contents of this chroot
environment from Arch to the new @gentoo subvolume.
ID gen top level path
-- --- --------- ----
256 50342 5 @arch
257 58760 5 @gentoo
307 58757 5 Steam
312 50028 256 @arch/var/cache/pacman/pkg
314 58759 5 jstn
315 38348 5 swap
I opted for a hybrid layout, mixing flat and nested subvolume structures where deemed necessary.
Sharing an entire user’s home between different distributions is generally
considered unsafe since program-specific configuration and cache files may be
shared between differing versions of the same program, these files may not be
compatible between program versions. To prevent this from being an issue, while
avoiding the headache of syncronizing two homes, I made a third subvolume for
my user data, jstn. Here I keep my downloads, workspace, documents, journal,
videos, music, etc. I mount this subvolume to /mnt/jstn on both Gentoo and
Arch, and set up symlinks from my home to those directories.
I set up a subvolume for Steam as well, but for a different reason: I wanted to
exclude Steam’s data from snapshots of my personal data subvolume. Unlike most
distribution packaged programs the Steam client updates itself, I trust
Steam-specific configurations will always be shared by an up-to-date version
of Steam. I mount this subvolume where it’d normally be on both Arch and
Gentoo, at ~/.local/share/Steam.
My swapfile is also contained within it’s own subvolume, swap, this omits the
swapfile from being part of @... snapshots and allows the swapfile to be
shared between Arch and Gentoo.
Initially I tried to share one boot partition between Arch and Gentoo but
running grub-mkconfig ... wouldn’t make an entry for both systems. So I set
up two boot partitions, one for Arch and the other for Gentoo. I enabled Grub’s
os-prober on Gentoo.
Admittedly, even though I’ve made decisions for my subvolumes specifically for snapshot purposes, I haven’t really bothered with them. I can’t think of a good use for them in my environment over proper backups.
I also don’t boot to Arch very often anymore since getting Gentoo “caught up” with where I left off on Arch. I am tempted occasionally when I question if the value of Gentoo’s source-based approach is worth the extra time and effort on my end. At least with this configuration it is fairly hassle-free to get back to Arch (or vise versa).