Solved [Solved] Checking CD/DVD data integrity?

Re: Checking CD/DVD data integrity?

That's because fsck is file-system specific, and to my knowledge, there is no fsck for the ISO-style file systems.

Here is what I do. You can just check that every block of the CD device (not the file system, the raw data) is readable. We know that CDs have 2KiB block size, so all you need is: dd if=/dev/cdxx of=/dev/null bs=2048, and you have to enter the correct device name for your CD. This will run for a long time, reading the CD at full speed. At the end of the media, it will get a read error. This means you have to think a little bit about the capacity of the CD. For example, if you know that it should contain roughly 300MB, that would be 150,000 blocks, so if the error message from dd says that you got the error after that many blocks, you're good to go.

But in in the end, you don't care whether every block of the CD is actually readable. You really just care that all the directories and files are readable. So you need a command to walk the directory structure (that's find), and another one to read the files. For the latter, you can use dd; I have a little C program floating around (cunningly called readfile) that does the same job, but gives nicer error messages and can handle a whole list of files. The only remaining question is how to plumb them together. There are many options, here are a few. Say you have a program readfile which reads all the files on its argument list:
find /mnt/cd -type f -exec readfile {} \;
find /mnt/cd -type f -print0 | xargs -0 -n 100 readfile
find /mnt/cd -type f -print | while read f ; do dd if=$f of=/dev/null bs=4096 ; done
The last one doesn't need readfile, but has the disadvantage that it doesn't work if the file names on CD contain special characters (spaces, newlines). The middle one runs marginally faster, because the exec only needs to be done for each 100 files. There is another way to read the whole directory: Just tar it up, and throw the result away: tar -vcf /dev/null /mnt/cd, which reads every file in every directory of the CD, puts it into a tar file, and writes it to the bitbucket.
 
Re: Checking CD/DVD data integrity?

Ok. I did the tar thing. I guess if some file was not readable it would have showed me an error, right?
Thank you very much.
 
Re: Checking CD/DVD data integrity?

Sort of forgot to mention that: Do any of the things that read all directories and files, and then look for error messages indicating read errors.

Good thing it worked.
 
Re: Checking CD/DVD data integrity?

See mtree(8) about checksumming a tree of files. A faster way to do this is generate one big file with the archiver of your choice. Write that file to CD/DVD, read it back with sha256(1) and compare the checksum with the original file.
 
Back
Top