LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 11-17-2010, 10:42 AM   #1
littlebigman
Member
 
Registered: Aug 2008
Location: France
Posts: 658

Rep: Reputation: 35
Question Command-line utility to check burned DVD?


Hello

On a bare Ubuntu 10.04 server, I used the following commands to check which device is used by the DVD burner, and then burn an ISO file:

Code:
apt-get install wodim
wodim --devices

apt-get install dvd+rw-tools
growisofs -speed=2 -dvd-compat -Z /dev/scd0=myfile.iso
But before mailing the DVD to a friend, I need to make sure the DVD is OK, but 30mn of Google didn't provide a command-line utility to do this.

Do you know if there is one available?

Thank you.
 
Old 11-17-2010, 10:52 AM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
You could use dd to copy the data back from the DVD to a file and checksum it, for example with md5sum. If you are doing this there are a couple of potential "gotchas". The DVD must not be mounted or you will get its contents not the image and you must dd the same amount of data back from the DVD using dd's count= option (divide the iso size in bytes by 512, assuming dd's default block size of 512 bytes).
 
Old 11-17-2010, 11:04 AM   #3
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 555Reputation: 555Reputation: 555Reputation: 555Reputation: 555Reputation: 555
Like catkin says, use md5sum and dd to read the burned image. No need for using another file though.

Here's a `rawread` command (a script) that came with some package or other, I've had it floating around for quite a while.. I don't think it currently comes with Slackware.. Anyhow, let's say your DVD drive is /dev/sr0, then you would do:
Code:
root# ./rawread /dev/sr0 | md5sum
and wait till it finishes - it takes a little while. Here's the code:
Code:
#!/bin/sh
# rawread - reads raw data of optical drive.

device=$1

blocksize=`isoinfo -d -i $device | grep "^Logical block size is:" | cut -d " " -f 5`
if test "$blocksize" = ""; then
        echo catdevice FATAL ERROR: Blank blocksize >&2
        exit
fi

blockcount=`isoinfo -d -i $device | grep "^Volume size is:" | cut -d " " -f 4`
if test "$blockcount" = ""; then
        echo catdevice FATAL ERROR: Blank blockcount >&2
        exit
fi

command="dd if=$device bs=$blocksize count=$blockcount conv=notrunc,noerror"
echo "$command" >&2
$command
EDIT: Here's what you see if you use it:
Code:
sasha@reactor: /home/sasha/SCRIPTING/rawread /dev/sr0 | md5sum
dd if=/dev/sr0 bs=2048 count=1884590 conv=notrunc,noerror
1884590+0 records in
1884590+0 records out
3859640320 bytes (3.9 GB) copied, 298.572 s, 12.9 MB/s
560b0feb704ae2e742682babdb1bde40  -
sasha@reactor:
With the final md5sum there in bold.

Last edited by GrapefruiTgirl; 11-17-2010 at 11:12 AM.
 
Old 11-17-2010, 12:10 PM   #4
littlebigman
Member
 
Registered: Aug 2008
Location: France
Posts: 658

Original Poster
Rep: Reputation: 35
Thanks much for the tip, but although the DVD is in the drive but apparently not mounted, the above script didn't work:

Code:
root@ubuntu:/tmp# mount
/dev/sda1 on / type ext3 (rw,errors=remount-ro)
proc on /proc type proc (rw,noexec,nosuid,nodev)
none on /sys type sysfs (rw,noexec,nosuid,nodev)
none on /sys/fs/fuse/connections type fusectl (rw)
none on /sys/kernel/debug type debugfs (rw)
none on /sys/kernel/security type securityfs (rw)
none on /dev type devtmpfs (rw,mode=0755)
none on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
none on /dev/shm type tmpfs (rw,nosuid,nodev)
none on /var/run type tmpfs (rw,nosuid,mode=0755)
none on /var/lock type tmpfs (rw,noexec,nosuid,nodev)
none on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)

root@ubuntu:/tmp# ./rawread /dev/scd0 | md5sum
catdevice FATAL ERROR: Blank blocksize
d41d8cd98f00b204e9800998ecf8427e  -
Thank you.
 
Old 11-17-2010, 12:17 PM   #5
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 555Reputation: 555Reputation: 555Reputation: 555Reputation: 555Reputation: 555
Correct that the disc does not need to be mounted. I suspect the problem using the script is that you do not have cdrtools and/or dvd+-rw_tools (approximate spelling) packages installed. So, the value of that variable is not being set correctly, and the script is failing. The script is pretty simple as you can see, so I can't imagine what else could be wrong.

Whatever package brings `isoinfo` with it. For me, I have:
Code:
root@reactor: which isoinfo
/usr/bin/isoinfo

# Which comes from Slackware package:
cdrtools-3.00-x86_64-1
So the above indicates for me, a Slackware package called cdrtools-3.00-x86_64-1 - maybe you have (or don't have) a similar package (cdrtools) for your OS which would provide this tool?

Otherwise, you'll have to come up with another means of determining correctly, the count= and blocksize= values you require for `dd` to correctly read back the data.
 
Old 11-17-2010, 12:43 PM   #6
littlebigman
Member
 
Registered: Aug 2008
Location: France
Posts: 658

Original Poster
Rep: Reputation: 35
OK, found what it was: When copy/pasting from the web page to the terminal, the "blocksize=" and "blockcount=" lines were turned into two lines. Fixing those two errors solved the problem.

Apparently, an alternative to using md5 directly is using the original ISO file as reference:

http://how-to.wikia.com/wiki/How_to_...x#Command_line

Thanks again.
 
Old 11-17-2010, 01:04 PM   #7
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
My goodness, it seems so complicated, but there's also:

Code:
cmp image.iso /dev/sr0
This should output that there is padding on the drive, which is true.
 
Old 11-18-2010, 01:43 AM   #8
littlebigman
Member
 
Registered: Aug 2008
Location: France
Posts: 658

Original Poster
Rep: Reputation: 35
Thanks for the tip. Is cmp as good and reliable as the other solution?

What's padding?
 
Old 11-18-2010, 07:32 AM   #9
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
Padding = it adds zeros to the end of the disk after burning the iso. This means a direct md5sum with device and iso will fail.

As for reliable, read 'man cmp'

"cmp - compare two files byte by byte"
 
Old 11-18-2010, 11:05 AM   #10
littlebigman
Member
 
Registered: Aug 2008
Location: France
Posts: 658

Original Poster
Rep: Reputation: 35
Thank you. "pv" makes it possible to have some progress info:

Code:
# pv myfile.iso | cmp /dev/scd0
3.88GB 0:06:38 [9.97MB/s] [======================================================================>] 100%
cmp: EOF on -
 
1 members found this post helpful.
Old 11-18-2010, 11:16 AM   #11
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by littlebigman View Post
Thank you. "pv" makes it possible to have some progress info:

Code:
# pv myfile.iso | cmp /dev/scd0
3.88GB 0:06:38 [9.97MB/s] [======================================================================>] 100%
cmp: EOF on -
pv? What's that? Not on Slackware64 and netsearching matches too many irrelvant pages.

Given that any padding will be on the DVD, not in the .iso, would it be better to use pv /dev/scd0 | cmp myfile.iso? Otherwise an early EOF could indicate an error.

Last edited by catkin; 11-18-2010 at 11:17 AM. Reason: SLackware64 -> Slackware64
 
Old 11-18-2010, 01:00 PM   #12
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
I think it is correct, EOF on - means that stdin has finished, while /dev/scd0 still has padding.

As for pv:
http://www.ivarch.com/programs/pv.shtml
 
1 members found this post helpful.
Old 11-18-2010, 01:38 PM   #13
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by H_TeXMeX_H View Post
I think it is correct, EOF on - means that stdin has finished, while /dev/scd0 still has padding.

As for pv:
http://www.ivarch.com/programs/pv.shtml
Thanks H_TeXMeX_H Of course it is; don't know what I was thinking of

And thanks for the link.
 
  


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
Command Line Utility to Determine External (Internet) IP dragos19 Linux - Software 2 05-14-2008 10:18 AM
command line setup utility sikkalgopal Mandriva 3 09-14-2004 12:41 PM
Where is Command line utility for Cups and command tutorial mossy Linux - Software 8 01-16-2004 12:24 AM
Command line utility costasm Linux - Software 1 10-24-2003 09:28 AM
Command line update utility ro Red Hat? ScreeminChikin Linux - General 4 01-17-2003 08:06 PM

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

All times are GMT -5. The time now is 03:15 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