-2

I have a working SD card which I want to back up to an .img file and be able to quickly replicate.

I'm using dd to copy my image to my sd card:

dd if=raspbian.img of=/dev/sdc bs=4M

Which executes successfully. When I inspect the contents of the sd card afterwards everything seems ok, boot partition contains all necessary files etc..

When I try to boot I get the rainbow screen after which it starts the boot process, I assume, and it gets stuck at

sh: can't access tty; job control turned off

Nothing seems to be wrong with the original card, it works every time, so I spent about 5 hours trying to figure out what the issue was, reading through countless posts on here containing the same error which were all unrelated. I finally figured it out, I'm posting this in case I can save someone else's time in future.

1
  • Why the f did whoever downvote this question?
    – php_nub_qq
    Commented Oct 29, 2021 at 13:28

1 Answer 1

1

It spent a lot of time looking at the image contents and all kinds of errors related to the header pins being shorted, modifying cmdline.txt and config.txt and more...

In the end the error turned out to be the way I was generating the image. Since my SD card is 32GB and I definitely don't want a 32GB image, I did some calculation to extract just about what my filesystem size was, off of the original card, using the count parameter on the dd command. My calculation was a bit off and my image ended up being ~100MB smaller than the content of the SD card. I don't know how that lead to the error I was experiencing as I believe that would have been ~100MB short off the rootfs partition, but apparently it affected it in some way. After generating a proper img file, slightly bigger than my contents' size, everything works as expected.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.