View Single Post
  #1   (View Single Post)  
Old 7th December 2017
gustaf gustaf is offline
Fdisk Soldier
 
Join Date: Dec 2016
Posts: 69
Default Verify integrity of disk image file written to disk ?

I have copied the file https://<local-mirror-domain-name>/pub/OpenBSD/6.2/amd64/install62.fs
to a flash drive using dd(1), according to the instrucions in /pub/OpenBSD/6.2/amd64/INSTALL.amd64.

These instructions also suggest that
Quote:
...copying the image back to a file and doing a compare or checksum is a good way to verify that the USB key is readable and free of read/write errors.
This would be relatively easy to accomplish with a reverse dd(1) if the file and the drive were the same size: $ doas dd if=/dev/rsd1c of=/path/to/install62.fs.copy bs=1m.

The problem is that /dev/rsd1c (the drive that contains the copied image) is larger than install62.fs (the original file). Any attempt to copy and compare will inevitably fail.

One possible solution is to extract the 'install62.fs' data from the drive before copying it to a file, but I can't find a command to do this.

Once I have a duplicate file, it's a simple matter of running cmp(1), sha256(1), or sha512(1) to see if the two files match.

Does anyone have any suggestions for how to copy the image on the drive back to a file so I can verify that the drive was written correctly?

I can mount the file systems and see the files, so I think it's OK, but I'd like to have some extra assurance since this is part of my emergency recovery plan.

Thanks.
Reply With Quote