The question is not trivial. BTRFS is COW file system and one object stored on hard disk can be referenced by many files.

I use BTRFS snapshots as a part of a backup solution on my production server. This way I have space-efficient, browsable history of a given subvolume (I use a modification of the SnapBtr).

I have several independent btrfs subvolumes for different purposes and a backup scheme for each one. When the free space is running out, I can get the most unneeded backup snapshot from each backup pool based on the smart logarithmic-time-cost algorithm of SnapBtr.

I need a way to weight the amount of data that will be freed after I remove each backup with age of the old snapshot and importance of its backup pool. I am missing the former information.

I understand that the process of calculation of the free space on the BTRFS is neither trivial nor quick. I need something that would simulate the subvolume's deletion to get the size of the would-be freed space.

Can anyone help me? Should I post this message to the linux-btrfs@vger.kernel.org?


2 Answers 2


As demonstrated here, this is actually fairly simple to do.

First, enable btrfs quotas:

# btrfs quota enable /btrfs_subvolume

And then run:

# btrfs qgroup show /btrfs_subvolume
# btrfs qgroup show -f /btrfs_subvolume

Which in Btrfs v3.18.2 shows you this:

qgroupid        rfer       excl
--------        ----       ----
0/260        1.09GiB    1.09GiB

The 0/260 is the subvolume ID, and the excl is the exclusive data in the subvolume. If you delete the subvolume, that's how much space you'll free up.

Edit: According to this link, this appears to be the official recommended way to do this.


btrfsQuota.py makes the output of btrfs qgroup show more readable, replacing subvol IDs with the names of the subvols, e.g.:

subvol                                      group         total    unshared
test/a                                      0/970        20.05M       0.05M
test/b                                      0/971        20.05M      10.05M
test/c                                      0/972        30.05M      10.05M
test/d                                      0/973        30.05M       0.05M
test/e                                      0/974        30.05M      10.05M
  • 1
    It doesn't work with default btrfs-tools version of Ubuntu 14.04. You need to install a newer one, and then everything is ok Jun 4, 2016 at 7:35
  • @AdamRyczkowski I'm using the Python 3 version of that script now, and it works fine.
    – Geremia
    Aug 3, 2017 at 18:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.