Ubuntu: ZFS bpool is full and not running snapshots during apt updates
When running apt to update my system I kept seeing a message saying that bpool had less than 20% space free and that the automatic snapshotting would not run.
What I didn’t realise is that this would apply to the rpool even if it had plenty of free space. They are run together and have to match. Checking the snapshots it seems they had stopped running for several months. Yikes!
You can list the current snapshots in several ways:
[List existing snapshots with their names and creation date.] $ zsysctl show Name: rpool/ROOT/ubuntu_dd5xf4 ZSys: true Last Used: current History: - Name: rpool/ROOT/ubuntu_dd5xf4@autozsys_qfi5pz Created on: 2021-01-12 23:35:01 - Name: rpool/ROOT/ubuntu_dd5xf4@autozsys_1osqbq Created on: 2021-01-12 23:33:22
You can also use the zfs commands for the same purpose.
List existing snapshots with default properties information (name, used, references, mountpoint) $ zfs list -t snapshot You can also list the creation date asking for the creation property. $ zfs list -t snapshot -o name,creation It should list then in creation order, but if not, you can use -s option to sort them. $ zfs list -t snapshot -o name,creation -s creation
Deciding which snapshots to delete will vary. You might want to get rid of the older ones, or maybe the ones that are consuming the most space.
My snapshots were a few months old so there wasn’t much point in keeping them. I deleted all with the following one-liner:
[-H removes headers] [-o name displays the name of the filesystem] [-t snapshot displays only snapshots] # zfs list -H -o name -t snapshot | grep auto | xargs -n1 zfs destroy
I can’t stress how important it is that whatever zfs destroy command you issue, especially if doing several automatic iterations, only applies to the snapshots you want to.
You can delete filesystems, volumes and snapshots with the above command. Deleting snapshots isn’t an issue. Deleting the filesystem is a pretty big one.
Please, ensure that the command lists only snapshots you want to remove before running it. You have been warned.