Created
April 4, 2024 08:39
-
-
Save muhamadazmy/25ac8f9af487e791689c531130b40be8 to your computer and use it in GitHub Desktop.
Script to print size and available space on a subvol quota
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# this script is called as `volstat.sh <path/to/subvol>` | |
set -e | |
vol=$1 | |
id=$(btrfs subvol show $vol | grep 'Subvolume ID:'| cut -f 4) | |
output=$(btrfs qgroup show --raw -r $vol| grep "^0/$id") | |
size=$(echo $output | cut -d ' ' -f 4) | |
used=$(echo $output | cut -d ' ' -f 3) | |
# this should output `<size> <available>` space on that subvolume in bytes | |
echo $size $(( $size - $used )) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment