Skip to content

Instantly share code, notes, and snippets.

Last active July 3, 2017 06:41
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save verhovsky/a3c754023aa0215f039597735451497a to your computer and use it in GitHub Desktop.
create bootable usb from .iso file on macOS
# if you want to boot a laptop from a USB drive and you have a file like archlinux-2017.07.01-x86_64.iso
# (and a USB drive plugged in), this is a script to copy the .iso onto the USB drive.
# like UNetbootin but debuggable.
echo "path to .iso?"
read iso_filepath
echo "rm /tmp/linux.dmg"
rm /tmp/linux.dmg 2>/dev/null
echo "converting .iso to .dmg"
echo "hdiutil convert $iso_filepath -format UDRW -o /tmp/linux # adds a .dmg to output"
hdiutil convert $iso_filepath -format UDRW -o /tmp/linux # adds a .dmg to output
if ! [[ $(diskutil list external) ]]; then
echo "your USB drive isn't plugged in. quitting"
diskutil list external
echo "which /dev/diskX is the flash drive that should be overwritten (just the number)?"
read disk_number
rdisk=/dev/rdisk$disk_number # supposedly faster
echo "diskutil unmountDisk $disk"
diskutil unmountDisk $disk
echo "copying .dmg file to the USB drive, this might take a while"
echo "if this errors, try to lowercase 1M to 1m in bs=1M"
echo "sudo dd if=/tmp/linux.dmg of=$rdisk bs=1M"
sudo /bin/dd if=/tmp/linux.dmg of=$rdisk bs=1M
diskutil eject $disk
echo "done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment