Troubles attempting to verify sha256sum of bootable CentOS 7.5.1804 thumb drive.

General support questions
Post Reply
Spork Schivago
Posts: 37
Joined: 2017/08/14 04:21:54

Troubles attempting to verify sha256sum of bootable CentOS 7.5.1804 thumb drive.

Post by Spork Schivago » 2018/10/14 22:37:03

Hi!

The CentOS wiki pages seem to be down. I'm right in the middle of attempting to make a bootable USB thumb drive, but would like to verify the thumb drive before attempting to install.

I ran sha256sum on the ISO itself that I dd'd to the thumb drive, but now, I don't know how to check the sha256 sum of the thumb drive.

I believe it'd be something like this:

Code: Select all

dd if=/dev/sdc bs=4096 count=144896 | sha256sum 
That count though....that would differ depending on what ISO of CentOS I dd'd. Those directions where for CentOS 7.4, not CentOS 7.5. I believe the wiki would have the answer, but could someone please confirm that my hypothesis is correct here?

My hypothesis is that count is equal to the number of bytes long the ISO is, divided by 4096 (because we specify that we want to read 4096 bytes at a time). The correct command would therefore be something along the lines of:

Code: Select all

dd if=/dev/sdc bs=4096 count= $(($(stat -c '%s' CentOS-7-x86_64-DVD-1804.iso) / 4096)) | sha256sum
correct?

I am a little confused as to why I cannot simply run sha256sum on /dev/sdc. I used dd to write the ISO image to the thumb drive. Shouldn't the ISO now be a 1:1 copy of the thumb drive, and vice-versa?

Thank you!
Last edited by Spork Schivago on 2018/10/14 22:44:10, edited 1 time in total.
-- Niklaus Wirth's Law: software is getting slower more rapidly than hardware becomes faster.

User avatar
TrevorH
Site Admin
Posts: 33219
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Troubles attempting to verify sha256sum of bootable CentOS 7.5.1804 thumb drive.

Post by TrevorH » 2018/10/14 22:42:21

When you dd the iso image file to the USB stick, it tells you how many blocks it copied when it finishes. That's how many you need to read back. Alternatively you can take the image file size and divide it by the blocksize you are using - for the CentOS-7-x86_64-DVD-1804.iso file, sized 4470079488 that would be 1091328 if using a 4096 blocksize.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

Spork Schivago
Posts: 37
Joined: 2017/08/14 04:21:54

Re: Troubles attempting to verify sha256sum of bootable CentOS 7.5.1804 thumb drive.

Post by Spork Schivago » 2018/10/14 22:47:34

TrevorH wrote:
2018/10/14 22:42:21
When you dd the iso image file to the USB stick, it tells you how many blocks it copied when it finishes. That's how many you need to read back. Alternatively you can take the image file size and divide it by the blocksize you are using - for the CentOS-7-x86_64-DVD-1804.iso file, sized 4470079488 that would be 1091328 if using a 4096 blocksize.
I edited my post after posting. Sorry about that. I had written the post and then started thinking about the problem a little more clear like. So my hypothesis was correct. We just went a little bit different ways of doing it. The image did successfully verify. Earlier, I tried making this disc in Windows, using win32diskimager or something along those lines. It appeared to be successful, but CentOS failed verification when I attempted to install. I switched over to my Linux box and used the tried and true dd to write it directly to the thumb drive. If it fails now, I will know there's an issue with the USB port on the server.
-- Niklaus Wirth's Law: software is getting slower more rapidly than hardware becomes faster.

Spork Schivago
Posts: 37
Joined: 2017/08/14 04:21:54

Re: Troubles attempting to verify sha256sum of bootable CentOS 7.5.1804 thumb drive.

Post by Spork Schivago » 2018/10/14 23:26:21

When I run sha256sum directly on /dev/sdc, I receive a different value. But why? I bet if I ran dd if=/dev/sdc of=./test.img bs=4096 and then ran sha256sum on that test.img file, it'd be the same as the original CentOS 7.5.1804 image's checksum.

Why must I pipe dd's output to sha256sum and not simply be able to run sha256sum on /dev/sdc? Oh! I think I know exactly why. It's because the thumb drive is physically larger than the image. sha256sum is calculating the entire image of the thumb drive, not just the CentOS 7 parts. And that means, if I'm right here, I was wrong when I said I bet if I ran dd if=/dev/sdc of=./test.img bs=4096. It's because I'd be creating an image of the entire thumb drive, not just reading out the CentOS 7 parts. So instead of a ~4.2GB file, I'd have more like a ~29GB file.
-- Niklaus Wirth's Law: software is getting slower more rapidly than hardware becomes faster.

User avatar
TrevorH
Site Admin
Posts: 33219
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Troubles attempting to verify sha256sum of bootable CentOS 7.5.1804 thumb drive.

Post by TrevorH » 2018/10/14 23:30:39

The sha256sum is of the data in the image file. If you write that image file to a larger stick and then sha256sum the stick, you'll be including all the data between the end of the image file and the end of the USB stick that was never written to and should not be part of the calculation. The correct way to verify the data on the stick is either to confine the sha256sum to the size of the image file or to read back just that size and write it to a file on disk and sha256sum that file.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

hunter86_bg
Posts: 2019
Joined: 2015/02/17 15:14:33
Location: Bulgaria
Contact:

Re: Troubles attempting to verify sha256sum of bootable CentOS 7.5.1804 thumb drive.

Post by hunter86_bg » 2018/10/15 14:44:22

I guess you can boot the USB and run the test from itself. If the checker reports issues - then there is a high chance that the USB is NOT OK

Post Reply