1
April
2021
Checking DVD and CD reading
16:39

Checking DVD and CD reading

1 April 2021 16:39

Often, after writing data to a new DVD-R disc, you want to make sure that the files are readable. Also, old, scratched CD-R discs may raise doubts about their readability in a DVD-RW drive. Before using such disks, it is advisable to perform a read test, which will not take much time.

Method 1: Check disk readability using DD command

This method is not very good, because... does not give an idea of ​​which of the files is not readable. But the fastest
and tells you the result - whether the disk as a whole is readable or not.

dd if=/dev/dvdrw of=/dev/null

or for an external DVD drive:

dd if=/dev/sr1 of=/dev/null

where dvdrw, sr1 are the names of devices for reading/writing CD/DVD, which can be found using the command cd-drive из пакета libcdio-utils).

Example of execution result:
dd if=/dev/dvdrw of=/dev/null

626688+0 records in

626688+0 records out

320864256 bytes (321 MB, 306 MiB) copied, 68,8281 s, 4,7 MB/s

Method 2: Check that files on the disk are read using the FIND and CP /dev/null commands

A good method, although quite slow if there are a lot of files. Team

find /media/vladimir -type f -exec cp "{}" /dev/null \;

where vladimir is the username

Parsing (explanation) of the command:
The find command searches the directory /media/vladimir/DISK_NAME for all files (-type f)
and on each of them executes (-exec) the cp command.

In this case, two curly braces {} refer to the find command,
for the cp command, the name of the current file being processed is substituted for parentheses (see.man find):

The string `{}' is replaced by the current file name being processed everywhere it occurs in the arguments to the command

Why are there quotes around curly braces?
These are strong escape symbols.

Why do you need a semicolon at the end of the command?
This is also explained in man find:

All following arguments to find are taken to be arguments to the command until an argument consisting of `;' is encountered.

That is, a semicolon delimits the list of arguments to the find command.

Why is a backslash (slash - "\") used before the semicolon ";" ?
Without a slash, an error about a missing argument is printed
-exec cp "{}" /dev/null ;
find: missing argument to-exec'`
that is, the slash in my opinion is used to single escape the argument ";" (end of arguments).

It is better to learn more about escaping the syntax of the bash command interpreter from Linux courses or textbooks. Since this is beyond the scope of this article.

This command should be executed when the optical disk in the DVD-ROM drive has been recognized by the system and has been mounted in the /media directory (the disk appears in PCmanFM Explorer).

The result of running the command on an old, scratched CD:

find /media/vladimir -type f -exec cp "{}" /dev/null \;
cp: error reading '/media/vladimir/HBCD 15.2 RUS/HBCD/Boot/pmagic/pmodules/PMAGIC_2012_10_10.SQFS': Ошибка ввода/вывода

Method 3. Calculating the checksum (hash) from the burned disk (MD5SUM and SHA256SUM)

If the disk was burned from an ISO image, you can compare the original checksum of the image file and the checksum

after reading the disc.

You need to load a recorded CD or DVD into the DVD-RW drive and execute the command

md5sum /dev/dvdrw

Execution speed depends on drive speed and data volume

For example, the result for removing the disk checksum

4b6f499873f282c8dd95adaf071eec68 /dev/dvdrw

I also withdrew the amount from the original disk image
md5sum xubuntu-20.04.2.0-desktop-amd64.iso

4b6f499873f282c8dd95adaf071eec68 xubuntu-20.04.2.0-desktop-amd64.iso

The comparison shows that the checksums match, the disc is written with high quality and is readable.

Recently, the checksum is calculated using the SHA256 algorithm

for example, indicated on the page https://mirror.yandex.ru/ubuntu-cdimage/xubuntu/releases/20.04/release/
checksum using the SHA256 algorithm for the specified distribution is (see file SHA256SUMS)
c59c3bb825294dbf76fd3a5dfa3fd5de9e854934b7c9aa6258105b6648979cd5 *xubuntu-20.04.2.0-desktop-amd64.iso

You can compare the image file with the specified amount (which means that the image is downloaded completely and correctly):

sha256sum xubuntu-20.04.2.0-desktop-amd64.iso

Check result:
c59c3bb825294dbf76fd3a5dfa3fd5de9e854934b7c9aa6258105b6648979cd5 xubuntu-20.04.2.0-desktop-amd64.iso

The specified checksums (hash sums) match. This means the ISO image corresponds to the original one from the website.


Source (author borisych):