Thursday, 29 December 2011

Creating a bootable USB key under Apple Mac OSX

I wanted to install a new (to me) Linux distribution - CentOS - onto my Thinkpad W500, and was looking to avoid finding and using a CD-ROM or DVD.

Having a spare USB thumb-drive kicking about, I was hoping that I could use that instead, and also "burn" the image from my Mac.

I'd already downloaded the CentOS ISO to my Mac Downloads folder, and had previously mounted it.

A quick Google search found me this MacRumours forum thread - how to "burn" an ISO to USB flash drive? - which provided a variety of answers, some positive, some not-so-positive.

Having said that, I scrolled to the very end of the thread, and found this post - Final Solution - from someone called Candlejack, which had the answer.

Basically, it's a bunch of Terminal commands :-) 

$ diskutil list

/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *320.1 GB   disk0
   1:                        EFI                         209.7 MB   disk0s1
   2:                  Apple_HFS Hard Disk               319.2 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
/dev/disk1
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *8.3 GB     disk1
   1:                 DOS_FAT_32 DISK_IMG                8.3 GB     disk1s1
/dev/disk2
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                            CentOS-6.2-x86_6       *731.9 MB   disk2

$  diskutil unmountDisk /dev/disk1

Unmount of all volumes on disk1 was successful

$  dd if=/dev/disk2 of=/dev/disk1 bs=1m

dd: /dev/disk2: Resource busy

$  diskutil unmountDisk /dev/disk2

Unmount of all volumes on disk2 was successful

$ dd if=/dev/disk2 of=/dev/disk1 bs=1m

698+0 records in
698+0 records out
731906048 bytes transferred in 206.409147 secs (3545899 bytes/sec)

Job done.

I was then able to boot the Thinkpad from the USB drive ( via the [F12] function key ) and install CentOS, far far quicker than I could've installed from a CD or DVD.

PS For the record, I've previously blogged about CentOS, with regard to installing IBM HTTP Server on it here.

4 comments:

x5150 said...

I got no boot sector on device when booting from the usb.

Dave Hay said...

@x5150, what OS were you using / booting ? I've only tried it with CentOS but assume that it'd work with most other Linux distros

Dave Hay said...

@x5150 - if it helps, I just saw: -

EDD: Error 0400 reading sector 1419692

when I tried to boot off an 8 GB USB thumb drive that I'd created in the same way. However, I'm guessing that this was a problem with the USB key, as I did the same thing with a different drive, and all was well.

Therefore, try a different drive, and see how you go.

Dave Hay said...

@x5150 - I realised why I was having a problem - the USB key was a 500 MB drive, whereas the ISO is 730 MB.

N00b error :-)