Last active
August 29, 2015 14:13
-
-
Save tylerflint/601a88756ab468fc5ce7 to your computer and use it in GitHub Desktop.
SmartOS cleanup crufty zone datasets
This file contains hidden or 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
#!/usr/bin/env bash | |
zfs_uuids=$(zfs list | /usr/xpg4/bin/grep -E -e 'zones/[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}$' | awk '{ print $1 }' | awk -F/ '{ print $2 }') | |
vmadm_uuids=$(vmadm list | tail -n +2 | awk '{ print $1 }') | |
imgadm_uuids=$(ls -1 /var/imgadm/images | sed 's/zones-//' | sed 's/\.json//') | |
symmetric_uuids=$(comm -3 <(echo "$zfs_uuids" | sort -) <(echo "$vmadm_uuids" | sort -)) | |
symmetric_uuids=$(comm -3 <(echo "$symmetric_uuids" | sort -) <(echo "$imgadm_uuids" | sort -)) | |
for uuid in $symmetric_uuids | |
do | |
echo "destroying crufty dataset zones/${uuid}" | |
zfs destroy zones/${uuid} | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment