Skip to content

Instantly share code, notes, and snippets.

@aasmith
Last active November 1, 2021 03:20
Show Gist options
  • Save aasmith/9224335 to your computer and use it in GitHub Desktop.
Save aasmith/9224335 to your computer and use it in GitHub Desktop.
Writing an image to a USB drive is somewhat convoluted in OS X...
# Insert drive.
# See what drives are available.
diskutil list
# Unmount the target drive.
diskutil unmountDisk /dev/disk1
# OPTIONAL step to convert ISO to usb compatible image (ubuntu ISOs require this)
hdiutil convert -format UDRW -o ~/path/to/target.img ~/path/to/ubuntu.iso
# Write the image using dd(1). Experiment with blocksize (bs).
# Note usage of *r*disk to improve write speed.
# MAKE SURE YOU HAVE THE CORRECT DRIVE
sudo dd of=/dev/rdisk1 if=loonix.iso bs=8m
# Press ^T (Ctrl-T) to see progress while copying.
# Eject disk afterwards.
diskutil eject /dev/disk1
@aasmith
Copy link
Author

aasmith commented Sep 30, 2020

If you are writing an OS image and want to test that it is bootable after writing, try qemu:

sudo qemu-system-x86_64 -m 1024 -hdb /dev/disk2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment