Is it safe to delete apt-snapshot-*?
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).
Solution 1:
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
Solution 2:
Looks like it is safe. I've seen other attempts to do this and it turned to be not so simple.
First, run the following command to see which partition is your btrfs partition (assuming you only have one btrfs partition):
lsblk -o NAME,FSTYPE | grep btrfs| grep -o sda.
The following uses /dev/sda3
as an example.
Here is how I did it:
# mkdir /mnt/tmp
# mount /dev/sda3 /mnt/tmp
# ls /mnt/tmp
@
@apt-snapshot-release-upgrade-utopic-2014-10-23_20:38:40
@home
Here is the correct partition:
# btrfs subvol delete /mnt/tmp/@apt-snapshot-release-upgrade-utopic-2014-10-23_20:38:40
Transaction commit: none (default)
Delete subvolume '/mnt/tmp/@apt-snapshot-release-upgrade-utopic-2014-10-23_20:38:40'
# btrfs subvol list /
ID 257 gen 397869 top level 5 path @
ID 258 gen 397869 top level 5 path @home
Not much space was freed:
vic-UX32VD# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda3 120729076 117384216 1996232 99% /
A restart helped:
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda3 120729076 109894736 9187296 93% /