Last active
August 21, 2020 23:02
-
-
Save hoggren/c7a9ebc2e7d02a8a35ae0adc48261cd6 to your computer and use it in GitHub Desktop.
Bootable usb flash drive for MacOS
This file contains 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
#!/bin/bash | |
# Usage: ./bootable_usb4mac.sh /dev/rdiskX isofile.iso | |
# Writing to /dev/rdiskX requires root privilegies, and rdisk is FASTER | |
# https://superuser.com/questions/631592/why-is-dev-rdisk-about-20-times-faster-than-dev-disk-in-mac-os-x/631601 | |
USBDISK=$1 | |
ISOFILE=$2 | |
TMPFILE="tempoutput" | |
if [ "$(whoami)" != "root" ]; then | |
echo "no root, qutting" | |
exit 0 | |
fi | |
echo "Write image $ISOFILE to $USBDISK, type YES to confirm:" | |
read INPUT | |
if [ "$INPUT" != "YES" ]; then | |
echo "quitting" | |
exit 0 | |
fi | |
diskutil unmountDisk $USBDISK | |
hdiutil convert -format UDRW -o $TMPFILE $ISOFILE | |
dd if=$TMPFILE.dmg of=$USBDISK bs=1m | |
rm $TMPFILE.dmg |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment