bablokb / pi-boot-switch

Boot-Switcher for Raspberry Pi multiboot systems
GNU General Public License v3.0
23 stars 6 forks source link

Error on Debian bookworm: role[$currentBoot]: bad array subscript #6

Open wolkenarchitekt opened 1 year ago

wolkenarchitekt commented 1 year ago

Using latest Raspberry Pi OS image (Debian bookworm): https://downloads.raspberrypi.org/raspios_lite_arm64/images/raspios_lite_arm64-2023-10-10/2023-10-10-raspios-bookworm-arm64-lite.img.xz

When running pi-boot-switch -I, I get the following error:

pi@raspberrypi:~ $ sudo pi-boot-switch -I
/usr/local/sbin/pi-boot-switch: line 304: role[$currentBoot]: bad array subscript

This seems caused by "boot" not mounted to /boot anymore but to /boot/firmware, see comparison with bullseye:

# bullseye
pi@raspberrypi:~ $ mount | grep boot
/dev/sda1 on /boot type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,errors=remount-ro)

# bookworm
pi@raspberrypi:~ $ mount | grep boot
/dev/sda1 on /boot/firmware type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,errors=remount-ro)
wolkenarchitekt commented 1 year ago

I'll try to fix other problems related to bookworm and create a PR if I'm successful.

Can I ask a question while at this @bablokb : Does pi-boot-switch support switching boot between USB devices, too? I don't have any SD card attached but only USB disks.

wolkenarchitekt commented 1 year ago

Can I ask a question while at this @bablokb : Does pi-boot-switch support switching boot between USB devices, too? I don't have any SD card attached but only USB disks.

Nevermind, I only found out today that its not possible to define which USB device a Raspberry should boot from, so an SD card (or network boot) is always necessary to switch boot:

https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#multiple-bootable-drives

Multiple Bootable Drives

When searching for a bootable partition, the bootloader scans all USB mass storage devices in parallel and will select the first to respond. If the boot partition does not contain a suitable start.elf file, the next available device is selected. There is no method for specifying the boot device according to the USB topology because this would slow down boot and adds unnecessary and hard to support configuration complexity.

https://elinux.org/RPi_USB_booting#Multiple_Devices

Multiple Devices

There is nothing to prevent someone from plugging more than one bootable USB device into the Raspberry Pi (or a connected USB hub). If multiple USB storage devices are available at power up time, the Raspberry Pi has no way to know which one to use. So, it will use the first one that responds.

bablokb commented 1 year ago

What you can do is to put the boot-partition on the SD-card, and the system partitions on the USB-devices. So you can boot systems from multiple USB-devices. pi-boot-switch does support this setup. And if you use UUIDs, the enumeration of the usb-devices does not play a role either.

bablokb commented 1 year ago

I have added basic support for the Bookworm layout in the next branch. This is mostly untested. Setting labels and description works, switching between multiple Bookworm installations on a single SD works also. Untested is copying and mixed Bookworm/Pre-Bookworm installations.

progsec commented 9 months ago

I use pi-boot-switch for years on rapi3,.. rapi4 without any issue.. today I got a new version of pi-boot-switch on a "brand new" raspi-5. (sudo git clone ..) but.. the following errors appeared:

sudo pi-boot-switch -I /usr/local/sbin/pi-boot-switch: Zeile 330: role: Falscher Feldindex. /usr/local/sbin/pi-boot-switch: Zeile 333: role[$nextRoot]: Falscher Feldindex.

as I am "no git-expert" I don't know what to do.. (as far as I can't prevent the "bold" part of this message, sorry for this, not by purpose.. ;-(

I found the fix ( bablokb#6 Fix getting current boot device on Debian bookworm ) but on my version of the local script I can't find that line to append the ||-statement (must have been updated in the meantime again.)

what information do you need to get deeper into this issue? best regards jürgen

bablokb commented 7 months ago

Although this was fixed with a new version of the script, it now fails again due to new changes in Bookworm. The file /boot/cmdline.txt is no longer a symbolic link to /boot/firmware/cmdline.txt, but a simple file.

A quick workaround:

cd /boot
sudo rm cmdline.txt
sudo ln -s firmware/cmdline.txt

I will see how I can fix this and update the scripts.

progsec commented 7 months ago

Thanks, bablokb, fot the hint. I did as you "told", and it works again.. thanks for the help!

bablokb commented 7 months ago

Hi all,

I fixed the problem in the next-branch. Anybody willing to test?

progsec commented 7 months ago

Thanks fo the info .. I've got one raspi-5 with bookworm, and "few" raspi3/4 with bullseye would that help? Please tell me, how I can install the test (and later the official) version.. jürgen

bablokb commented 7 months ago

Clean way:

git clone https://github.com/bablokb/pi-boot-switch.git
cd pi-boot-switch
git switch next
sudo tools/install

Later (once I merged next into master):

cd pi-boot-switch
git switch master
git pull
sudo tools/install

Fast way: here in github switch to the next branch, go to files/usr/local/sbin and download pi-boot-switch. After download, you have to do a chmod +x to make it executable. Advantage of this approach: you can use both versions in parallel as long as you don't download to /usr/local/sbin.

progsec commented 7 months ago

Hi all, (sorry again for the unwanted bold/bigger text ;(

I installed it on bookworm and on bullseye without a problem. Then I made a copy of current root to another partition, again without a problem on both systems. (see attached files pi-boot-switch_bookworm.rtf and pi-boot-switch_bullseye.rtf in Archiv.zip)

The only thing with "pi-boot-switch -I" problem since years: I can't set the "Label" to be shown in pi-boot-switch (I'm sure in "my beginning of pi-boot-switch" it worked, later it did not anymore..)

xxxx:~/pi-boot-switch $ sudo pi-boot-switch -I info: reading partition descriptions from /boot/firmware/pi-boot-switch.txt Partition Label Role Description
/dev/sda1 sysbck2 sysbck_20240326

But with the command .. it's shown on both OSs ..

xxxx:~/pi-boot-switch $ sudo lsblk -o name,mountpoint,label,partlabel,size NAME MOUNTPOINT LABEL PARTLABEL SIZE sda 931,5G ├─sda1 sysbck_20240326 sysbck2 64G

I always change the l Archiv.zip abel afterwards with gdisk .. -> what do I do wrong?

best regards jürgen

bablokb commented 7 months ago

LABEL is an attribute of the filesystem. PARTLABEL is an attribute of the partition. PARTLABEL is only available for GPT disks. So as long as you don't use GPT formatted disks, you don't have PARTLABEL. Otherwise, you have both and they can be different.

pi-boot-switch uses LABEL. You can set the label with e2label or with

pi-boot-switch -L "mylabel"                        # will label the current root-partition
pi-bootswitch -t /dev/sda1 -L "myLabel"   # will label the target-partition provided by -t

The reason why pi-boot-switch -I only shows the PARTLABEL and not the LABEL is an error. Please open a new issue for that, I will see what I can do.

progsec commented 6 months ago

to the „pi-boot-switch label not written“ problem.. I usually work with usb-disks (just boot from card, work on disk) -> there (on disks) label does not work

currently I re-installed on a sd-card.. —> there the label command works fine..

perhaps that makes it more clear?

b est regards jürgen

Am 26.03.2024 um 13:21 schrieb bablokb @.***>:

LABEL is an attribute of the filesystem. PARTLABEL is an attribute of the partition. PARTLABEL is only available for GPT disks. So as long as you don't use GPT formatted disks, you don't have PARTLABEL. Otherwise, you have both and they can be different.

pi-boot-switch uses LABEL. You can set the label with e2label or with

pi-boot-switch -L "mylabel" # will label the current root-partition pi-bootswitch -t /dev/sda1 -L "myLabel" # will label the target-partition provided by -t The reason why pi-boot-switch -I only shows the PARTLABEL and not the LABEL is an error. Please open a new issue for that, I will see what I can do.

— Reply to this email directly, view it on GitHub https://github.com/bablokb/pi-boot-switch/issues/6#issuecomment-2020285023, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZQCPKZAAHRHPYAMHBTYCQTY2FK4PAVCNFSM6AAAAAA6JDQRFSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRQGI4DKMBSGM. You are receiving this because you commented.