Copy an iso Image to an USB drive
 
In OS X it is possible to use disk utility (GUI) to load an image file onto a physical drive, e.g. a USB flash drive. But this process often goes faulty (at least on my setup). Here is an alternative way of doing this using a terminal in OS X.

Write iso image to USB flash drive

It is assumed that the file source.iso is used and that the USB flash drive has the identifier /dev/disk4.
If you need to create a drive bootable on a regular PC, read the second instruction on the bottom, otherwise continue here (e.g. for a drive bootable on an Apple computer):
To see a list of all installed drives:
diskutil list
which should output something like this:
/dev/disk0
  #:            TYPE NAME          SIZE    IDENTIFIER
  0:   GUID_partition_scheme            *128.0 GB  disk0
  1:            EFI             209.7 MB  disk0s1
  2:         Apple_HFS SYSTEM         118.6 GB  disk0s2
  3:         Apple_Boot Recovery HD       650.0 MB  disk0s3
  4:     Apple_CoreStorage             8.5 GB   disk0s4
  5:         Apple_Boot Boot OS X        134.2 MB  disk0s5
/dev/disk1
  #:            TYPE NAME          SIZE    IDENTIFIER
  0:   GUID_partition_scheme            *250.1 GB  disk1
  1:            EFI             209.7 MB  disk1s1
  2:         Apple_HFS STORAGE         95.2 GB  disk1s2
  3:         Apple_Boot Recovery HD       650.0 MB  disk1s3
  4:    Microsoft Basic Data BOOTCAMP        154.0 GB  disk1s4
/dev/disk2
  #:            TYPE NAME          SIZE    IDENTIFIER
  0:         Apple_HFS DATA          *8.1 GB   disk2
/dev/disk3
  #:            TYPE NAME          SIZE    IDENTIFIER
  0:   FDisk_partition_scheme            *1.0 TB   disk3
  1:         Apple_HFS MACDATA2        371.1 GB  disk3s1
  2:         Apple_HFS MACDATA1        629.1 GB  disk3s2
/dev/disk4
  #:            TYPE NAME          SIZE    IDENTIFIER
  0:   FDisk_partition_scheme            *1.0 GB   disk4
  1:         DOS_FAT_32 UNTITLED        1.0 GB   disk4s1

As you see I currently have quite a few drives attached of which /dev/disk4 is the USB flash drive I want the image file written on.

First let's convert the source.iso file to an OS X format:
hdiutil convert -format UDRW -o converted.img source.iso

Now we've got converted.img.dmg. Next we eject the USB flash drive:
diskutil unmountDisk /dev/disk4

And final step: Let's write the image onto the flash drive:
sudo dd if=converted.img.dmg of=/dev/rdisk4
(note that now we use /dev/rdisk4 instead of /dev/disk4!)
(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)
(If you see the error dd: /dev/diskN: Resource busy, make sure the disk is not in use. Start the 'Disk Utility.app' and unmount (don't eject) the drive)

Alternatively, you might want to look at unetbootin which is a cross-platform opensource tool that allows to do these steps for various linux distributions (also allows downloading of the distribution).
sourceforge.net/projects/unetbootin/


Create a PC (regular windows PC) bootable USB flash drive from an image

This task requires the creation of a MBR on the drive because regular PCs with a BIOS will check the MBR for a partition with the boot flag.
First create a MBR formatted USB stick with Disk Utility or in terminal:
diskutil umountDisk /dev/disk4
Create new MBR oand partition table on the drive:
sudo fdisk -a dos -c 1024 -h 255 -s 63 -b 512 -i /dev/disk4
diskutil umountDisk /dev/disk4
(The option "-b 512" here is important, as it sets the sector size to 512 bytes per sector which is required for the drive to be bootable.)

Create boot flag:
sudo fdisk -e /dev/disk4
flag 1
quit

This leaves a DOS-type partition. To make it Unix-type, issue:
sudo fdisk -e /dev/disk4
edit 1
a9
[enter]
[enter]
[enter]
quit


Now write the image on the drive (almost same steps as above, first convert the iso image to a dmg file. But here we're using the partition we've just created):
diskutil umountDisk /dev/disk4
sudo dd if=converted.img.dmg of=/dev/disk4s1


Further information:
- http://www.ubuntu.com/download/desktop/create-a-usb-stick-on-mac-osx
- http://qwiek.wordpress.com/2009/09/27/how-to-create-a-bootable-usb-flash-drive-under-mac-os-x-in-the-special-case-of-a-netbsd-installation-disc/
 
admin / Dec 09, 2012
   
 
 
Login: 
Pass: 
 
 
     
     
2004 - 2022 / lookass.ch
makememad@lookass.ch