Ramblings of an aging IT geek
← Ramblings of an aging IT geek
linux

when a snapshot turned a ruined saturday into a five-minute rollback

A botched package upgrade left a laptop unbootable on a Saturday morning, and a pre-upgrade btrfs snapshot turned what could have been a reinstall into a quick rollback from a recovery shell.

A terminal showing btrfs subvolume list output

I broke my laptop on Saturday morning and had it back by the time the tea was ready, which is the entire point of this post. A routine upgrade pulled in a graphics stack change that did not agree with my hardware, and the next boot dropped me into a black screen with a cursor and nothing else. The old me would have spent the day with a USB stick and a fresh install. Instead I rolled back a snapshot.

I run snapper against the root subvolume so that every zypper/pacman transaction takes a snapshot before and after. So there was already a clean pre-upgrade snapshot sitting there, taken automatically two minutes before I broke everything. From a recovery shell it was a case of finding the good snapshot and making it the default boot target.

btrfs subvolume list /
snapper list
snapper rollback 142

Reboot, and I was back on the working system as if the upgrade had never happened. No data lost, the snapshots are copy-on-write so they cost almost nothing and take an instant.

The lesson is not that btrfs is flawless, it has its sharp edges and I have cursed at it before. The lesson is that automatic pre-upgrade snapshots turn "my system is broken" from a catastrophe into an inconvenience. The safety net was already there before I needed it, which is the only kind of safety net worth having.