witty
Posts: 38
Joined: Sat Oct 31, 2015 5:33 pm

booting from wrong /boot partition

Mon Jun 22, 2020 2:53 am

Raspberry Pi Model B Rev 2

Raspberry Pi OS (32-bit) Lite
Version: May 2020
Release date: 2020-05-27
Kernel version: 4.19

Step 1 (fresh install version 1):
fresh install on SD-Card(1).
For security reasons renamed user "pi" to "myuser", changed password, activated login via key-exchange only (by "PasswordAuthentication no").
Connected to internet and installed all updates (apt update/upgrade/full-upgrade, rpi-update).
After basic configuration work and several planned reboots, the system stopped while booting - several Ctrl+Alt+Del reboots (not power off) showed the same error.

Code: Select all

You are in emergency mode. After logging in, type "journalctl -xb" to view system logs, "systemctl reboot" to reboot, "systemctl default" or "exit" to boot into default mode.

Cannot open access to console, the root account is locked.
See sulogin(8) man page for more details.

Press Enter to continue.

Reloading system manager configuration
Starting default target
As I was not sure, the SD-Card(1) crashed, I decided to not put focus on this, but take a new SD-Card(2) and repeat the fresh install...

Step 2 (fresh install version 2):
fresh install on SD-Card(2) same as above.

Step 3 (copy config from SD1 to SD2)
copy config (keys, etc.) from (offline) SD-Card(1) to SD-Card(2):
In this step I learned (and was surprised to see), that both SD-Cards do have the same UUIDs (as this is the case when using the same "Raspberry Pi OS version" ).

I use an USB-Hub with included SD-Card reader, mounted SD-Card‘s(2) ext4 partition (with reference to /dev/sda2 and NOT the UUID ;)), copied everything I needed to my SD-Card(1), then, umounted, halt+power off and unplugged USB-Hub.

Step 4:
Power on lead me now to the error:

Code: Select all

[FAILED] Failed to start Remount Root and Kernel File Systems.
 See 'systemctl status systemd-remount-fs.service' for details.
[...]
[TIME] Timed out waiting for device /dev/disk/by-partuuid/8cd889c2-01.
[DEPEND] Dependency failed for File System Check on /dev/disk/by-partuuid/8cd889c2-01.
[DEPEND] Dependency failed for /boot.
[DEPEND] Dependency failed for Local File Systems.
[...]
You are in emergency mode. After logging in, type "journalctl -xb" to view system logs, "systemctl reboot" to reboot, "systemctl default" or "exit" to boot into default mode.

Cannot open access to console, the root account is locked.
See sulogin(8) man page for more details.

Press Enter to continue.

Reloading system manager configuration
Starting default target
Luckily, after re-connecting the USB-Hub with attached SD-Card(1), system works fine again.
BUT my RPi is now mounting the wrong /boot partition

Code: Select all

$ lsblk --fs
NAME        FSTYPE LABEL  UUID                                 FSAVAIL FSUSE% MOUNTPOINT
sda
├─sda1      vfat   boot   592B-C92C                               [b]201M    20% /boot[/b]
└─sda2      ext4   rootfs 706944a6-7d0f-4a45-9f8c-7fb07375e9f7
mmcblk0
├─mmcblk0p1 vfat   boot   592B-C92C
└─mmcblk0p2 ext4   rootfs 706944a6-7d0f-4a45-9f8c-7fb07375e9f7   25.9G     7% /
I still can mount the SD-Card's(2) boot partition "mmcblk0p1" manually , once the pi is running!

=> Why does my RPi no longer boot from SD-Card(2)?
=> how do I reactivate the SD-Card's(2) boot partition, so my RPi can boot without the SD-Card(1) in the USB-Hub

thanks for any hint!

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

Re: booting from wrong /boot partition

Mon Jun 22, 2020 5:05 am

witty wrote:
Mon Jun 22, 2020 2:53 am
Luckily, after re-connecting the USB-Hub with attached SD-Card(1), system works fine again.
BUT my RPi is now mounting the wrong /boot partition

Code: Select all

$ lsblk --fs
NAME        FSTYPE LABEL  UUID                                 FSAVAIL FSUSE% MOUNTPOINT
sda
├─sda1      vfat   boot   592B-C92C                               [b]201M    20% /boot[/b]
└─sda2      ext4   rootfs 706944a6-7d0f-4a45-9f8c-7fb07375e9f7
mmcblk0
├─mmcblk0p1 vfat   boot   592B-C92C
└─mmcblk0p2 ext4   rootfs 706944a6-7d0f-4a45-9f8c-7fb07375e9f7   25.9G     7% /
I still can mount the SD-Card's(2) boot partition "mmcblk0p1" manually , once the pi is running!

/dev/mmcblk0 (the SD card inserted in the Pi) and /dev/sda (the SD card inserted in the USB-Hub reader) have identical UUID's (and presumably identical PARTUUID's). That's a no-no!

Change the UUID and PARTUUID on one of the SD cards:

UUID : tune2fs
PARTUUID: fdisk or set-partuuid

witty
Posts: 38
Joined: Sat Oct 31, 2015 5:33 pm

Re: booting from wrong /boot partition

Mon Jun 22, 2020 12:35 pm

RonR wrote:
Mon Jun 22, 2020 5:05 am
witty wrote:
Mon Jun 22, 2020 2:53 am
/dev/mmcblk0 (the SD card inserted in the Pi) and /dev/sda (the SD card inserted in the USB-Hub reader) have identical UUID's (and presumably identical PARTUUID's). That's a no-no!

Change the UUID and PARTUUID on one of the SD cards:

UUID : tune2fs
PARTUUID: fdisk or set-partuuid
Well I already thought, having 2 identical SD-Cards in one system is not the best idea ;-)

Maybe I should have asked first (before changing the PARTUUID) - but what is the reason, the SD-Card(2) fails booting, but with plugged in SD-Card(1) in parallel, it works - better worked.

After changing now the PARTUUID of SD-Card(1), the system stops during booting with

Code: Select all

[FAILED] Failed to start Remount Root and Kernel File Systems.
 See 'systemctl status systemd-remount-fs.service' for details.
[...]
[TIME] Timed out waiting for device /dev/disk/by-partuuid/7f41c975-01.
[DEPEND] Dependency failed for File System Check on /dev/disk/by-partuuid/7f41c975-01.
[DEPEND] Dependency failed for /boot.
[DEPEND] Dependency failed for Local File Systems.
[...]
You are in emergency mode. After logging in, type "journalctl -xb" to view system logs, "systemctl reboot" to reboot, "systemctl default" or "exit" to boot into default mode.

Cannot open access to console, the root account is locked.
See sulogin(8) man page for more details.

Press Enter to continue.

Reloading system manager configuration
Starting default target
Luckily, after re-connecting the USB-Hub with attached SD-Card(1), system works fine again.
seems, I'm not so lucky any longer ... :-(

fbe
Posts: 649
Joined: Thu Aug 17, 2017 9:08 pm

Re: booting from wrong /boot partition

Mon Jun 22, 2020 7:25 pm

A Raspberry Pi B Rev. 2 can't "boot from wrong /boot partition". It will allways boot from SD card, if a bootable SD card is inserted. (Maybe it is able to boot from USB if an empty SD-card with a bootcode.bin file only is inserted.)

It will load the kernel from the boot partition (/dev/mmcblk0p1) and the kernel mounts the root filesystem, specified in cmdline.txt on the boot partition.

Now the Linux OS is initialising and the filesystems, specified in /etc/fstab on the root partition are mounted.

If the filesystems are specified by PARTUUID, you have to take care, that the PARTUUID are unique while system is booting, otherwise you can't predict what partitions get mounted. But again, even if /dev/sda1 is mounted to /boot, the Raspberry Pi B Rev. 2 will boot from /dev/mmcblk0p1.

Please start over with a new image, flashed to your SD card and don't connect a second device, that is using identical PARTUUID to your Raspberry Pi, while it is booting.

If you have both, boot and root partition on your SD card, you can safely specify them by their device name in cmdline.txt

Code: Select all

... root=/dev/mmcblk0p2 ...
and /etc/fstab

Code: Select all

...
/dev/mmcblk0p1  /boot           vfat    defaults          0       2
/dev/mmcblk0p2  /               ext4    defaults,noatime  0       1
...
to avoid trouble with non-unique PARTUUID. But you should not specify partitions on USB devices by device name because their name is not predictable if more than one USB device is connected.

Don't run rpi-update. Most users should better run

Code: Select all

sudo apt remove rpi-update
:evil:.

Return to “Troubleshooting”