Skip to content

Instantly share code, notes, and snippets.

@muhamadazmy
Created April 4, 2024 08:39
Show Gist options
  • Save muhamadazmy/25ac8f9af487e791689c531130b40be8 to your computer and use it in GitHub Desktop.
Save muhamadazmy/25ac8f9af487e791689c531130b40be8 to your computer and use it in GitHub Desktop.
Script to print size and available space on a subvol quota
#!/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