Jump to content

Recommended Posts

Posted (edited)

This will cause update-grub to add the following a devicetree line to all menu entries. This example is based on Debian Trixie's grub-efi.

 

This example will expect dtb directories (or links) to be in the /boot directory, using the convention that I've seen Armbian use. Here is an example of a /boot directory listing for (pure) Debian Trixie with two kernels:

-rw-r--r-- 1 root root   336036 Aug 27 04:10 config-6.12.43+deb13-arm64
-rw-r--r-- 1 root root   343394 Sep  6 12:48 config-6.16.3+deb13-arm64
lrwxrwxrwx 1 root root       42 Sep 20 16:17 dtb -> ../usr/lib/linux-image-6.16.3+deb13-arm64/
lrwxrwxrwx 1 root root       43 Sep 20 16:17 dtb-6.12.43+deb13-arm64 -> ../usr/lib/linux-image-6.12.43+deb13-arm64/
lrwxrwxrwx 1 root root       42 Sep 20 16:18 dtb-6.16.3+deb13-arm64 -> ../usr/lib/linux-image-6.16.3+deb13-arm64/
drwxr-xr-x 3 root root     4096 Sep 20 15:13 efi
drwxr-xr-x 5 root root     4096 Sep 20 16:26 grub
lrwxrwxrwx 1 root root       29 Sep 15 21:30 initrd.img -> initrd.img-6.16.3+deb13-arm64
-rw------- 1 root root 42521317 Sep 20 16:26 initrd.img-6.12.43+deb13-arm64
-rw------- 1 root root 43760872 Sep 20 16:25 initrd.img-6.16.3+deb13-arm64
lrwxrwxrwx 1 root root       30 Sep 15 20:38 initrd.img.old -> initrd.img-6.12.43+deb13-arm64
-rw-r--r-- 1 root root       83 Aug 27 04:10 System.map-6.12.43+deb13-arm64
-rw-r--r-- 1 root root       92 Sep  6 12:48 System.map-6.16.3+deb13-arm64
lrwxrwxrwx 1 root root       26 Sep 15 21:30 vmlinuz -> vmlinuz-6.16.3+deb13-arm64
-rw-r--r-- 1 root root 37449664 Aug 27 04:10 vmlinuz-6.12.43+deb13-arm64
-rw-r--r-- 1 root root 41507328 Sep  6 12:48 vmlinuz-6.16.3+deb13-arm64
lrwxrwxrwx 1 root root       27 Sep 15 20:38 vmlinuz.old -> vmlinuz-6.12.43+deb13-arm64

Note: The relative pathways of the dtb links above assume that the /boot directory is part of the main OS partition, not on its own boot partition. Otherwise you'd need to copy those directories to /boot/ as Armbian does.

 

 

For The Current Partition's OS Entries (each devicetree will be specific to the respective kernel)

1. Open the file with a text/source editor (using sudo):

/etc/grub.d/10_linux

 

2. Find every line that looks something like this (currently on my system, there is only one, and it's line 189)

linux	${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args}

 

3. Just above it, add your own system's version of this line:

devicetree ${rel_dirname}/dtb-${version}/[VENDOR SUB-DIRECTORY]/[SBC PRODUCT].dtb

 

Specific Example: OrangePI-5-Plus

devicetree ${rel_dirname}/dtb-${version}/rockchip/rk3588-orangepi-5-plus.dtb

 

Specific Example from the resulting grub.cfg, of the current trixie-backport kernel, again on the OrangePI-5-Plus:

devicetree /boot/dtb-6.16.3+deb13-arm64/rockchip/rk3588-orangepi-5-plus.dtb

 

 

For Other Partitions' OS Entries, via os-prober (I'm unfamiliar with the variables in this so each devicetree will be the same generic path, regardless of kernel)

1. Open the file with a text/source editor (using sudo):

 /etc/grub.d/30_os-prober

 

2. Find every line that looks something like this (currently on my system, there are two, lines 277 and 297)

linux ${LKERNEL} ${LPARAMS}

 

3. Just above it, add your own system's version of this line:

devicetree /boot/dtb/[VENDOR SUB-DIRECTORY]/[SBC PRODUCT].dtb

 

Specific Example: OrangePI-5-Plus

devicetree /boot/dtb/rockchip/rk3588-orangepi-5-plus.dtb

 

 

Then run update-grub, and take a look at the resulting /boot/grub/grub.cfg

 

 

 

Edited by The Tall Man
Posted (edited)

Addendum: How To Include Devicetree Overlays

Since Grub does not have devicetree overlay support, we need to merge the desired overlay(s) in with the main devicetree (.dtb) file we're using.

 

Part of the device-tree-compiler package is this command:

fdtoverlay

 

An example from Armbian 25.8.1 Trixie running on the Orange Pi 5 Plus, to enable GPU acceleration in the Vendor (6.1) kernel. In sudo:

cd /boot/dtb-6.1.115-vendor-rk35xx/rockchip
fdtoverlay -i rk3588-orangepi-5-plus.dtb -o rk3588-orangepi-5-plus-panthor.dtb overlay/rockchip-rk3588-panthor-gpu.dtbo

 

Of course, to have that load automatically from grub using the modification above, you'll need to rename (or move) the original .dtb to something else, then rename the one with the -panthor suffix to the original name to take its place.

Edited by The Tall Man
Posted (edited)

Addendum: An Easy Way To Bypass Grub's Self-Centric Orientation & Eliminate The Need For OS-Prober

 

1. Assuming you already have your EFI partition set up, for any OS that's mounting the EFI partition, stop that.

In the /etc/fstab file, comment out (with a #) the line where it's mounted (i.e. as /boot/efi/).

 

2. Install grub on each OS. You can keep the /boot/grub/ directory on the same partition as root. Each installed OS will just update its own grub.cfg whenever it's needed.

# If the your OS doesn't have a /boot/efi/ directory, create one.
mkdir /boot/efi

# Install grub. This will force it to install even though it won't detect a genuine EFI.
grub-install --efi-directory /boot/efi --force

 

Remember if you need to disable os-prober (recommended), just comment-out its line in /etc/default/grub.

 

3. Optional: Eliminate the pesky EFI Firmware menu entry in each OS this way:

cd /etc/grub.d
mkdir skip.d
mv 30_uefi-firmware skip.d/

 

4. Update Grub with your current kernels

update-grub

 

5. Create a small partition for grub. 64 MB will suffice.

 

6. Choose an OS's grub, and copy all files from /boot/grub/ to that small grub partition.

 

7. On that grub partition, create a new grub.cfg. Here is a sample:

set timeout=10

# Load Modules
insmod all_video
insmod part_gpt
insmod ext2
insmod png

# Setup Background
loadfont unicode
terminal_output gfxterm
background_image /grub-16x9.png
set color_normal=white/black
set color_highlight=black/white

# Menu Entries
menuentry 'Orange PI Bookworm' {
	search.fs_uuid df078711-12a0-4637-9264-bac72ee25e4c root
	set prefix=($root)'/boot/grub'
	configfile $prefix/grub.cfg
}
menuentry 'Debian Trixie' {
	search.fs_uuid 1b6add1b-05ac-4568-bf54-1f920a6f8e3e root
	set prefix=($root)'/boot/grub'
	configfile $prefix/grub.cfg
}
menuentry 'Armbian 25.8.1 Bookworm' {
	search.fs_uuid ecb0ae86-8f5c-477e-bcd0-bc77ee5ebee9 root
	set prefix=($root)'/boot/grub'
	configfile $prefix/grub.cfg
}
menuentry 'Armbian 25.8.1 Trixie' {
	search.fs_uuid 6f2d1972-8868-4fb2-bde4-e14325ea4d31 root
	set prefix=($root)'/boot/grub'
	configfile $prefix/grub.cfg
}
menuentry 'Armbian 25.8.1 Noble (Ubuntu 24.04)' {
	search.fs_uuid d974e989-b201-48c6-b74b-f9ab5dfdfdae root
	set prefix=($root)'/boot/grub'
	configfile $prefix/grub.cfg
}

 

Of course, change the menu entry titles and UUIDs to your own.

 

8. Copy the background image you'd like to use to your grub partition. On Debian, background images for grub are typically stored some place like this:

/usr/share/desktop-base/emerald-theme/grub

 

Note in the sample grub.cfg file, grub-16x9.png is the background image named.

If you want to use a .jpg instead of a .png, change the insmod png to insmod jpeg.

 

9. In your EFI partition, modify the grub.cfg to be as follows:

search.fs_uuid 3D53-E216 root 
set prefix=($root)'/'
configfile $prefix/grub.cfg

...changing the UUID to that of your grub partition.

 

Usage

Select the OS you want. That will take you to the OS's own grub menu, which will likely show you two options, the main boot option and "Advanced" boot options. If you select an operating system and wish to change your mind, the ESCAPE key will return you to your previous menu.

 

Problems

I did this and everything worked well except the Armbian Noble (Ubuntu) entry. I coped Debian Bookworm's grub to my grub partition, and either Ubuntu's grub is buggy or apparently Ubuntu's grub used language in its grub.cfg that Debian's grub didn't like. It boots into Ubuntu automatically, but it doesn't show any boot menu. I set its timeout for 10 seconds, so it sits with a blank screen for 10 seconds before it boots.

 

Update: I replaced the grub files on my grub partition with those from Debian Trixie. Same results with Armbian Noble (Ubuntu).

Edited by The Tall Man

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines