LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-30-2013, 10:31 PM   #1
user1x
LQ Newbie
 
Registered: Apr 2013
Posts: 14

Rep: Reputation: Disabled
How to verify a disk matches an ISO file?


When trying to burn a blu-ray disk from an ISO file using growisofs, I got a strange error:
"CLOSE SESSION failed with SK=5h/INVALID FIELD IN CDB"

I googled and found too much data and not enough information, if you know what I mean. I'm not 100% confident that I didn't lose any data. Most people say stuff like it *should* be okay. I want confirmation that it *is* okay. To me, okay means that all the files in the ISO are on the disk and are complete.

I read that you can do a `dd if=/dev/sr0 bs=64k|md5sum` to create an md5sum of the disk and then compare it against `cat my.iso|md5sum`. They didn't match. However, a `diff -r` between a mount of the ISO against a mount of the disk did not show any differences. I don't feel 100% good about this disk. So I have a few questions:

1. What could explain the difference between the md5sums?
2. Is there a simple way to never get the error above? I don't mind running some script before or after I burn, updating kernels or firmware.

I'm sure the answer to #2 is out there, but I'm just completely lost in the details of most of the posts that I see. I just want the error to go away. I don't need a 10 page report about why it happened.

Last edited by user1x; 04-30-2013 at 10:32 PM. Reason: mentioned growisofs
 
Old 04-30-2013, 10:40 PM   #2
Timothy Miller
Moderator
 
Registered: Feb 2003
Location: Arizona, USA
Distribution: Debian, Arch, Void
Posts: 3,551
Blog Entries: 5

Rep: Reputation: 1202Reputation: 1202Reputation: 1202Reputation: 1202Reputation: 1202Reputation: 1202Reputation: 1202Reputation: 1202Reputation: 1202
Easier to use md5sum directly:
Code:
md5sum whatever.iso
As far as using the dd I'm assuming your actually doing dd if=/you/iso bs=64k. If you're doing /dev/sr0 then unless you've already burnt it and put it into your drive (/dev/sr0 is your optical drive normally), then you're not getting a md5 of your iso, but rather that of an empty mountpoint. However, dd if=/your/iso bs=64k | md5sum SHOULD produce the same results as md5sum youriso.iso.

As far as the cat my.iso | md5sum not sure, never attempted to use that method.

I'd still say it's a lot easier just to use md5sum directly. It's had that ability to directly read an iso for quite some time.
 
Old 05-01-2013, 08:37 AM   #3
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
How to use md5sum
"cat my.iso | md5sum" will NOT work, forget about it. That information is WRONG.

Last edited by Habitual; 05-01-2013 at 08:39 AM.
 
Old 05-01-2013, 08:40 AM   #4
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292
I would use 'cmp' to compare the iso to the burned image. The burned image usually is padded with zeroes, so it will not match the md5sum.
 
Old 05-01-2013, 04:44 PM   #5
jefro
Moderator
 
Registered: Mar 2008
Posts: 20,314

Rep: Reputation: 3213Reputation: 3213Reputation: 3213Reputation: 3213Reputation: 3213Reputation: 3213Reputation: 3213Reputation: 3213Reputation: 3213Reputation: 3213Reputation: 3213
The true test of disc would be both write and read then test. Burn the cd, read back from the cd and test result.

Due to some issues with how some drives burn and how some drives read, you can't be sure this disc will work with every drive.

Last edited by jefro; 05-01-2013 at 04:46 PM.
 
Old 05-01-2013, 10:23 PM   #6
user1x
LQ Newbie
 
Registered: Apr 2013
Posts: 14

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Habitual View Post
How to use md5sum
"cat my.iso | md5sum" will NOT work, forget about it. That information is WRONG.
`cat my.iso | md5sum` and `md5sum my.iso` gave me identical results.
 
Old 05-02-2013, 11:45 AM   #7
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Verify that ISO with isoinfo?
 
Old 06-10-2013, 01:57 AM   #8
jpyper
LQ Newbie
 
Registered: Jun 2013
Location: Lexington Park, MD, USA
Distribution: Arch Linux
Posts: 4

Rep: Reputation: Disabled
Verify Written Data Against Image File

Quote:
Originally Posted by user1x View Post
When trying to burn a blu-ray disk from an ISO file using growisofs, I got a strange error:
"CLOSE SESSION failed with SK=5h/INVALID FIELD IN CDB"

I googled and found too much data and not enough information, if you know what I mean. I'm not 100% confident that I didn't lose any data. Most people say stuff like it *should* be okay. I want confirmation that it *is* okay. To me, okay means that all the files in the ISO are on the disk and are complete.

1. What could explain the difference between the md5sums?
2. Is there a simple way to never get the error above? I don't mind running some script before or after I burn, updating kernels or firmware.
I made a little shell script for burning iso files to blank discs. It has a simple verify section that I will share, which you can paste into a text file. Make the file executable (chmod u+x verifydisc.sh). Change the BURN_DRIVE variable to whatever your burner is. /dev/sr0 /dev/dvd etc...

Run the script from the command line and be sure to quote the image file name: verifydisc.sh "My File.iso"

If you are interested in my whole burnimg.sh script, I'd be more than happy to share it with you. It's still missing a few minor things like checking to make sure the disc is in the drive before proceeding to the next command that requires the disc to be ready, or checking to make sure the filename passed on the command line is a file or that is even exists. Those are coming soon. I use wodim as my default writing program, but also have a commented out line for genisofs as well.

Code:
#!/bin/sh

# set burner drive
BURN_DRIVE="/dev/sr0"

# [VERIFY DISC WRITTEN DATA]
clear
echo "+--------------------------------------------------------+"
echo "|  VERIFY WRITTEN DATA ON DISC                           |"
echo "|                                                        |"
echo "| This can be a long process, depending on drive speeds. |"
echo "| Steps 3 and 4 will take the longest.                   |"
echo "+--------------------------------------------------------+"
echo
echo "IMAGE FILE:  $1"
echo "BURNER:      $BURN_DRIVE"
echo

# Get image file MD5 checksum
echo "(1/4) Getting MD5 checksum from image."
VERIFY_IMAGE_MD5SUM="`md5sum "$1" | cut -d " " -f 1`"

# Get image file byte count
echo "(2/4) Getting byte count from image."
VERIFY_IMAGE_BYTES="`wc -c "$1" | cut -d " " -f 1`"

# Get written disc MD5 checksum
echo "(3/4) Getting MD5 checksum from written disc."
VERIFY_DISC_MD5SUM="`dd status=none if=$BURN_DRIVE | head -c $VERIFY_IMAGE_BYTES | md5sum | cut -d " " -f 1`"
echo "      * This probably took quite a while."

# Get written disc byte count
echo "(4/4) Getting byte count from written disc."
VERIFY_DISC_BYTES="`dd status=none if=$BURN_DRIVE | wc -c - | cut -d " " -f 1`"
echo "      * This shouldn't have taken quite as long as the previous step."
echo

# Print some statistics on the screen
echo "*** These numbers should match. ***"
echo "FILE MD5SUM:      $VERIFY_IMAGE_MD5SUM"
echo "DISC MD5SUM:      $VERIFY_DISC_MD5SUM"
echo
echo "*** These numbers should match. ***"
echo "FILE BYTES:       $VERIFY_IMAGE_BYTES"
echo "DISC BYTES:       $VERIFY_DISC_BYTES"
echo

Last edited by jpyper; 06-10-2013 at 02:03 AM.
 
Old 06-10-2013, 08:23 AM   #9
mina86
Member
 
Registered: Aug 2008
Distribution: Debian
Posts: 517

Rep: Reputation: 228Reputation: 228Reputation: 228
Quote:
Originally Posted by jpyper View Post
Code:
VERIFY_IMAGE_BYTES="`wc -c "$1" | cut -d " " -f 1`"
Perhaps:
Code:
VERIFY_IMAGE_BYTES=$(stat "$1" | sed -n 's/.*Size: *\([0-9]*\).*/\1/p')
Quote:
Originally Posted by jpyper View Post
Code:
echo "*** These numbers should match. ***"
echo "FILE MD5SUM:      $VERIFY_IMAGE_MD5SUM"
echo "DISC MD5SUM:      $VERIFY_DISC_MD5SUM"
Human being probably would not call those numbers and besides its far more user friendly to actually print out whether the hashes were the same or not:
Code:
if [ x"$VERIFY_IMAGE_MD5SUM" = x"$VERIFY_DISC_MD5SUM" ]; then
    echo "File and disc checksum match ($VERIFY_IMAGE_MD5SUM)"
else
    echo "File and disc checksum do not match!"
    echo "  file: $VERIFY_IMAGE_MD5SUM"
    echo "  disc: $VERIFY_DISC_MD5SUM"
fi
Quote:
Originally Posted by jpyper View Post
Code:
echo "*** These numbers should match. ***"
echo "FILE BYTES:       $VERIFY_IMAGE_BYTES"
echo "DISC BYTES:       $VERIFY_DISC_BYTES"
Not necessarily. I would skip checking the size of recorded disk myself.

Last edited by mina86; 06-10-2013 at 08:26 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to verify the signature of the slack ISO images (or any other file for that matte stf92 Slackware - Installation 2 10-26-2012 10:18 AM
How do I verify the iso images Virtual Circuit Slackware - Installation 6 02-18-2008 11:17 AM
How to verify downloaded iso's ashwin_cse Fedora 1 06-27-2005 10:23 PM
Cant verify checksum off ISO file after downloading with Win XP Firefox idros Linux - Newbie 2 09-25-2004 08:48 AM
How do I verify the iso's with md5sums and other questions Bork3 Mandriva 1 11-16-2003 03:48 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:46 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration