How to display quota limit on btrfs subvolume?
I cannot determine how to get the quota limit which is currently set on a btrfs subvolume. The btrfs wiki on quota doesn't seem to show this.
This is what I think I know:
- set a quota:
btrfs qgroup limit 21G /path
- check used space:
btrfs qgroup show /path
But how to check the already set limit?
Solution 1:
Use options -r
and -e
:
btrfs qgroup show -pcre /path
Solution 2:
I created a simple script that will show the quota limit for each sub-volume in the specified path and the used space too. The syntax is pretty simple:
./quota.sh path
To print the used space for all sub-volumes use the -a flag:
./quota.sh path -a
Don't forget to add execution permissions to the script.
Script:
#! /bin/sh
volumes=$(btrfs subvolume list $1 | cut -d " " -f 9 )
snapshots=$(btrfs subvolume list -s $1 | cut -d " " -f 14 )
regsnap=$(echo $snapshots | sed 's/ /,/g')
normalv=$(echo $volumes | sed "s/\($regsnap\)//g" )
if [ ! -z "$snapshots" ] ; then
echo SNAPSHOTS
for p in $snapshots; do
quot=$(btrfs qgroup show -rF $1/$p | tail -1)
if [ -z $2 ]; then
(echo $quot | grep -q none) || echo $p $quot
else
[ "$2" == "-a" ] && echo $p $quot
fi
done
fi
if [ ! -z "$normalv" ] ; then
echo SUBVOLUMES
for p in $normalv; do
quot=$(btrfs qgroup show -rF $1/$p | tail -1)
if [ -z $2 ]; then
(echo $quot | grep -q none) || echo $p $quot
else
[ "$2" == "-a" ] && echo $p $quot
fi
done
fi
It will print first the traditional sub-volumes and below the snapshots volumes. Sample output:
SNAPSHOTS
apple 0/258 1.32MiB 16.00KiB 20.00MiB
SUBVOLUMES
citrus/orange 0/256 1.32MiB 16.00KiB 20.00MiB