Score:1

Read DVD image with dd until empty

cn flag

I want to compare the SHA hash of the .iso file that I burned to a DVD with the image of the DVD itself to see if they are identical if the burning was succesful. The problem is that they are not, not because there was possible error, but because the way disk sectors work is that if 1 sector is half-full it reads all of it, or something like that.

Is there any way to use the dd tool to read only the filled data on the disk, that is up until the last bit/byte that is not empty, and ignore the empty space and the rounding at the end of it, so that the read disk image portion until it's filled, will be identical to the .iso that I used to burn it (if no other errors were present of course)?

guiverc avatar
cn flag
You've not provided any OS or release details, but almost all Ubuntu media has a self-validation that performs this check when you boot it. On some ISOs or releases you select to manually run it, on others the check is run but you need to look for the result... so why not just boot your *unstated* system & have it verify the media itself? FYI: *It's been a few cycles (groovy I think) when I was last required to use DVD media in QA-testing, and DVD validation is slow; but it's no slower booting & validating the disc compared to just reading it all - it's still got to read the whole disc*
cn flag
It's not a Ubuntu .iso, but something else, but I specifically want a terminal based dd solution to this. I know that there is one, I remember that there is, but I just couldn't find the answer anywhere. (also booting and self-validating it is bad for security, had this been a Ubuntu iso, and I would have downloaded a malware infested variant, it could just replace those trusted verification mechanisms, it's always important to validate .iso's externally, whatever it may be to avoid this security problem)
cn flag
You don't understand, I am using Ubuntu on my other PC to do this, it's just that the stuff that I am burning to the DVD is not an OS, it is on topic to this discussion. I am asking how to use the DD tool on a Ubuntu OS to achieve my goals stated here.
Score:2
jp flag

I tested right now with an old Lubuntu 16.04.1 LTS amd64 iso file and DVD-disk that I burned when it was new (2016). I extracted from the DVD-disk with dd,

$ sudo dd if=/dev/sr0 of=dvd.img bs=4096
218880+0 poster in
218880+0 poster ut
896532480 byte (897 MB, 855 MiB) kopierade, 95,2247 s, 9,4 MB/s

and compared the result with my stored iso file,

$ ls -l lubuntu-16.04.1-desktop-amd64.iso /media/multimed-2/test/test0/temp/dvd.img
-rw------- 1 nio  1002 896532480 jul 20  2016 lubuntu-16.04.1-desktop-amd64.iso
-rw-r--r-- 1 root root 896532480 dec  7 12:25 /media/multimed-2/test/test0/temp/dvd.img

$ md5sum lubuntu-16.04.1-desktop-amd64.iso /media/multimed-2/test/test0/temp/dvd.img
d2d7edc41ea03998e267db607f92b40d  lubuntu-16.04.1-desktop-amd64.iso
d2d7edc41ea03998e267db607f92b40d  /media/multimed-2/test/test0/temp/dvd.img

$ sha256sum lubuntu-16.04.1-desktop-amd64.iso /media/multimed-2/test/test0/temp/dvd.img
1b91a43b0101e03b0890428d3e77198c0d35364cf35e38aaea2755d10ace26a7  lubuntu-16.04.1-desktop-amd64.iso
1b91a43b0101e03b0890428d3e77198c0d35364cf35e38aaea2755d10ace26a7  /media/multimed-2/test/test0/temp/dvd.img

As you can see, the sizes and the checksums match.

cn flag
Unfortunately it doesn't work for me, maybe Ubuntu and other Linux OS variants are made to be an exact size to fill up all disk sectors but what I am burning to the DVD is not of exact rounded up size so a few bits/bytes will be left dangling in the other sector while the rest, supposedly filled up with zeroes. I could `cat` zeroes to it but I thought there is a simpler solution to this with `dd` only, perhaps some flags to ignore the leftovers, i don't know, not an expert with the tool.
sudodus avatar
jp flag
@Orchid67732, If you *know* the size (number of bytes), you can use dd with `count=blocks`. It helps if the number of bytes is an even multiple of big number, otherwise you must use a small block size (in the worst case bs=1) which makes dd slow. It may be better to cat zeroes or use some other method to make the sizes match.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.