[Discuss] K3b verify problems
John Blomfield
jabfield at shaw.ca
Sun Mar 23 14:41:26 PDT 2008
I have been burning a few distro CD iso's lately and have found that K3b
has been reporting an error between the downloaded iso and the burned CD
when the "verify" box is checked. After discarding a copy of disks and
then in desperation trying the disk and finding that it worked just fine
I have been looking for a way to easily independently verify the burned
CD. You may find this solution useful if you have a similar problem:
http://bbs.archlinux.org/viewtopic.php?pid=262760
Its a nice little Python script
It works fine and proves that K3b has a bug.
John Blomfield
P.S just in case you loose the link, here it is:
Usage: ./ISOVerify.py [[iso file] [device node]]
#!/usr/bin/python
import os, sys, md5
# globals
CD_BLOCK_SIZE = 2048
FILE_BLOCK_SIZE = 512
def parse_cli():
if len(sys.argv) != 3:
print "Usage: "+sys.argv[0]+" [[iso file] [device node]]"
sys.exit(1)
iso = sys.argv[1]
dev_node = sys.argv[2]
for f in iso, dev_node:
if not os.path.exists(f):
sys.stderr.write("Error: '"+f+"' does not exist!\n")
sys.exit(1)
return iso, dev_node
def get_bytes(file):
return int(os.stat(file)[6])
def get_blocks(bytes, block_size):
return bytes / block_size
def get_md5sum(file, block_size, blocks):
m = md5.new()
f = open(file, 'r')
current_block = 1
while current_block <= blocks:
try:
m.update(f.read(block_size))
f.seek(block_size * current_block)
except IOError:
# If we get here, it means we dont have the expected number of bytes.
#Return the current digest as this should reflect the inconsistant data anyways.
f.close()
return m.hexdigest()
current_block += 1
f.close()
return m.hexdigest()
def main():
iso, dev_node = parse_cli()
# iso md5sum
print iso+": ",
sys.__stdout__.flush()
iso_bytes = get_bytes(iso)
iso_blocks = get_blocks(iso_bytes, FILE_BLOCK_SIZE)
iso_md5sum = get_md5sum(iso, FILE_BLOCK_SIZE, iso_blocks)
print iso_md5sum
# cd/dvd md5sum
# use the total bytes from the iso image and divide by the cd's block
# size to get the number of blocks for the device node.
print dev_node+": ",
sys.__stdout__.flush()
dev_node_blocks = get_blocks(iso_bytes, CD_BLOCK_SIZE)
dev_node_md5sum = get_md5sum(dev_node, CD_BLOCK_SIZE, dev_node_blocks)
print dev_node_md5sum
if iso_md5sum == dev_node_md5sum:
print "md5sums match :)"
sys.exit(0)
else:
print "md5sums DO NOT match!"
sys.exit(0)
if __name__ == '__main__':
main()
More information about the Discuss
mailing list