MikeCoder
Posts: 78
Joined: Fri Jan 24, 2020 12:05 am

[Question] How does RPI OS deal with volume IDs and fstab?

Wed Jun 09, 2021 12:49 am

Hello!

I'm making an RPI OS mod OS with an among us-like theme. I've noticed that a lot of users report a blank cursor on boot, which I believe is most likely a mismatch between the volume ID and the IDs specified in /etc/fstab. I was wondering how the RPI OS devs resolve this issue on first boot so I can apply it to my OS.

RonR
Posts: 2260
Joined: Tue Apr 12, 2016 10:29 pm
Location: US

Re: [Question] How does RPI OS deal with volume IDs and fstab?

Wed Jun 09, 2021 3:11 am

A virgin Raspberry Pi OS image has a cmdline.txt in its boot partition that contains 'init=/usr/lib/raspi-config/init_resize.sh'.

On the first run, in addition to resizng the root partition to use all available space, init_resize.sh generates a random 8-digit hex value which becomes the new PTUUID using fdisk. cmdline.txt and fstab are then updated with this PTUUID. These actions occur in the fix_partuuid() function.

'init=/usr/lib/raspi-config/init_resize.sh' is removed from cmdline.txt and the system reboots.


MikeCoder
Posts: 78
Joined: Fri Jan 24, 2020 12:05 am

Re: [Question] How does RPI OS deal with volume IDs and fstab?

Wed Jun 09, 2021 10:27 pm

BTW are there any other potential causes for blinking cursor, even if I know the image itself boots on my system but not others?

RonR
Posts: 2260
Joined: Tue Apr 12, 2016 10:29 pm
Location: US

Re: [Question] How does RPI OS deal with volume IDs and fstab?

Thu Jun 10, 2021 12:26 am

MikeCoder wrote:
Wed Jun 09, 2021 10:27 pm
BTW are there any other potential causes for blinking cursor, even if I know the image itself boots on my system but not others?

Do the other systems boot and run properly with a virgin Raspberry Pi OS image?

What changes did you make to a virgin Raspberry Pi OS image that caused it not to boot and run properly on the other systems?

swampdog
Posts: 721
Joined: Fri Dec 04, 2015 11:22 am

Re: [Question] How does RPI OS deal with volume IDs and fstab?

Thu Jun 10, 2021 2:23 pm

The first ever start for the GUI can take a while (device speed / network / extra services) so it can be sat with a blank flashing cursor top-left for tens of seconds.

I tend to remove "quiet" and "splash" from /boot/cmdline.txt for that reason when writing a non-custom image. I also enable serial for headless debugging. Even though I might create a third partition (in the middle) I decided to leave in init_resize.sh figuring I've no control over what else it does: seems from RonR's PTUUID comment this was a good thing. I also enable /etc/rc.local to hack in runtime changes at first boot (though a service would be better).

MikeCoder
Posts: 78
Joined: Fri Jan 24, 2020 12:05 am

Re: [Question] How does RPI OS deal with volume IDs and fstab?

Sun Jun 13, 2021 5:02 pm

swampdog wrote:
Thu Jun 10, 2021 2:23 pm
The first ever start for the GUI can take a while (device speed / network / extra services) so it can be sat with a blank flashing cursor top-left for tens of seconds.

I tend to remove "quiet" and "splash" from /boot/cmdline.txt for that reason when writing a non-custom image. I also enable serial for headless debugging. Even though I might create a third partition (in the middle) I decided to leave in init_resize.sh figuring I've no control over what else it does: seems from RonR's PTUUID comment this was a good thing. I also enable /etc/rc.local to hack in runtime changes at first boot (though a service would be better).
What runtime changes?

swampdog
Posts: 721
Joined: Fri Dec 04, 2015 11:22 am

Re: [Question] How does RPI OS deal with volume IDs and fstab?

Sun Jun 13, 2021 6:28 pm

One thing my custom rpi images do is enable ssh and copy in my /etc/wpa_supplicant/wpa_supplicant.conf

Before I boot the image I'll have created a folder "/wrk/" (chmod=01777) in which I'll have put the various scripts that /etc/rc.local needs plus any packages that rpi might need, NoMachine for instance.

On first boot /etc/rc.local does this..
I create a new user "foo" which can "sudo" without a password, create a complex password for "root", ditto "pi" and lock the "pi" account. More fundamentally, I swap the uid/gid of "foo" and "pi" because it just so happens my primary NFS server(s) use uid=1000/gid=1000,username=foo. I tend to also set the same complex password for "foo" and "pi" - doesn't matter with "lite" but an rpi with GUI might prompt for "pi" password (need to unlock "pi" a/c again). This isn't a great hassle because my desktop PC "foo" a/c ssh public key (id_rsa.pub) gets written to the rpi image and I tend to have GUI linux images boot straight to desktop. Consequently I rarely have to type passwords. The ssh options "-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" are enough to bypass the initial login prompts when scripting.

..subsequently /etc/rc.local does nothing but quit. It was supposed to verify the first run but it was too much hassle: most failures tend to be down to a bad sdcard image.

Another thing the first run does is install a custom mailer (https://github.com/muquit/mailsend) into "/usr/local/sd/" along with a load of other stuff common to my environment - "foo" user has "$HOME/bin" and "/usr/local/sd/bin" in its PATH from its modified ".bash_profile" (I also mod /etc/bash.bashrc). The custom mailer is platform agnostic so there's a script 'sd-mail' which fudges things so it looks enough like 'mailsend' to work. A successful first boot will result in me getting a mail from that rpi telling me it's name and ip address. "foo" also gets a crontab which at leaat contains this..

Code: Select all

foo@pi18:~ $ crontab -l
PATH=/usr/local/sd/bin:$HOME/bin:/bin:/usr/bin
#------------------------------------------------------------------------------
#min	hrs	dom	mon	dow	/path/to/cj
#------------------------------------------------------------------------------
02	08	*	*	*	cjx dfh
#------------------------------------------------------------------------------
..which effectively mails "df -hP" daily. 'dfh' is a script which emits a modified tidy looking "df -hP" (some of these rpi have LVM running) and 'cjx' ensures the crontab environment is correct to run scripts same as typed from command line - and mails output using above mailer.

Currently this is all done via what has become a very hacky script..

Code: Select all

$ ./go sdd ./2021-05-07-raspios-buster-armhf-lite.zip pi99
..would write that image to /dev/sdd and name the rpi "pi99". After it's booted and I get the mail..

Code: Select all

$ ./go --post pi99
..uses 'ssh' to update/upgrade the rpi and can be used for custom stuff. Reboot and the rpi is ready.

The idea is hitting its limits though. It's a pain updating anything associated with the first run because that's not automated. Worse, I do the above by mounting /dev/sdX once the zip image is written. Big snag is the rpi rootfs is unexpanded so there's a limit on what can be stuffed in there. I haven't written anything to grow the rootfs a bit because there's too many disks on my PC - the danger of accidentally stuffing a PC disk is too great especially when you consider the penchant usb disks have to keep changing their /dev/sdX!

So next iteration is going to use QEMU. I'm going to use 'qemu-img' to create a raw device. I can muck that up in testing as much as I like. I'll only need to "sudo dd" after it's cooked iyswim. It'll also be more flexible in that I can shove one or more partitions between the fat32 and rootfs.

MikeCoder
Posts: 78
Joined: Fri Jan 24, 2020 12:05 am

Re: [Question] How does RPI OS deal with volume IDs and fstab?

Tue Jun 15, 2021 4:21 pm

RonR wrote:
Thu Jun 10, 2021 12:26 am
MikeCoder wrote:
Wed Jun 09, 2021 10:27 pm
BTW are there any other potential causes for blinking cursor, even if I know the image itself boots on my system but not others?

Do the other systems boot and run properly with a virgin Raspberry Pi OS image?

What changes did you make to a virgin Raspberry Pi OS image that caused it not to boot and run properly on the other systems?
Other systems boot properly with RPI OS but not my OS. The only change that might affect boot would be a 64-bit kernel pre-enabled, so I can get a better memory split for some preinstalled apps to run better.

RonR
Posts: 2260
Joined: Tue Apr 12, 2016 10:29 pm
Location: US

Re: [Question] How does RPI OS deal with volume IDs and fstab?

Tue Jun 15, 2021 6:13 pm

MikeCoder wrote:
Tue Jun 15, 2021 4:21 pm
RonR wrote:
Thu Jun 10, 2021 12:26 am
MikeCoder wrote:
Wed Jun 09, 2021 10:27 pm
BTW are there any other potential causes for blinking cursor, even if I know the image itself boots on my system but not others?

Do the other systems boot and run properly with a virgin Raspberry Pi OS image?

What changes did you make to a virgin Raspberry Pi OS image that caused it not to boot and run properly on the other systems?
Other systems boot properly with RPI OS but not my OS. The only change that might affect boot would be a 64-bit kernel pre-enabled, so I can get a better memory split for some preinstalled apps to run better.

Are you saying that you start with the latest Raspberry Pi OS image (2021-05-07-raspios-buster-armhf.img) and the ONLY change you make to it is to add 'arm_64bit=1' to /boot/config.txt and this causes it not to boot on some Raspberry Pi's?

MikeCoder
Posts: 78
Joined: Fri Jan 24, 2020 12:05 am

Re: [Question] How does RPI OS deal with volume IDs and fstab?

Wed Jun 16, 2021 11:14 pm

I've also done stuff like theming and such to it, but that shouldn't affect the OS itself right? And uh also... I might have set GPU memory to 512 mb?

RonR
Posts: 2260
Joined: Tue Apr 12, 2016 10:29 pm
Location: US

Re: [Question] How does RPI OS deal with volume IDs and fstab?

Wed Jun 16, 2021 11:43 pm

MikeCoder wrote:
Wed Jun 16, 2021 11:14 pm
I've also done stuff like theming and such to it, but that shouldn't affect the OS itself right? And uh also... I might have set GPU memory to 512 mb?

It's very difficult to speculate what the problem might be not knowing the changes you've made and the environment where the failures occur.

If you're using to the 64-bit kernel, then the result will only run on a Raspberry 4, 3, and 2 (v1.2).

Your best best is to start with an umodified Raspberry Pi OS and add in your changes one or two at time and verify that it still runs on all devices. Sooner or later, you'll determine what the culprit is.

MikeCoder
Posts: 78
Joined: Fri Jan 24, 2020 12:05 am

Re: [Question] How does RPI OS deal with volume IDs and fstab?

Thu Jun 17, 2021 2:42 am

RonR wrote:
Wed Jun 16, 2021 11:43 pm
MikeCoder wrote:
Wed Jun 16, 2021 11:14 pm
I've also done stuff like theming and such to it, but that shouldn't affect the OS itself right? And uh also... I might have set GPU memory to 512 mb?

It's very difficult to speculate what the problem might be not knowing the changes you've made and the environment where the failures occur.

If you're using to the 64-bit kernel, then the result will only run on a Raspberry 4, 3, and 2 (v1.2).

Your best best is to start with an umodified Raspberry Pi OS and add in your changes one or two at time and verify that it still runs on all devices. Sooner or later, you'll determine what the culprit is.
The OS is available at https://github.com/jostroOS/amogOS/rele ... Sv1.3.2.xz if you'd like to give it a shot, but I'll try to change stuff in cmdline.txt and add bits and stuff to see if it'll fix it with the help of some friends.

RonR
Posts: 2260
Joined: Tue Apr 12, 2016 10:29 pm
Location: US

Re: [Question] How does RPI OS deal with volume IDs and fstab?

Thu Jun 17, 2021 4:13 am

MikeCoder wrote:
Thu Jun 17, 2021 2:42 am
The OS is available at https://github.com/jostroOS/amogOS/rele ... Sv1.3.2.xz if you'd like to give it a shot, but I'll try to change stuff in cmdline.txt and add bits and stuff to see if it'll fix it with the help of some friends.

At first glance, there are two major problems with your image file which prevents it from booting:

1. The image file has a PTUUID of 4ce2c88d, but your cmdline.txt and fstab files reference 3455c31b. Use the correct PTUUID in both files.

2. You've replaced /etc/rc.local with a bunch of raspi-config resizing code that's not needed and only causes problems. Delete the existing rc.local and rename rc.local.bak to rc.local.


These changes allow the image to boot. I attempted to poke around a little from a terminal window, but it's terribly unstable, so I gave up.

If you want a 64-bit kernel, build on the Raspberry Pi OS 64-bit image:

https://downloads.raspberrypi.org/raspi ... -arm64.zip

MikeCoder
Posts: 78
Joined: Fri Jan 24, 2020 12:05 am

Re: [Question] How does RPI OS deal with volume IDs and fstab?

Fri Jun 18, 2021 2:07 am

RonR wrote:
Thu Jun 17, 2021 4:13 am
MikeCoder wrote:
Thu Jun 17, 2021 2:42 am
The OS is available at https://github.com/jostroOS/amogOS/rele ... Sv1.3.2.xz if you'd like to give it a shot, but I'll try to change stuff in cmdline.txt and add bits and stuff to see if it'll fix it with the help of some friends.

At first glance, there are two major problems with your image file which prevents it from booting:

1. The image file has a PTUUID of 4ce2c88d, but your cmdline.txt and fstab files reference 3455c31b. Use the correct PTUUID in both files.

2. You've replaced /etc/rc.local with a bunch of raspi-config resizing code that's not needed and only causes problems. Delete the existing rc.local and rename rc.local.bak to rc.local.


These changes allow the image to boot. I attempted to poke around a little from a terminal window, but it's terribly unstable, so I gave up.

If you want a 64-bit kernel, build on the Raspberry Pi OS 64-bit image:

https://downloads.raspberrypi.org/raspi ... -arm64.zip
/etc/rc.local looks the same as a vanilla one... but I replaced it anyways. I have no idea how the partition uuids work. Here's a new one I made: https://drive.google.com/file/d/1mxIgN7 ... sp=sharing

RonR
Posts: 2260
Joined: Tue Apr 12, 2016 10:29 pm
Location: US

Re: [Question] How does RPI OS deal with volume IDs and fstab?

Fri Jun 18, 2021 3:28 am

MikeCoder wrote:
Fri Jun 18, 2021 2:07 am
Here's a new one I made: https://drive.google.com/file/d/1mxIgN7 ... sp=sharing

This is a radically different image from the previous one (11 GB vs 7 GB). cmdline.txt and fstab have the proper values for PARTUUID and rc.local is the virgin copy.

This image file boots and appears to run correctly, but I wasn't able to find a shutdown/reboot option anywhere (I finally resorted to 'halt' in a terminal window). The terminal window now appears to be stable.

MikeCoder
Posts: 78
Joined: Fri Jan 24, 2020 12:05 am

Re: [Question] How does RPI OS deal with volume IDs and fstab?

Fri Jun 18, 2021 7:14 pm

RonR wrote:
Fri Jun 18, 2021 3:28 am
MikeCoder wrote:
Fri Jun 18, 2021 2:07 am
Here's a new one I made: https://drive.google.com/file/d/1mxIgN7 ... sp=sharing

This is a radically different image from the previous one (11 GB vs 7 GB). cmdline.txt and fstab have the proper values for PARTUUID and rc.local is the virgin copy.

This image file boots and appears to run correctly, but I wasn't able to find a shutdown/reboot option anywhere (I finally resorted to 'halt' in a terminal window). The terminal window now appears to be stable.
Oh lol, this was fresh off image-utils so I didn't bother with pishrink, but it looks like it's working! The power off button is in the top-right. Thanks so much for your help!

Return to “Raspberry Pi OS”