limepepper/raspberry-pi-factory-reset

Recover image hangs on "random crng init done" on boot

Closed this issue · 22 comments

Hi! I used the script on a custom 2021-05-07-raspios-buster-armhf-lite.img that has been already preshrunk by pyshrink.

After i flashed the recovery image onto the sd card (32 gb) and booted my pi hangs on one of the boot screens last steps:
"random crng init done".

My thoughts: this might have to do with the cmdline.txt being edited, any idea what a proper one should look like to work for this? OR has anyone seen this error with this script before?

Also unrelated i run this script on my pi itself with the img put in the root folder. Not sure if that's how you guys do it.
Thanks!

Note: using custom wpa_Supplicant settings, scripts, ssh configs, etc... that's why i need to use a custom image. Also used pishrink to shrink sd card from 30 gb to 4 gb.

Generally I've only tested the script when using vanilla (i.e. not resized and not booted in an actual rPi) images. The "random crng init done" generally means it wasn't able to mount the root partition.

If you mount the sdcard and paste you current /boot/cmdline.txt /etc/fstab and also the output of blkid /dev/sdX*, it might indicate where the problem is.

I've noticed that resizing and shrinking tools seem to reset the UUID of the root partition (and possibly the PARTUUID) but I've not really used these tools much myself, so I'd need to see what the output is to help much

hm so would it be better to never use pishrink on an image if you want a custom image but still disable resizing via cmdline.txt to allow for space in a sd card? From your intuition is this problem fixable via cmdline.txt manipulation or is it a lost cause?

err. it might be something simple (or not). I would be able to tell from the output of those files.

my cmdline.txt:
console=serial0,115200 console=tty1 root=PARTUUID=d3a978f4-03 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait init=/usr/lib/raspi-config/init_resize.sh
My .fstab (not fstab) file inside the rootfs partition (let me know if you need recover partition files):

proc            /proc           proc    defaults          0       0

PARTUUID=31d0c512-01  /boot           vfat    defaults          0       2

PARTUUID=31d0c512-02  /               ext4    defaults,noatime  0       1

Blkid of /dev/sdX* I'm still working on getting since i'm not sure how to find that if the pi can't boot up and i can't ssh into it? can't find it with a file explorer either, any ideas?

my fstab file not .fstab:

proc                                       /proc  proc  defaults          0  0
UUID=DC3E-E470                             /boot  vfat  defaults          0  2
UUID=4b990a43-aa3f-4386-948c-4b935f153cc5  /      ext4  defaults,noatime  0  1

so my first observation is that the PARTUUID is inconsistent between the /boot/cmdline.txt and the /etc/fstab

So I have a sdcard in an sdard slot on my fedora box and it shows this:

# blkid  /dev/sde*
/dev/sde: PTUUID="436be1e9" PTTYPE="dos"
/dev/sde1: LABEL_FATBOOT="boot" LABEL="boot" UUID="5DE4-665C" BLOCK_SIZE="512" TYPE="vfat" PARTUUID="436be1e9-01"
/dev/sde2: LABEL="recoveryfs" UUID="def8f4fb-afc3-4cc8-b465-e8f56d0ea65c" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="436be1e9-02"
/dev/sde3: LABEL="rootfs" UUID="1c92521c-4882-4f09-ac33-fb0a12086a7e" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="436be1e9-03"

Interesting, i'm going to make by partuuid PARTUUID=d3a978f4-03 (from cmdline.txt) for both files and report back if it works!

if that doesn't work, try setting 31d0c512-03 in both /etc/fstab and /boot/cmdline.txt

if that doesn't work, try setting 31d0c512-03 in both /etc/fstab and /boot/cmdline.txt

still trying to figure out how to edit my fstab file from windows in my sdcard. (the cmdline edit was easier). in the meantime are these the only 2 places for PARTUUID that the script edits? and why -03? is this a type or do you actually want me to put in -03? for both partuuid in fstab or append it on? (sorry for so many dumb questions, im very new to sd card partuuid stuff and it requires a lot of small details) thank you for being patient with me in the meantime

also sorry for the inconvenience but mind if i see what your fstab contents look like for a comparison?

another note: did some digging into my cmdline.recovery (since i figured pishrink might've affected this) and came across this:
console=serial0,115200 console=tty1 root=PARTUUID=XXXYYYXXX rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quiet init=/usr/lib/raspi-config/init_restore.sh
(notice how it goes to init_restore.sh rather than init_resize.sh in my current cmdline.txt any thoughts on that?
my cmd_line_txt from pristine is this:
console=serial0,115200 console=tty1 root=PARTUUID=31d0c512-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait
(note it uses the -02 one)

Ah, ok, I think I might see a problem

/etc/fstab from source image
proc                  /proc  proc  defaults          0  0
PARTUUID=9730496b-01  /boot  vfat  defaults          0  2
PARTUUID=9730496b-02  /      ext4  defaults,noatime  0  1

/etc/fstab for root partition
proc                                       /proc  proc  defaults          0  0
UUID=5DE4-665C                             /boot  vfat  defaults          0  2
UUID=1c92521c-4882-4f09-ac33-fb0a12086a7e  /      ext4  defaults,noatime  0  1

basically the script was originally based off how raspbian did the UUID and/or PARTUUID back in 2018, and I think they have changed it since. The problem occurs that now its using PARTUUID in /etc/fstab rather than what it previously used, i.e. UUID and this probably confuses things (when resizer is run)

I think the script needs a change to use whatever id type the image is using

i see. so more or less can either change it all to the new way of partuuid (which is what it is now i assume and not working) or somehow find my original img's uuid and change my fstab file and cmdline.txt to that?

Your fstab seems to use partuuid just fine if not nearly identical to mine.
i bet our cmdline.txts are pretty much the same too?

so i'm a little confused as to how to implement the correct way?

if you are open to a discord call so i can pick your knowledge on these partuuid/uuid tips and tricks for 10 minutes. if not i totally understand! and am very appreciative of all the help so far!

this is my fstab file not my .fstab file: Im sorry all the above examples were my .fstabs.

proc                                       /proc  proc  defaults          0  0
UUID=DC3E-E470                             /boot  vfat  defaults          0  2
UUID=4b990a43-aa3f-4386-948c-4b935f153cc5  /      ext4  defaults,noatime  0  1

I pushed a bunch of changes to better handle UUID vs PARTUUID, i.e. now it just uses whatever was provided by the image (or set by an intermediate resizing tool) If you checkout the latest script and try again, you might have more luck.

If you are still having problems, please add details of exactly what steps you took, including what tools were used, and what OS was used to run them, and I'll try and replicate the issue.

I pushed a bunch of changes to better handle UUID vs PARTUUID, i.e. now it just uses whatever was provided by the image (or set by an intermediate resizing tool) If you checkout the latest script and try again, you might have more luck.

If you are still having problems, please add details of exactly what steps you took, including what tools were used, and what OS was used to run them, and I'll try and replicate the issue.

Thank you so much for that!!!! i tried to make some of my own changes last night to the script and tested it and it failed haha. Will give this a try right now and let you know if it works!

sadly same error, will post updates after digging into it more after work. Any files or outputs you want me to post for any guesses on what may be causing it? i ran the script. got the restore image. transferred it onto my pc, and then wiped the sd card clean and installed the restore image on it and booted. still stuck same error :/

where are you building the image? (i.e. what OS where you run the script)

where are you building the image? (i.e. what OS where you run the script)

I run it on the pi os directly, i transfer the image to the correct folder via filezilla then run the script. After it generates the .recover image i transfer it back to my pc via filezilla, wipe the sd, then install the restore image and try to boot. I hope i'm doing it right? do you run it not via pi?

ok! I've never tried it actually on a pi before, and now I did I see a problem...

run from fedora (or ubuntu) it's correct:

/etc/fstab for root partition
proc                  /proc  proc  defaults          0  0
PARTUUID=efbd6bd4-01  /boot  vfat  defaults          0  2
PARTUUID=efbd6bd4-03  /      ext4  defaults,noatime  0  1

/boot/cmdline.txt for restore image
console=serial0,115200 console=tty1 *root=PARTUUID=efbd6bd4-03* rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quiet init=/usr/lib/raspi-config/init_resize.sh splash plymouth.ignore-serial-consoles

BUT when built on the raspberry Pi, its wrong

/etc/fstab for root partition
proc                  /proc  proc  defaults          0  0
PARTUUID=4ec79441-01  /boot  vfat  defaults          0  2
PARTUUID=4ec79441-03  /      ext4  defaults,noatime  0  1

doesn't match the cmdline.txt:

/boot/cmdline.txt for restore image
console=serial0,115200 console=tty1 root=PARTUUID=90f2d126-03 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quiet init=/usr/lib/raspi-config/init_resize.sh

no idea why that would happen, I'm looking into it.... will report back

OK, I fixed a problem that happened only on rPi builds, so if you get a chance, can you pull the changes and try again. Thanks

the basic idea is that at the end of the build, these 3 values (that I have underlined in red), are all the same

2021-10-14_07-44

I built that on a raspberry pi

root@raspberrypi-00008:~/git/raspberry-pi-factory-reset# cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

burned it to an sdcard and booted it, and was able to successfully boot it, and factory reset the image

20211014_075009

OK, I fixed a problem that happened only on rPi builds, so if you get a chance, can you pull the changes and try again. Thanks

the basic idea is that at the end of the build, these 3 values (that I have underlined in red), are all the same

2021-10-14_07-44

I built that on a raspberry pi

root@raspberrypi-00008:~/git/raspberry-pi-factory-reset# cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

burned it to an sdcard and booted it, and was able to successfully boot it, and factory reset the image

20211014_075009

IT WORKS!!!! THANK YOU SO MUCH. I've been stuck on this problem for weeks before reaching out to you, many sleepless nights. Couldn't thank you enough for taking the time to help push code and help find a solution. Thank you!!!!!!!!!!!