Ubuntu – Is it safe to delete apt-snapshot-*

btrfs

I think I did a mistake when I decided to use Btrfs. I am not using any of its features, but now have troubles with not enough space. I did

sudo btrfs balance start / -v

as suggested in some sources, but still have little space available:

$ sudo btrfs fi df /    
Data, single: total=102.00GiB, used=99.55GiB
System, single: total=32.00MiB, used=16.00KiB
Metadata, single: total=2.00GiB, used=762.44MiB
unknown, single: total=256.00MiB, used=0.00

A source suggests to remove snapshots. I found one candidate:

$ sudo btrfs subvolume list /
ID 257 gen 390597 top level 5 path @
ID 258 gen 390597 top level 5 path @home
ID 317 gen 390480 top level 5 path @apt-snapshot-release-upgrade-utopic-2014-10-23_20:38:40

Is it safe to delete @apt-snapshot-release-upgrade-utopic-* snapshot?

Note: I am using eCryptFS (not sure if this matters in this case).

Best Answer

I've seen a lot of tutorials on how to roll back to one of these snapshots however, on newer versions of ubuntu (tested on 15.04), you nolonger need to mount the filesystem to roll back to a snapshot created through apt-btrfs-snapshot.

Again, run these commands from a running system, not a mounted partition as you normally would when managing btrfs snapshots.

Just run:

sudo apt-btrfs-snapshot list

to list the available snapshots and then run the following to revert to an older snapshot:

sudo apt-btrfs-snapshot set-default @<name-of-snapshot>

For this case, you may want to set the default to the existing snapshot.

Reboot for the changes to take effect.

Also, deleting snapshots is now much more reliable and simple. Again, to list snapshots, run:

sudo apt-btrfs-snapshot list

Then, to delete a snapshot, run:

sudo apt-btrfs-snapshot delete @<name-of-snapshot>

To list by date older than two days, for example, run:

sudo apt-btrfs-snapshot list-older-than 2d

To delete all snapshots older than two days, for example, run:

sudo apt-btrfs-snapshot delete-older-than 2d

The cool thing is that your old default will not be deleted so you can still roll back to that one if you have one set.

Deleting snapshots should take effect immediately.


If you get a "no space on device" error after you boot, you can attach a blank USB pendrive or external drive and use the command line to mount the drive at /tmp.

After mounting the drive at /tmp you should have enough available space to run:

sudo apt-btrfs-snapshot delete-older-than 
Related Question