The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My work

  • My badges

  • Twitter Updates

  • My Flickr Stream

    20140508-Delphi-2007--Project-Options--Cannot-Edit-Application-Title-HelpFile-Icon-Theming

    20140430-Fiddler-Filter-Actions-Button-Run-Filterset-now

    20140424-Windows-7-free-disk-space

    More Photos
  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,776 other followers

A bash script to btrfs snapshot details like disk sizes (requires btrfs quota to be enabled)

Posted by jpluimers on 2016/09/06

One thing I’ve not figured out yet is this: How does enabling btrfs quotas impact the system? – Unix & Linux Stack Exchange

My gut feeling says it’s not much. But if someone knows: please chime in.

Anyway: btrfs quota support helps you to see how big snapshots (and other subvolumes) are.

Enabling and disabling is easy (the slash is the path from where to enable quota):

btrfs quota enable /

btrfs quota disable /

The bad thing is that there is no command that gives just the quota status. You have to revert to btrfs qgroup show /

This will show you quota groups when quota are enabled:

qgroupid         rfer         excl 
--------         ----         ---- 
0/5          16.00KiB     16.00KiB 

or errors when quota are disabled:

ERROR: can't perform the search - No such file or directory
ERROR: can't list qgroups: No such file or directory

You might also want to check the syslogs as there was a [PATCH 1/2] btrfs: syslog when quota is enabled.

The btrfs qgroup output is the base for agronick/btrfs-size: A script that will print out a list of BTRFS subvolumes along with their size in megabytes and their name.

It actually shows it in human readable form (kilo/mega/giga/… bytes) and is documented at Get the size of your BTRFS Snapshots | PoisonPacket. It gives me a nice overview that corresponds to the snapper list output (see below).

The script has two drawbacks:

./btrfs-size/btrfs-size.sh: line 55: can't + 0: syntax error: invalid arithmetic operator (error token is "'t + 0")

  • it can take a while for btrfs quota enable / to actually deliver the quota for all the qgroupid values snapper uses. Until that time, the columns ID/Total/Exclusive Data are empty.
  • it won’t warn you if the quota data is out of data; to check that, run the below script

# btrfs qgroup show / > /dev/null
WARNING: Qgroup data inconsistent, rescan recommended

In that case, run btrfs quota rescan / and wait for it to complete by running this command until the warning is gone:

# btrfs qgroup show / > /dev/null
WARNING: Rescan is running, qgroup data may be incorrect

If the warning reverts to WARNING: Qgroup data inconsistent, rescan recommended then you might see the effects from this bug and should not worry about it: Bug 933428 – btrfs qgroup – allways shows WARNING: Qgroup data inconsistent.

For more btrfs quota background information, see: UseCases – btrfs Wiki.

–jeroen

One Response to “A bash script to btrfs snapshot details like disk sizes (requires btrfs quota to be enabled)”

  1. […] can combine this with A bash script to btrfs snapshot details like disk sizes (requires btrfs quota to be enabled) to find out which snapper snapshots take up a truckload of space and might be safely […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: