Skip to content

Instantly share code, notes, and snippets.

@hamano
Last active November 8, 2024 23:58
Show Gist options
  • Save hamano/4484915d82e99bc3da57f2e29cc20702 to your computer and use it in GitHub Desktop.
Save hamano/4484915d82e99bc3da57f2e29cc20702 to your computer and use it in GitHub Desktop.
dfree-btrfs.sh
#!/bin/bash
declare -a res=($(sudo /usr/bin/btrfs qgroup show --raw -rF . | tail -1))
if [[ ${res[3]} == "none" ]]; then
declare -a res=($(df /fs | tail -1))
MAX=${res[1]}
FREE=${res[3]}
else
MAX=$((res[3] / 1024))
USE=$((res[2] / 1024))
FREE=$((MAX - USE))
fi
echo ${MAX} ${FREE}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment