4

I want to free up some space in my btrfs filesystem by deleting some snapshots. But I cannot work out which ones would be effective to delete. This question's answer explains how to show the amount of data held exclusively in one btrfs snapshot. But that doesn't help if your tentatively-deletable data was held for longer than the interval between snapshots. For example, if I create a file on Monday, do daily snapshots, and then delete it on Wednesday, that file will be used by two snapshots, and hence not exclusive to either.

What I think I'm looking for is a way to enumerate groups of snapshots that hold data held by no other snapshots.

1 Answer 1

0

Yes, you can do this with quota groups.

First recall that every snapshot is a subvolume and has a numeric subvolume id. You can see them all with btrfs subvol list /myfs.

Then if you want to see how much space is used by blocks contained only in subvolumes 10, 20, 30 (collectively), you can do

btrfs quota enable /myfs                            # if not enabled already
btrfs qgroup create 1/12345 /myfs                   # any number not already in use
btrfs qgroup assign --no-rescan 0/10 1/12345 /myfs
btrfs qgroup assign --no-rescan 0/20 1/12345 /myfs
btrfs qgroup assign --no-rescan 0/30 1/12345 /myfs
btrfs quota rescan -w /myfs                         # may take a long time
btrfs qgroup show /myfs

You will see a line like

1/12345    107.07GiB     38.93GiB

This means that:

  • Subvolumes 10, 20, 30 collectively include 107 GiB of total data, counting data that either is or is not also contained in other subvolumes (i.e. other snapshots or the "active" filesystem)

  • They contain 38.93 GiB of data that is not part of any other subvolumes. If you deleted subvolumes 10, 20, and 30, then 38.93 GiB of space would be freed.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .