Skip to content

Instantly share code, notes, and snippets.

@pvieito
Created July 4, 2014 15:23
Show Gist options
  • Save pvieito/fa5487d2d8cd3b54ef00 to your computer and use it in GitHub Desktop.
Save pvieito/fa5487d2d8cd3b54ef00 to your computer and use it in GitHub Desktop.
Uses hdiutil to create a raw disk image with .img extension
#!/usr/bin/env bash
if [ "$1" = "-h" -o "$1" = "--help" -o -z "$1" ]; then cat <<EOF
Usage:
`basename $0` <diskimage>
Converts a Disk Image (DMG, ISO) to raw format.
EOF
exit; fi
hdiutil convert -format UDTO $1 -o $1
if [ -f "$1.cdr" ]; then
IMAGE="$(echo $1.cdr | sed -E 's/(\..{0,3})?\.cdr$/.img/')"
mv "$1.cdr" $IMAGE
echo
echo Raw Image: $IMAGE
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment