Attempting to dual boot

I’m attempting to dual-boot Raspbian on eMMC and Ubuntu on SD. I have booted successfully from both on their own. As mentioned here, I ran update-grub while booted into Raspbian on the eMMC. It successfully ran os-prober and found Ubuntu on the SD card. After rebooting, uboot throws an error if the eMMC is connected.

Found EFI removable media binary efi/boot/bootaa64.efi
872448 bytes read in 21 ms (39.6 MiB/s)
Booting /efi\boot\bootaa64.efi
No EFI system partition
Failed to persist EFI variables
“Synchronous Abort” …

It appears that modifying grub has corrupted it somehow. Interrupting uboot and running run bootcmd_mmc1 does work, but is there a way to use grub to dual-boot both grub bootable OSs?

1 Like

It appears that installing a new version of Grub, as mentioned in that other thread, was breaking the existing one. I opened the image and manually copied the old grub files into the EFI folder to fix it. Updating grub entries was not the problem.

However I still cannot get os-prober to reliably find the OS’s on the SD Card. Nor can I get grub itself to even access the other storage mediums. (something to do with how uboot passes hardware control to grub maybe.)

The ridiculous workaround I’ve found for this is to create a grub entry I labeled “Boot SD Card” which simply executes the exit command. This causes grub to quit and makes uboot think that emmc booting failed and to try the next option on the list. This works to boot OS’s not using grub (like CoreELEC and Android) so long as grub is installed on the eMMC. I imagine it would work for SD Card users (or eMMC users) trying to dual boot with a USB device.

  1. make sure OS on eMMC uses grub (Raspbian, Ubuntu, etc.)
  2. sudo nano /etc/grub.d/40_custom
  3. add the following to the bottom of that file

menuentry “Boot SD Card” {
exit
}

  1. sudo update-grub

That’s it. Dual boot with anything on the SD Card including swapping cards on the fly for testing without having to add grub entries for each new OS. The other option is to stop uboot and enter run bootcmd_mmc1 each time you want to boot into the SD Card instead.

2 Likes
  1. I like your solution. It’s a lot easier to catch grub than uboot. My eMMC might come out of the drawer now.
  2. As a sugar-maker, I like your avatar.
2 Likes

I really wish that there were a better (in SPI?) bootloader to opt-pick a boot device or at least define a boot priority. I would much rather it prefer to boot from USB first, then uSD, then LASTly the eMMC. I assume that since this board lacks SPI flash that this is likely impossible without including this within the bootloader on each boot device?

You can control this via the boot.ini on the first partition of your boot device.

boot_targets=usb mmc1 mmc0
2 Likes

Doesn’t that still require an eMMC or uSD card to then boot from USB?

Yes, for boards without SPI flash, you need eMMC or MicroSD with the firmware flashed correctly. For all boards designed since 2018, they have onboard SPI firmware that is controlled by a switch.

It would be nice to include boot_targets=usb mmc1 mmc0 into the lepotato images by default.

The boot.ini doesn’t seem to exist by default in the Raspbian11 image - does the included uboot support it?

2024-04-08 15:14:16 root@lepotato:~# lsblk -o +label,fstype,uuid
NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT LABEL  FSTYPE UUID
mmcblk0      179:0    0 116.5G  0 disk                          
mmcblk0boot0 179:32   0     4M  1 disk                          
mmcblk0boot1 179:64   0     4M  1 disk                          
mmcblk1      179:96   0 119.3G  0 disk                          
├─mmcblk1p1  179:97   0   256M  0 part /boot/efi  bootfs vfat   92A6-EC23
└─mmcblk1p2  179:98   0   119G  0 part /          rootfs btrfs  b4186fcb-3f89-41ba-8555-d8d3907d885f
2024-04-08 15:14:31 root@lepotato:~# ls -alh /boot/efi/
total 16K
drwxr-xr-x 4 root root 4.0K 1969-12-31 16:00  .
drwxr-xr-x 1 root root  296 2023-12-02 22:43  ..
-rwxr-xr-x 1 root root  325 2024-04-08 07:44  cmdline.txt
-rwxr-xr-x 1 root root 2.1K 2023-05-02 19:53  config.txt
drwxr-xr-x 4 root root 2.0K 2023-12-02 22:43  EFI
-rwxr-xr-x 1 root root  145 2023-05-02 20:49  issue.txt
drwxr-xr-x 2 root root 2.0K 2024-04-08 07:44 'System Volume Information'
2024-04-08 15:14:42 root@lepotato:~# 

Also, does mmcblk0boot0 and/or mmcblk0boot1 contain the uboot? Is it easier to upgrade the uboot this way?

Woohoo! echo "boot_targets=usb mmc1 mmc0" > /boot/efi/boot.ini seems to work even for Raspbian11! This really should be the default in every image!

The eMMC is successfully booting with Raspbian11, and the uSD card is successfully booting with Raspbian11 full, finally taking boot priority over the eMMC:

2024-04-08 17:05:25 root@lepotato:~# lsblk -o +label,fstype,uuid
NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT LABEL  FSTYPE UUID
mmcblk0      179:0    0 116.5G  0 disk                          
├─mmcblk0p1  179:1    0   256M  0 part            bootfs vfat   35DE-9C73
└─mmcblk0p2  179:2    0 116.2G  0 part            rootfs btrfs  e57d1fe0-6df4-4b8c-90fe-0ae3245d2fd6
mmcblk0boot0 179:32   0     4M  1 disk                          
mmcblk0boot1 179:64   0     4M  1 disk                          
mmcblk1      179:96   0 119.3G  0 disk                          
├─mmcblk1p1  179:97   0   256M  0 part /boot/efi  bootfs vfat   92A6-EC23
└─mmcblk1p2  179:98   0   119G  0 part /          rootfs btrfs  b4186fcb-3f89-41ba-8555-d8d3907d885f
zram0        252:0    0   3.8G  0 disk [SWAP]                   
2024-04-08 17:05:34 root@lepotato:~# 

Now I can finally test and troubleshoot the bookworm image on uSD without hassle of losing my working OS.