Current versions of Ubuntu and Kubuntu install a package named apt-btrfs-snapshot by default. This package creates a btrfs snapshot each time packages are installed or removed. These snapshots can take up a lot of space if not cleaned up regularly.
How much space is left on my btrfs file system?
First a quick reminder. Traditional Linux tools like
report the used / free disk space on btrfs file systems inaccurately.
Better use the following commands to get an accurate overview about
your current disk space situation:
user@laptop:~/tmp$ sudo btrfs filesystem usage / Overall: Device size: 156.57GiB Device allocated: 126.16GiB Device unallocated: 30.41GiB Device missing: 0.00B Used: 37.35GiB Free (estimated): 113.61GiB (min: 113.61GiB) Data ratio: 1.00 Metadata ratio: 1.00 Global reserve: 93.14MiB (used: 0.00B) Multiple profiles: no Data,single: Size:119.65GiB, Used:36.44GiB (30.46%) /dev/sdb6 57.65GiB /dev/sda5 62.00GiB Metadata,single: Size:6.51GiB, Used:926.61MiB (13.90%) /dev/sdb6 2.51GiB /dev/sda5 4.00GiB System,single: Size:4.00MiB, Used:48.00KiB (1.17%) /dev/sdb6 4.00MiB Unallocated: /dev/sdb6 3.63GiB /dev/sda5 26.77GiB user@laptop:~/tmp$
If you just want to see which partitions belong to a btrfs file system the following command comes in handy:
user@laptop:~/tmp$ sudo btrfs dev usage / /dev/sdb6, ID: 1 Device size: 63.79GiB Device slack: 0.00B Data,single: 57.65GiB Metadata,single: 2.51GiB System,single: 4.00MiB Unallocated: 3.63GiB /dev/sda5, ID: 2 Device size: 92.77GiB Device slack: 0.00B Data,single: 62.00GiB Metadata,single: 4.00GiB Unallocated: 26.77GiB user@laptop:~/tmp$
Removing btrfs snapshots (created by apt-btrfs-snapshot)
To list all the snapshots in a btrfs file system the following
command can be used:
$ sudo btrfs subvolume list -s /.
-s only snapshot subvolumes in the filesystem will be listed.
A snapshot is also a subvolume, but with a given initial content of the original subvolume.
If you want to read more about btrfs snapshots and subvolumes
But instead of messing around with the raw snapshots / subvolumes
I recommend using the
apt-btrfs-snapshot tool itself instead.
$ sudo apt-btrfs-snapshot list to list all btrfs snapshots created by
apt-btrfs-snapshot. To remove all the snapshots you can use the following
$ sudo apt-btrfs-snapshot delete-older-than 0d.
Check your file system
After the snapshots have been removed you might want to run a file system check:
# Start a file system check. $ sudo btrfs scrub start / # Check the status of a running file system check. $ sudo btrfs scrub status /
If you want to get to know more about some of the btrfs terms you might take a look at the glossary over at the btrfs wiki. A scrub is defined as follows:
An online filesystem checking tool. Reads all the data and metadata on the filesystem, and uses checksums and the duplicate copies from RAID storage to identify and repair any corrupt data.
A note about Netcup
Netcup offers inexpensive, yet powerfull web hosting packages, KVM-based root servers or dedicated servers for example. Using a code generated by my Netcup coupon code generator you can even save more money (5$ on your first purchase, 30% off any KVM-based root server, ...).