Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11
After burning some CDs on my laptop I noticed an interesting problem. When I checked the MD5 of the CD I burned it didn't match; I figured it was just ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux User Krendoshazin's Avatar
    Join Date
    Feb 2005
    Location
    London, England
    Posts
    471

    An interesting problem to watch out for


    After burning some CDs on my laptop I noticed an interesting problem. When I checked the MD5 of the CD I burned it didn't match; I figured it was just a bad burn, so I burned another one and it did the same thing.

    I realised that both MD5 sums from the first CD and the second were exactly the same, and so it couldn't be a random error. I ran script and 'cat'ed the drive to see exactly what it was outputting, and it turned out to be a whole lot of "nothing".

    Code:
    root@neuromancer:~# md5check sweex.iso
    c99a74c555371a433d121f551d6c6398 /dev/sr0
    d7fdf8a0a0de095f0d8b84b981a79cb2  sweex.iso
    
    root@neuromancer:~# cat /dev/sr0
    ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@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^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@
    It's only once I ejected the drive and put it back in that I was able to verify the disc properly:

    Code:
    root@neuromancer:~# md5check sweex.iso
    d7fdf8a0a0de095f0d8b84b981a79cb2 /dev/sr0
    d7fdf8a0a0de095f0d8b84b981a79cb2  sweex.iso
    I'm not sure what's causing it - it could be the drive or the kernel, or even the software - but it's not a huge hassle to use the -eject option with 'cdrecord' in order to get around this problem for now. It's worth watching out for.

  2. #2
    Guest
    Join Date
    Feb 2005
    Posts
    312
    Ok I'm tired, so it's possible I'm not getting this, but if you're simply checking the burned disc against the .iso that may be where you're going wrong. I don't know what "md5check" is but with md5sum you need to specify the file size as the image will not be filling the entire disc, thus you're checking the .iso against the image on the disc + the remaining unused space on the disc. You need to get the size of the .iso and just pipe that much of the disc to md5sum using dd. There are online guides for this sort of thing if you have a search around.

  3. #3
    Linux User Krendoshazin's Avatar
    Join Date
    Feb 2005
    Location
    London, England
    Posts
    471
    md5check is a script that I wrote to take a filename as input and then compare it against the md5sum of the disc in the drive:
    Code:
    #!/bin/bash
     
    if [ -e $1 ]; then
            isofile=$1
    else
            echo "Error: file does not exist"
            exit
    fi
     
    drive=/dev/sr0
    filesize=$(ls -l $isofile | awk '{ print $5 }')
     
    echo `cat $drive | head --bytes=$filesize | md5sum | awk '{ print $1 }'`"  $drive"
    md5sum $isofile
    I assure you there is nothing wrong with my code, and it is only DVDs that require you to check the data that actually corresponds to the file. The problem, as I have said, is that the md5sum is incorrect until the disc is ejected from the drive and put back in again.

  4. #4
    Guest
    Join Date
    Feb 2005
    Posts
    312
    Quote Originally Posted by Krendoshazin View Post
    it is only DVDs that require you to check the data that actually corresponds to the file
    I'm afraid that's not true - and by the way I was not for one moment questioning your scripting abilities.

    It depends on the image file not whether it's a DVD or CD - e.g. if you burn a 180MB .iso to a CDR/CDRW and then do an md5sum of the whole disk, it will not match the original .iso

  5. #5
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353

    typo

    @krendro,

    I have had the exact same problem as you, except I wasn't going as far as you did to verify my discs. I stuck an -eject at the end of my media burning script, like you, and all was good.

  6. #6
    Linux User TaZMAniac's Avatar
    Join Date
    Jan 2009
    Posts
    269
    I've also have had this issue when using a burning program like k3b or brasero.
    For some reason the verify disk feature would report a failure but if I had the program eject the disk and then
    reinsert the disk then the md5 verification would report that the disk burned correctly.
    I believe it has something to do with the last bits of burned data remaining in the program cache. Doing an eject
    purges the cache and forces the program to re-read the disk to get the proper md5sum.

  7. #7
    Linux User Krendoshazin's Avatar
    Join Date
    Feb 2005
    Location
    London, England
    Posts
    471
    Quote Originally Posted by caravel View Post
    It depends on the image file not whether it's a DVD or CD - e.g. if you burn a 180MB .iso to a CDR/CDRW and then do an md5sum of the whole disk, it will not match the original .iso
    I will verify that the next time I burn a copy of AVG rescue CD to the CDRW disc I use. I used a CD-R in this case, and the ISO that I burned was only 66MB; I know that it matches the ISO md5 because I ran md5sum on the drive during my attempt to diagnose this. I've burned a lot of media, and the only time I recall the problem of extra data affecting the md5 hash is on DVDs.
    Last edited by Krendoshazin; 11-26-2011 at 11:47 AM. Reason: Modified a sentence to make more sense.

  8. #8
    Linux User Krendoshazin's Avatar
    Join Date
    Feb 2005
    Location
    London, England
    Posts
    471
    It's good to know that I'm not the only one experiencing this problem. I was starting to think that I was the only one who got to have all the fun.

  9. #9
    Linux User Krendoshazin's Avatar
    Join Date
    Feb 2005
    Location
    London, England
    Posts
    471
    I finally got around to burning that copy of AVG on my CDRW - they release updates about twice a month.

    The commands I used are:
    Code:
    cdrecord -v -blank=fast -dev=/dev/sr0
    cdrecord -v -eject -dev=/dev/sr0 avg_arl_cdi_all_120_110831a4643.iso
    and the results are:
    Code:
    root@neuromancer:~# md5sum avg_arl_cdi_all_120_110831a4643.iso
    a6ff495f5d17066cee6f03b46f88367d  avg_arl_cdi_all_120_110831a4643.iso
    root@neuromancer:~# md5sum /dev/sr0
    a6ff495f5d17066cee6f03b46f88367d  /dev/sr0
    and hence it does not contain extra data at the end of the disc, unlike DVDs.

  10. #10
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    I'd never thought to run an md5sum on the block device itself - good tip, thanks for posting (even if it is problematic on DVDs).

Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •