Skip to content

Instantly share code, notes, and snippets.

@mamiu
Last active October 11, 2021 09:54
Show Gist options
  • Select an option

  • Save mamiu/a62086858a78441895d0953b17617e2b to your computer and use it in GitHub Desktop.

Select an option

Save mamiu/a62086858a78441895d0953b17617e2b to your computer and use it in GitHub Desktop.
Create bootable USB stick from an ISO image on macOS

Create bootable USB stick from an ISO file on an Apple macOS

  1. Download the desired ISO file
  2. Open a terminal application (like the Apple Terminal or iTerm)
  3. Convert the .iso image to a .dmg file (UDIF image) using the convert option of hdiutil:
hdiutil convert -format UDRW -o /path/to/target /path/to/source.iso

hdiutil will put the .dmg file extension to the output file automatically.

  1. Get the current list of devices
diskutil list
  1. Insert your flash media
  2. Run the command from step 4 again to determine the device node assigned to your flash media (e.g. /dev/disk2)
diskutil list
  1. Unmount that disk

Note: In the next commands you have to replace N with the disk number you've determined in the last command (in the previous example, N would be 2).

diskutil unmountDisk /dev/diskN
  1. Format the disk
diskutil eraseDisk MS-DOS "NAME" GPT /dev/diskN
  1. Unmount the disk again
diskutil unmountDisk /dev/diskN
  1. Burn the .dmg image to the flask disk. Replace /path/to/converted-iso.dmg with the path where the converted ISO image file is located (e.g. ~/Downloads/ubuntu.dmg).
sudo dd if=/path/to/converted-iso.dmg of=/dev/rdiskN bs=1m status=progress

Note: If you see the error dd: Invalid number '1m' you are using GNU dd. Use the same command but replace bs=1m with bs=1M.

Note: Using /dev/rdisk instead of /dev/disk may be faster.

  1. Eject the flash disk remove your flash media when the command completes
diskutil eject /dev/diskN
  1. Now the USB stick is ready. You can boot any device from it by plugging it in, start the device, change the boot order in the BIOS or open the boot device menu and select the USB stick.
@mamiu
Copy link
Copy Markdown
Author

mamiu commented Oct 1, 2021

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