April 25, 2016

Baking ISOs in OSX

Ever needed a freshly baked ISO to be used with your virtualbox? I needed one, for some playing around stuff. There's a bunch of answers on superuser, but I found that the suggested command using hdiutils didn't allow the image to be bootable in a virtualbox.

$ hdiutil makehybrid -iso -joliet -o Documents/tools/dest.iso /Volumes/source

So, all things equal, dd should be your best bet. Since dd is both fast and efficient. To use dd you'll have to check where your (dv|c)d is mounted.

$ diskutil list
/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *500.1 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:          Apple_CoreStorage Macintosh HD            499.2 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
/dev/disk1 (internal, virtual):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                  Apple_HFS Macintosh HD           +498.9 GB   disk1
                                 Logical Volume on disk0s2
                                 71E61617-FD0B-4FFA-A432-4FE2737C217D
                                 Unlocked Encrypted
/dev/disk2 (disk image):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                            firefox_cache          +596.7 MB   disk2
/dev/disk4 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:        CD_partition_scheme                        *861.7 MB   disk4
   1:              CD_ROM_Mode_1 Hacking LiveCD          750.3 MB   disk4s0


Looking at the CD entry, you'll want to create a binary copy of the disk4s0 image since this is the packed iso file. The other disk4 is the mounted and unpacked file system.

Before creating a copy you'll need to unmount the disk, so you can use it.

$ sudo diskutil umount /dev/disk4s0

Next, generate an ISO image with dd:

$ sudo dd if=/dev/disk4s0 of=my.iso bs=2048 conv=sync,notrunc

Sudo is needed to access the 'real' disk iso. Once the disk image has been generated, check if it can boot with virtualbox.

If you wish to create a bootable CD using dd, just reverse the command, by using the iso ad if and the drive as of, check this guide if you're in doubt. Remember to chown and chmod the image if you wish others that root can use it.

No comments: