We often search for the ideal linux flavour that will satisfy our requirements. It is hard to strike a ballance between an accessible system and a system that works against the latest packages. So we often end up testing new setups or modifying our existing setup to try an alternative configuration.
The problem is then to be able to quickly revert to a working setup incase anything goes wrong or is not up to scratch.
We want something like gits ability to switch between branches, but for actual systems.
Solution is to use btrfs for your filesystem, mixed with a subvolume/default subvolume and snapshot strategy.
on the chosen disk or partition, setup btrfs.
mkfs.btrfs /dev/sda1 -L "label"
This creates a btrfs filesystem, with a default subvolume 0. now mount this, and create the structure that will hold the various roots of each system.
mkdir home roots experiments
branches have heads, we represent this by the @ subvolume. home/@ is the current head for our home partition. In my setup home doesn't need branching facilities, just snapshot facilities. For btrfs it is identical, but its just the way we think about them that is different.
we might end up with something like:
home/@ home/2012-07-23 home/2012-08-23 home/2012-09-23
For roots we might have something like:
roots/@ roots/clean roots/clean-2012-08-23 roots/code roots/code-2012-08-23 roots/readme
here we have two branches, the clean branch, with its snapshots, and the coding branch. Clean just uses apt-get to install packages, no other installs are allowed.
code is where we are allowed to install things that do not come pre-packaged.
now a new release is made of a linux flavour, so we want to try it. we create a new subvolume to contain this possibly throwaway setup.
btrfs subvol create experiments/ubuntu1210 btrfs subvol list #to obtain the id of the subvolume just created, and now we switch the default subvol to be this btrfs subvol setdefault <id> /
at this point we have disingaged our old system.
reboot with the new cd/dvd and when it comes to partitioning, choose manual configuration, and select the btrfs partition, and make sure you dont tick the format checkbox. let it install as usual.
when its finnished, it will reboot into the new system, and we can do any needed testing.
to reboot into our working setup or another experiment, we need to mount the disk with the subvolid=0, then find the id of the experiment we wish to switch to, and set it as default, then reboot.
We may end up with a non-booting system, due to grub not finding the expected kernel versions. If this happens, we just boot using a live/recovery disk, and regenerate grubs configuration as described here.