9.3.7 Make an image file of a CD
Some CD-Rs and commercial CDs have junk sectors at the end that make copying by
dd
impossible (the Windows 98 CD is one of them). The
cdrecord
package comes with the readcd
command. Use
this to copy any CD contents to an image file. If it is a data disk, mount it
and run df
to see its actual size. Divide the number shown in
blocks (1 block = 1024 bytes) by 2 to get the number of actual CD sectors (1
sector = 2048 bytes). Run readcd
with options and use this disk
image to burn the CD-R/RW.
# readcd dev=target,lun,scsibusno # select function 11
Here, set all three parameters to 0 for most cases. Usually the number of
sectors given by readcd
is excessive! Use the above number from
an actual mount for better results.
It should be noted that the use of dd
has a few problems if used
on CD-ROM. The first run of the dd
command may cause an error
message and may yield a shorter disk image with a lost tail-end. The second
run of dd
command may yield a larger disk image with garbage data
attached at the end on some systems if the data size is not specified. Only
the second run of the dd
command with the correct data size
specified, and without ejecting the CD after an error message, seems to avoid
these problems. If for example the image size displayed by df
is
46301184 blocks, use the following command twice to get the right
image (this is my empirical information):
# dd if=/dev/cdrom of=cd.img bs=2048 count=$((46301184/2))