Monday, April 18, 2016

Write ISO to USB drive in OS X

OS X systems natively support writing disk images to USB drives, however they often need to be converted to a more Mac friendly format first. Start by converting the image to DMG format. In my case, I'm converting a DBAN ISO, but substitute these values with the file you want to convert.
$ hdiutil convert ~/dban-2.3.0_i586.iso -format UDRW -o ~/dban-2.3.0_i586.dmg
Reading DBAN                             (Apple_ISO : 0)…
.............................................................................
Elapsed Time:  1.172s
Speed: 13.6Mbytes/sec
Savings: 0.0%
created: /Users/myaccount/src/os/dban-2.3.0_i586.dmg


Next, plug in the USB drive and list all the available disks.
$ diskutil list
/dev/disk0
   #:                       TYPE NAME                  SIZE       IDENTIFIER
   0:      GUID_partition_scheme                      *250.1 GB   disk0
   1:                        EFI EFI                   209.7 MB   disk0s1
   2:                  Apple_HFS OS X                  249.7 GB   disk0s2
/dev/disk1
   #:                       TYPE NAME                  SIZE       IDENTIFIER
   0:     Apple_partition_scheme                      *17.4 MB    disk1
   1:        Apple_partition_map                       32.3 KB    disk1s1
   2:                  Apple_HFS Flash Player          17.4 MB    disk1s2
/dev/disk2
   #:                       TYPE NAME                  SIZE       IDENTIFIER
   0:     Apple_partition_scheme                      *18.1 MB    disk2
   1:        Apple_partition_map                       32.3 KB    disk2s1
   2:                  Apple_HFS Flash Player          18.1 MB    disk2s2
/dev/disk3
   #:                       TYPE NAME                  SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                      *8.0 GB     disk3
   1:                 DOS_FAT_32 UNTITLED 1            8.0 GB     disk3s1


In my case, my USB drive is /dev/disk3. Now unmount that drive, but leave it plugged into the system.
$ diskutil unmountDisk /dev/disk3
Unmount of all volumes on disk3 was successful


Write the image to disk using the dd command.
$ sudo dd if=dban-2.3.0_i586.dmg of=/dev/disk3 bs=1m
Password:
15+1 records in
15+1 records out
16719872 bytes transferred in 6.551918 secs (2551905 bytes/sec)


Finally, eject the disk.
$ diskutil eject /dev/disk3
Disk /dev/disk3 ejected

No comments:

Post a Comment