0

How can I clone a CD or DVD to an ISO or DMG, using just the CLI, so that I can attach it to a VirtualBox VM.

I often clone CDs or DVDs using the following commands:

diskname=`df -kh /Volumes/* | grep -o Volumes.* | cut -d"/" -f2`
diskname=`echo $diskname | sed s/\ //g` # remove spaces
device=`df -kh /Volumes/* | grep Volumes | cut -d" " -f1`

sudo umount $device
dd if=$device of=~/Desktop/$diskname.iso bs=2048
hdiutil eject $device

The result is a .ISO on my desktop that is, as far as I can tell, a bit clone of the CD or DVD.

However, when I boot a VirtualBox Windows XP VM and attach the ISO, Windows says it cannot read it.

3

You can use hdiutil to create the disk image, then convert to a hybrid format:

hdiutil create -srcdevice $device $diskname
hdiutil makehybrid -o $diskname.iso -joliet -iso $diskname.dmg

NOTE: this method does not require unmounting the device first.

1
  • That was it. I forgot Windows needs joliet. Thanks.
    – user588
    Mar 1 '11 at 9:07

You must log in to answer this question.