Thinking ZFS had my back, yesterday I started messing with Gnome, Compiz, and dconf editor. After several hours, Gnome sure looked good with all sorts of addins, but after a reboot, my (complex, 3 monitor) setup went berserk, with Wayland very unhappy. So I figured I'd just go back to my Grub snapshot history to early that evening before the tinkering started (cos apt had made a few snapshots then).
Select older root snapshot (system and user), Reboot, seems okay. But then.... sudo apt update && sudo apt upgrade .... whole system gets confused. Starts messing with kernels and graphic driver updates. Apt was very unhappy. Very strange. And smashes the whole display driver setup, to the extent I couldn't recover the system and spent a half day today reinstalling 20.04. This time with ext 4 (though I was quite happy with ZFS up to now).
So I'm wondering. Are ZFS snapshots really recommended for "rolling back" the OS on a root partition? Or is it really good only for a data drive or a home directory. Does apt get confused in some way ie can this kind of rollback create unrecoverably inconsistent states?
ZFS has your back. BUT the current implementation in Ubuntu seems buggy. In particular the rollback menu in Grub that you have been using. What it currently does is it clones the snapshots under a new name and then mounts them on top of the old ones. This creates several issues after such a "restore" of making the file system inconsistent. I really hope they fix that, as it is clearly broken.
For now I recommend using
zfs restore
instead ofclone
and doing it directly. This rolls back the filesystem completely and in a clean way. The only downside is that you loose all the data stored in the meantime permanently, so all that is still needed needs to be backed up before. The good news about this is that it also frees up all the space, which the ubuntu method does not, so you can restore as needed without having to pay for it every time.For that the first step is to boot from a Ubuntu Live CD.
Then you need to import your zpool:
List all snapshots and find out which one you want to restore.
Now we make a list of all datasets that need to be restored
Inspect this list carefully, as any data will be deleted that was changed after the snapshot.
WARNING: ZFS can only rollback to a snapshot if it is the most recent one. So all intermediate snapshots and bookmarks must be destroyed as well as any clones of those snapshots. We do this by specifying the -rR option. I recommend you have a look at the documentation.
Now we need to execute rollback for each of these snapshots. This gets rid of all the data written in the meantime.
At this point you can reboot the system and you have a rolled back system without any clutter.
Now that you know how it works, I also want you aware that you can create snapshots with easy identifiable name at any time. For example before attempting some risky operations. That way you can take full advantage of this method. To do that just do at any time:
Note The rollback can technically also be done on a live system. However that might not be a good idea, depending on what was changed.