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

Make boot mount-point configurable #195

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

waveform80
Copy link
Member

On RaspiOS (and many derivatives) the boot mount-point is always /boot.
However on Ubuntu (and Debian), it is /boot/firmware (/boot is still the
target for kernel installation and initramfs generation, but
flash-kernel then copies files from there to /boot/firmware). This patch
changes references to /boot to $BOOT to make it easier to configure the
boot mount-point.

Please note that in the overlayfs routines, the location of the
generated initramfs is deliberately left as /boot (as this is always
correct even when the boot partition is not mounted there).

On RaspiOS (and many derivatives) the boot mount-point is always /boot.
However on Ubuntu (and Debian), it is /boot/firmware (/boot is still the
target for kernel installation and initramfs generation, but
flash-kernel then copies files from there to /boot/firmware). This patch
changes references to /boot to $BOOT to make it easier to configure the
boot mount-point.

Please note that in the overlayfs routines, the location of the
generated initramfs is deliberately left as /boot (as this is always
correct even when the boot partition is *not* mounted there).
@XECDesign
Copy link
Member

Not sure I follow how this is meant to work. It's still a hardcoded path that will get over-written any time the package is updated.

Would something like BOOT=${BOOT:-/boot} make more sense?

Or is this just to simplify a patch for another distro?

@waveform80
Copy link
Member Author

I'd be happy to update the patch to use a default, but yes you are correct that this is largely to ease patching raspi-config to run on Ubuntu (and potentially other variants relying on flash-kernel where the boot partition gets mounted under /boot/firmware).

A bit of context: raspi-config got added (rather carelessly) to the Ubuntu archive back in impish (21.10) and, as it's looking at /boot rather than /boot/firmware it mostly doesn't work. I'm currently trying to get it into a semi-working state but the delta is already looking ... daunting, so this is part of my attempt to minimize that and make Future-Dave's life a bit easier!

@timg236
Copy link

timg236 commented Jul 1, 2022

How about updating raspi-config to source something under /etc/defaults (if present) to set the default environment parameters (BOOT)?

@XECDesign
Copy link
Member

raspi-config is very Raspberry Pi OS specific and is not the cleanest of scripts. If I was working on another distro, I'd start from scratch.

But yeah, if it makes things easier, I'm okay with merging it as is.

We could use something like /etc/defaults/raspi-config, but that's generally intended for changing the behaviour of init scripts and doesn't seem necessary here.

@timg236
Copy link

timg236 commented Jul 1, 2022

raspi-config is very Raspberry Pi OS specific and is not the cleanest of scripts. If I was working on another distro, I'd start from scratch.

But yeah, if it makes things easier, I'm okay with merging it as is.

We could use something like /etc/defaults/raspi-config, but that's generally intended for changing the behaviour of init scripts and doesn't seem necessary here.

Ok. Btw, rpi-eeprom-update also needs to know where the BOOT mount is so that it can write recovery.bin to the write place. If there's a system wide setting for this then we can point rpi-eeprom-update at it as well.

@waveform80
Copy link
Member Author

How about updating raspi-config to source something under /etc/defaults (if present) to set the default environment parameters (BOOT)?

It's an interesting idea; off the top of my head we already patch rpi-eeprom, specifically its /etc/default/rpi-eeprom-update file so that its BOOTFS var points at /boot/firmware (I suppose it could just source that although that then introduces a dependency between the two).

raspi-config is very Raspberry Pi OS specific and is not the cleanest of scripts. If I was working on another distro, I'd start from scratch.

Indeed -- that task's been on my "would be nice if I ever had the time" list for ... too long! Unfortunately it appears others got impatient and just imported raspi-config more or less verbatim into the Ubuntu archive. Given it's there now, I may as well spend a couple of days making as much of it work (or at least not break stuff) as I reasonably can.

(As an example of potential for breakage, I discovered while working through it that the current overlay handling would render an Ubuntu system unbootable when disabling it. The function assumes that it can remove the initramfs line from config.txt -- a completely reasonable assumption under RaspiOS, but less so under Ubuntu :-)

But yeah, if it makes things easier, I'm okay with merging it as is.

Thanks!

@@ -2611,21 +2612,21 @@ EOF
update-initramfs -c -k "$KERN"

# rename it so we know it has overlay added
mv /boot/initrd.img-"$KERN" /boot/"$INITRD"
mv /boot/initrd.img-"$KERN" "$BOOT"/"$INITRD"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry about the delay

I'm guessing the /boot on this particular line is expected because update-initramfs will always write to /boot?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw: When patching cmdline.txt (after init_resize) scripts should really check the overlay_prefix parameter from /proc/device-tree/chosen should be checked.

https://www.raspberrypi.com/documentation/computers/configuration.html#part4

Otherwise, it's possible that the wrong cmdline.txt will be patched

Copy link
Member

@XECDesign XECDesign Nov 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check the overlay_prefix parameter from /proc/device-tree/chosen should be checked.

overlay_prefix or os_prefix?

Also, wouldn't the whole mechanism be broken on Pi OS, which assumes that /boot is THE place where everything is?

In either case, I think that one is for @spl237, since the overlayfs parts of raspi-config are his.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I've now spent ten minutes scratching my head about this...

What does the overlay_prefix parameter from /proc/device-tree (which is used for loading kernel overlays) have to do with patching cmdline.txt (which is used for adding a file system overlay)? Are those things not completely different, with the only common factor being the word "overlay"? Or am I missing something?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I mean os_prefix

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Now fixed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Now fixed.

I'm pretty sure it only breaks things. All the related packages install files to /boot and it's hardcoded all over the place (which is reasonable).

If things are instead in a subdirectory, nothing is going to work. The system should be set up to bind /boot to the appropriate subdirectory instead.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it is now in a global variable in raspi-config which is used instead of /boot/cmdline.txt throughout. So if it does break things, it's trivial to remove - just hard-code PREFIX to an empty string on line 24.

I've got no idea what this breaks or doesn't break - I just do what I'm told... ;)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had a chat with Tim and yeah, it breaks things, but not in the context os_prefix is expected to be used in. I'll move it to public and get this PR sorted when I've got a spare moment.

Thanks

@lurch
Copy link

lurch commented Oct 13, 2023

I guess this can be closed, now that Bookworm has been released? (5dbaf53 seems to be the relevant commit)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants