Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lengerfulluse/5ee560f87b891815d55797f8c52bcc60 to your computer and use it in GitHub Desktop.
Save lengerfulluse/5ee560f87b891815d55797f8c52bcc60 to your computer and use it in GitHub Desktop.
#!/bin/bash
# where to store the sparse-image
WORKSPACE=~/UnixVolume.dmg.sparseimage
create() {
hdiutil create -verbose -type SPARSE -fs 'Case-sensitive Journaled HFS+' -size 50g -volname UnixVolume ${WORKSPACE}
}
detach() {
m=$(hdiutil info | grep "/Volumes/AmazonVolume" | cut -f1)
if [ ! -z "$m" ]; then
hdiutil detach $m
fi
}
attach() {
hdiutil attach ${WORKSPACE}
}
compact() {
detach
hdiutil compact ${WORKSPACE} -batteryallowed
attach
}
case "$1" in
create) create;;
attach) attach;;
detach) detach;;
compact) compact;;
*) ;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment