Skip to content

Instantly share code, notes, and snippets.

@hypevhs
Last active February 3, 2022 17:36
Show Gist options
  • Save hypevhs/2a6aae780f5e15032e623c82e7f5b354 to your computer and use it in GitHub Desktop.
Save hypevhs/2a6aae780f5e15032e623c82e7f5b354 to your computer and use it in GitHub Desktop.
estimate space actually used by snapshots of a dataset
#!/usr/bin/env bash
# vim:set et sw=2 ts=2:
# estimate space actually used by snapshots of a dataset
# original by https://www.reddit.com/r/zfs/comments/bzo817/running_out_of_space_easy_way_to_visualize/er0ccbe/
# edits by me
# NO WARRANTY
set -euxo pipefail
here="$(realpath "$1")"
{ echo -e "NAME\tRECLAIM";
for snapshot in $(zfs list -Hpr "$here" -t snapshot -o name -s creation -d 1); do
echo -ne "$snapshot\t"
zfs destroy -nv "${snapshot/@/@%}" | sed -nre "s/would reclaim (.+)/\1/p"
done } | column -t
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment