I have several old CDs that have scratches and won't play anymore. The same with a scratched video DVD. Is there any chance to recover the data using Ubuntu?
You can use ddrescue to recover damaged media. In contrast to regular dd it will not stop at unreadble sectors. This is especially promising with optical media because sometimes retries or reversed reading of the media yield different results.
sudo apt install gddrescue
With ddrescue you can try to recover your data in multiple steps. Not all of which are always needed.
Step 1: Get the good data
In the first run we recover everything that is proberly readable and log what appears to be damaged.
ddrescue -b 2048 -n -v /dev/sr0 dvd.iso rescue.log
The blocksize of 2048 is the default blocksize of DVD media. The device name /dev/sr0 could be different on your system. Just run
mount to find the correct name.
Step 2: Try the bad blocks
If you get no errors after step 1, your are done. If you do get errors, run the following command to concentrate on the bad blocks.
ddrescue -b 2048 -d -r 3 -v /dev/sr0 dvd.iso rescue.log
The parameter -d enables direct access to the device (requests do not go through the kernel), -r 3 is the number of retries for bad blocks.
If you still get errors, continue.
Step 3: Going backwards
Finally run this:
ddrescue -b 2048 -d -R -r 3 -v /dev/sr0 dvd.iso rescue.log
The parameter -R reverses the reading direction. This can ofter lead to several more blocks that can be successfully recovered.
Even if you still have some errors, ddrescue will fill blocks that cannot be recovered with zeros, so that you do not get errors when playing back the media. Audio-CDs and Video-DVDs include a lot of error correction data. That means that even if you still have errors, you might not hear or see any problems with your recovered media.