## 10 Copying CD-ROMs and DVDs ¶

Ddrescue may be better than dd for copying recordable CD-ROMs because the two lead out sectors at the end of some of them may cause a read error that prevents the whole last record from being copied by dd, potentially losing data. Also dd may create an image larger than the original if the ‘`sync`’ conversion and a block size larger than the sector size are specified.

In the special case of reading CD-ROMs (but not DVDs), the specialized tool dvdisaster may be a better option than ddrescue for recovering data because dvdisaster can read and analyze raw CD sectors, which ddrescue can’t.

Recordable CD and DVD media keep their data only for a finite time (typically for some years). After that time, data loss develops slowly with read errors growing from the outer region towards the inside. It is a good idea to make two (or more) copies of every important CD-ROM/DVD you burn so that you can later recover them with ddrescue.

If you have only one copy of a CD-ROM or DVD that fails when being copied, and if you have access to multiple optical media drives, you have a better chance of recovering the bad sectors since one drive may fail to read a particular sector, but another drive might be able to squeeze the data out of it, depending on the laser frequency and the sensitivity of the laser-sensor that reads the reflected laser light.

Example 1: Rescue a CD-ROM in `/dev/cdrom`.

    ddrescue -n -b2048 /dev/cdrom cdimage mapfile
    ddrescue -d -r1 -b2048 /dev/cdrom cdimage mapfile
      (if bad-sector size is zero, cdimage now contains a complete image
       of the CD-ROM and you can write it to a blank CD-ROM)

Example 2: Rescue a CD-ROM in `/dev/cdrom` from two copies.

    ddrescue -n -b2048 /dev/cdrom cdimage mapfile
    ddrescue -d -b2048 /dev/cdrom cdimage mapfile
      (insert second copy in the CD drive)
    ddrescue -d -r1 -b2048 /dev/cdrom cdimage mapfile
      (if bad-sector size is zero, cdimage now contains a complete image
       of the CD-ROM and you can write it to a blank CD-ROM)

Example 3: Rescue a CD-ROM in `/dev/cdrom` using two CD drives from two different computers, writing the image into an USB drive mounted on `/mnt/mem`.

    ddrescue -n -b2048 /dev/cdrom /mnt/mem/cdimage /mnt/mem/mapfile
    ddrescue -d -r1 -b2048 /dev/cdrom /mnt/mem/cdimage /mnt/mem/mapfile
      (umount the USB drive and move both USB drive and CD-ROM to second
       computer)
    ddrescue -d -r1 -b2048 /dev/cdrom /mnt/mem/cdimage /mnt/mem/mapfile
      (if bad-sector size is zero, /mnt/mem/cdimage now contains a complete
       image of the CD-ROM and you can write it to a blank CD-ROM)

Example 4: Merge the partially recovered images of 3 identical DVDs using their mapfiles as domain mapfiles.

    ddrescue -m mapfile1 dvdimage1 dvdimage mapfile
    ddrescue -m mapfile2 dvdimage2 dvdimage mapfile
    ddrescue -m mapfile3 dvdimage3 dvdimage mapfile
      (if bad-sector size is zero, dvdimage now contains a complete image
       of the DVD and you can write it to a blank DVD)

Example 5: Recover a lzip compressed backup from two copies on CD-ROM with error-checked merging of copies.

    ddrescue -d -r1 -b2048 /dev/cdrom cdimage1 mapfile1
    mount -t iso9660 -o loop,ro cdimage1 /mnt/cdimage
    cp /mnt/cdimage/backup.tar.lz rescued1.tar.lz
    umount /mnt/cdimage
      (insert second copy in the CD drive)
    ddrescue -d -r1 -b2048 /dev/cdrom cdimage2 mapfile2
    mount -t iso9660 -o loop,ro cdimage2 /mnt/cdimage
    cp /mnt/cdimage/backup.tar.lz rescued2.tar.lz
    umount /mnt/cdimage
    lziprecover -v -m -o backup.tar.lz rescued1.tar.lz rescued2.tar.lz
      Input files merged successfully.
    lziprecover -tv backup.tar.lz
      backup.tar.lz: ok