CDROM -> ISO
ISOs are frequently used as a means of transporting Linux distributions. We're all fairly familiar with mounting ISOs in loopback mode, and with burning them, but how do we get an ISO file when we only have the burned CD?
One would expect that we would handle this in the same way that we do a floppy, something like:
# dd if=/dev/cdrom of=/tmp/aniso.iso bs=1kUnfortunately, this will result in a few problems. When dd reaches the end of the ISO, it begins to read the part of the CD overburned as the laser is turned off. This typically takes a long time as there are errors while reading this non-data region. Also, this process results in a larger ISO than the original, and an MD5 sum that will not match. Certainly not ideal.
To avoid this, we do the following:
# mount /dev/cdrom /mnt/cdrom # dfBy mounting the CD, we can get the true block count of the ISO image. Make a note of the "1K-blocks" number for the CD.
# umount # dd if=/dev/cdrom of=/tmp/aniso.iso bs=1k count=[insert 1k block count here]By specifying the exact size of the image, we prevent trying to read the overburned sectors and end up with an exact ISO image, that is the same size and has the same MD5 sum as the original.