Skip to content

Instantly share code, notes, and snippets.

@eugenetriguba
Last active June 16, 2023 11:24
Show Gist options
  • Save eugenetriguba/4b092271c7bc322042c00d74b941b032 to your computer and use it in GitHub Desktop.
Save eugenetriguba/4b092271c7bc322042c00d74b941b032 to your computer and use it in GitHub Desktop.
A tutorial on how to create a bootable USB stick using Bash on Mac OS X

How to Create a Bootable USB stick on Mac OS X

Convert the ISO to UDRW format. Note: the names destination and source are used for clarification. The name of the destination does not matter.

$ hdiutil convert -format UDRW -o destination.img source.iso

Reading CCCOMA_X64FRE_EN-US_DV9          (Apple_UDF : 0)…
...............................................................................
Elapsed Time: 11.058s
Speed: 426.0Mbytes/sec
Savings: 0.0%
created: /Users/eugene/Downloads/destination.img.dmg

Find the USB.

$ diskutil list

/dev/disk0 (internal):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                         500.3 GB   disk0
   1:                        EFI EFI                     314.6 MB   disk0s1
   2:                 Apple_APFS Container disk1         500.0 GB   disk0s2

/dev/disk1 (synthesized):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      APFS Container Scheme -                      +500.0 GB   disk1
                                 Physical Store disk0s2
   1:                APFS Volume Mac OSX                 106.3 GB   disk1s1
   2:                APFS Volume Preboot                 87.3 MB    disk1s2
   3:                APFS Volume Recovery                1.6 GB     disk1s3
   4:                APFS Volume VM                      2.1 GB     disk1s4

/dev/disk2 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *15.7 GB    disk2
   1:                       0x17                         346.0 MB   disk2s1

Partition the disk to 1 partition without any formatting. WARNING: This deletes all contents on the USB.

$ diskutil partitionDisk /dev/disk2 1 "Free Space" "unused" "100%"

Started partitioning on disk2
Unmounting disk
Creating the partition map
Waiting for partitions to activate
Finished partitioning on disk2
/dev/disk2 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *15.7 GB    disk2
   1:                        EFI EFI                     209.7 MB   disk2s1

Copy the image to the USB stick. Note: This command does not produce any output. You can press CTRL+T during the process for a progress update. It will take a while for a large file (~35 minutes for a 5gb Windows ISO)

$ sudo dd if=destination.img.dmg of=/dev/disk2 bs=1m
Password:
330+0 records in
330+0 records out
346030080 bytes transferred in 133.780774 secs (2586546 bytes/sec)

Finally, eject the USB.

$ diskutil eject /dev/disk2

Now you're good to go.

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