Skip to content

Instantly share code, notes, and snippets.

@mwyau
Last active April 11, 2026 08:06
Show Gist options
  • Select an option

  • Save mwyau/dc18410b567a7479e44853d6fa6c654b to your computer and use it in GitHub Desktop.

Select an option

Save mwyau/dc18410b567a7479e44853d6fa6c654b to your computer and use it in GitHub Desktop.
dfree-zfs for Samba ZFS pools
#!/bin/bash
POOLS=$(df -PT | awk '$2~"zfs" && $7~path {print $1}' path="^$(realpath ${1:-/mnt})" | awk -F'/' '{print $1}' | sort | uniq)
USED=0
AVAIL=0
for pool in ${POOLS[@]}; do
(( USED += $(zfs get -o value -Hp used $pool) ))
(( AVAIL += $(zfs get -o value -Hp available $pool) ))
done
TOTAL=$(( USED + AVAIL ))
echo $TOTAL $AVAIL 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment