LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Command-line utility to check burned DVD? (https://www.linuxquestions.org/questions/linux-software-2/command-line-utility-to-check-burned-dvd-844857/)

littlebigman 11-17-2010 10:42 AM

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.

catkin 11-17-2010 10:52 AM

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).

GrapefruiTgirl 11-17-2010 11:04 AM

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.

littlebigman 11-17-2010 12:10 PM

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.

GrapefruiTgirl 11-17-2010 12:17 PM

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.

littlebigman 11-17-2010 12:43 PM

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.

H_TeXMeX_H 11-17-2010 01:04 PM

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.

littlebigman 11-18-2010 01:43 AM

Thanks for the tip. Is cmp as good and reliable as the other solution?

What's padding?

H_TeXMeX_H 11-18-2010 07:32 AM

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"

littlebigman 11-18-2010 11:05 AM

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 -


catkin 11-18-2010 11:16 AM

Quote:

Originally Posted by littlebigman (Post 4163278)
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.

H_TeXMeX_H 11-18-2010 01:00 PM

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

catkin 11-18-2010 01:38 PM

Quote:

Originally Posted by H_TeXMeX_H (Post 4163422)
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 :redface:

And thanks for the link.


All times are GMT -5. The time now is 11:05 PM.