Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: cli sha256sum error when running as non-root user #974

Open
1 task done
sunetfreitag opened this issue Dec 5, 2024 · 1 comment
Open
1 task done

[BUG]: cli sha256sum error when running as non-root user #974

sunetfreitag opened this issue Dec 5, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@sunetfreitag
Copy link

What happened?

I have a script to prepare SD cards with a base RaspiOS Lite: https://github.com/freitaglab/BerryMetre/blob/main/BerryPiGateway/prepareimage.sh

This script fails (reproducibly for me) when running as a regular user with an error message: "Download corrupt. Hash does not match".

The relevant command is a variation of
./Raspberry_Pi_Imager-1.9.0-x86_64.AppImage --debug --cli --sha256 f4954098468cab0a875a17259c7c23740485dbf8ecd87bd1969bf2eb37ca8cb3 --first-run-script firstrun.sh 2024-10-22-raspios-bookworm-arm64-lite.img.xz /dev/sda

The imager fails for me under the following circumstances:

  • Running as regular user being prompted for the user password
  • In version 1.8.5, 1.9.0 on Arch, 1.9.0 AppImage
  • On three different computers (2 running Arch, 1 running Ubuntu 24.0.1 LTS)
  • Using different SD card readers (Lexar, Benfei, Levin)
  • Using different SD cards (Sandisk, Kingston Industrial, Transcend Industrial)
  • Without specifying the first-run-script
  • Using either a compressed or uncompressed OS image file

The Imager reports the same wrong hashes on different computers, but the wrong hashes are always the same for the same base image. Running sha256sum on the compressed image calculates the correct sha256. Uncompressing the image manually and running sha256sum manually on the uncompressed image calculates the correct sha256.

The imager succeeds for me:

  • Running the imager as root or with sudo
  • Running the imager without the --sha256
  • Running the imager using the latest Ubuntu booted from USB (only clicking "Authorize" without having to enter a password)

Version

1.9.0

What host operating system were you using?

Debian and derivatives (eg Ubuntu)

Host OS Version

Ubuntu 24.04.1

Selected OS

Raspberry Pi OS Bookworm lite

Which Raspberry Pi Device are you using?

Raspberry Pi 4B, 400, and Compute Modules 4, 4S

What kind of storage device are you using?

microSD Card in a USB reader

OS Customisation

  • Yes, I was using OS Customisation when the bug occurred.

Relevant log output

=== Logs for 2024-07-04-raspios-bookworm-arm64-lite.img.xz ===
Cloudinit: ""
Parsed .xz file. Uncompressed size: 2835349504
Unmounting: "/dev/sdb"
BLKDISCARD not supported                  
Zeroing out first and last MB of drive
Done zeroing out start and end of drive. Took 0 seconds
Image is NOT a valid disk image, as its length is not a multiple of the sector size of 512 bytes long
Last write() would be 793804 bytes, but padding to 794112 bytes
Hash of uncompressed image: "32e1d0656856e4ffe2342cfbff4e40dcf07979ad00bc8f1e8b07a663722689aa"
Mismatch with expected hash: "2746d9ff409c34de471f615a94a3f15917dca9829ddbc7a9528f019e97dc4f03"
Error: Download corrupt. Hash does not match

=== Logs for 2024-10-22-raspios-bookworm-arm64-lite.img.xz ===
Cloudinit: ""
Parsed .xz file. Uncompressed size: 2864709632
Unmounting: "/dev/sdb"
BLKDISCARD not supported                  
Zeroing out first and last MB of drive
Done zeroing out start and end of drive. Took 0 seconds
Image is NOT a valid disk image, as its length is not a multiple of the sector size of 512 bytes long
Last write() would be 656060 bytes, but padding to 656384 bytes
Hash of uncompressed image: "f7d1867e15f517ee916005acf70b3ca9b813a890b55e515516612377f16b138a"
Mismatch with expected hash: "f4954098468cab0a875a17259c7c23740485dbf8ecd87bd1969bf2eb37ca8cb3"
Error: Download corrupt. Hash does not match
@sunetfreitag sunetfreitag added the bug Something isn't working label Dec 5, 2024
@sunetfreitag
Copy link
Author

I am quite sure by now that it is related to the local cache as it only happens when preparing a second SD card. Removing the lastdownload.cache file before the second run of the imager resolves the problem.

Interestingly enough, the sha256sum of the file lastdownload.cache is the same as reported by the imager.

In ~/.cache/Raspberry Pi/Imager

sha256sum lastdownload.cache 
e22fa77cdc91b465614de2d0caed6cf9e0170cbf674d627c0ce0e78ddd0693ed  lastdownload.cache

Debug output of imager on second run

Done zeroing out start and end of drive. Took 0 seconds
Hash of uncompressed image: "e22fa77cdc91b465614de2d0caed6cf9e0170cbf674d627c0ce0e78ddd0693ed"
Mismatch with expected hash: "2746d9ff409c34de471f615a94a3f15917dca9829ddbc7a9528f019e97dc4f03"
Error: Download corrupt. Hash does not match

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant