DEV Community

Cover image for How to create a bootable USB Device on MacOS
Ethan
Ethan

Posted on

How to create a bootable USB Device on MacOS

Introduction

Hello! Recently I had to create a bootable Arch Linux usb drive to fix an issue with my machine running Arch. However the only other PC I had access to was a Mac, so I'll show how to create a bootable external USB drive using only the command line.

Hopefully it helps and I'm sure it will help me when I brick my Arch installation again. ๐Ÿ˜…


Converting the ISO file to UDRW Format

First we need to convert the format of the ISO file to UDRW format so that the image can be written to the external USB device. This can be done via the following command:
Change the source_file to the name of the ISO image.

hdiutil convert -format UDRW -o output_file.img source_file.iso
Enter fullscreen mode Exit fullscreen mode

Formatting the external USB device

Next we need to format the external USB device, but first we need to get the device name.

diskutil list
Enter fullscreen mode Exit fullscreen mode

This will list all the connected devices, make a note of the external device. (in my case /dev/disk4)

Next we need to format the device, this can be done via the following command:
Make sure to replace dev/disk4, you don't want to accidentely format an unrelated disk.

diskUtil partitionDisk /dev/disk4 1 "Free Space" "unused" "100%"
Enter fullscreen mode Exit fullscreen mode

The above command creates 1 partition using 100% of the available space.


Copying the Image file to USB

Finally we can copy the UDRW format image to the USB device, this can be done via the following command: (This command needs root permission)

sudo dd if=output_file.img.dmg of=/dev/disk4 bs=1m
Enter fullscreen mode Exit fullscreen mode

This command has no progress but it should finish after a while.

Finally to be safe we eject the usb device.

diskutil eject /dev/disk4
Enter fullscreen mode Exit fullscreen mode

Done! The USB device should now be bootable! ๐Ÿ˜ƒ


Like me work? I post about a variety of topics, if you would like to see more please like and follow me.
Also I love coffee.

โ€œBuy Me A Coffeeโ€

Top comments (0)