I have a sever(Dell workstation) with several Oss installed (multiboot with Win10, Ubuntu desktop, Ubuntu-server, Fedora desktop and Opensuse Tumbleweed desktop) on the same ssd (plus Debian with proxmox on an extra ssd). Since I have installed TW I need to use grub2 from TW for booting, because the grub of the other Oss does not recoggnize TW. The issue is, that Ubuntu-server is set as default boot, and so I cannot use “grub-reboot” from Ubuntu-server to boot into any other Os (as “grub-reboot” only changes the “grubenv” of grub, not of grub2). The only possibility I am aware of is mounting the TW partition and modifying “grubenv” of TW via ubuntu-server. As that file needs to have a specfic size I would have to write a program that does the change. Is there possibly another better solution? There are a monitor and a wireless keyboard connected to the server, but I would like to be able to choose the Os headless.
Could I possibly use chroot to change root to root of TW and then use “grub2-reboot” from TW (I have no experience with chroot)?
Chat-gpt (o3-mini-high) tells me that I can use “grub-editenv” to change the grub2 ‘grubenv’ (“sudo grub-editenv -g /mnt/boot/grub2/grubenv set next_entry=2”) and do not have to use “grub2-editenv”, as both variants would be functionally identical! Is that correct?
I am not sure I am following you correctly, so let me ask, after installing TW your grub menu did list Win10, Ubuntu desktop, Ubuntu-server, Fedora desktop and Opensuse Tumbleweed as options?
Normally when you install TW that will be the default boot entry so it is not clear to me how it can be “that Ubuntu-server is set as default boot”
On changing the default boot entry, I still get a better answer using an search machine then using AI:
openSUSE is using heavily patched grub2, so yes, in general this is the only possibility - you need to use tools from openSUSE.
I myself set “ubuntu-server” as default boot! All other Oss are only installed for testing purposes!
[/quote]
That solution does not work, as I need to change the “grubenv” from TW, not the one from Ubuntu!
If Ubuntu server is default boot then the problem is its boot code not seeing TW
I now tried:
sudo /mnt/boot_tw/usr/bin/grub2-editenv -g /mnt/boot_tw/boot/grub2/grubenv set next_entry=0
(TW-partiiton mounted to /mnt/boot_tw)
but got the error “error while loading shared libraries: libdevmapper.so.1.03: cannot open shared object file: No such file or directory”
So i probably need to chroot Tw, but I never used chroot. Could soemone tell me how to do that properly (for this specific case)?
mount /dev/your-btrfs-root /mnt
mount --bind /dev /mnt/dev
mount --bind /proc /mnt/proc
mount --rbind /sys /mnt/sys
chroot /mnt
mount -a -t btrfs
You may need to also mount /boot/efi
depending on what you are going to do.
Thanks, I will try that!
I now did the following (within ubuntu-server):
sudo mount UUID=f7e9003b-c57b-46a6-bffb-9ee9e37a49f0 /mnt/tumbleweed
sudo mount --bind /dev /mnt/tumbleweed/dev
sudo mount --bind /proc /mnt/tumbleweed/proc
sudo mount --rbind /sys /mnt/tumbleweed/sys
sudo chroot /mnt/tumbleweed
sudo grub2-editenv /boot/grub2/grubenv set next_entry=0
sudo reboot
and it booted into TW (TW is entry “0”) and after a reboot it booted into ubuntu-server again - PERFECT!
I then put that into a script (with “…next_entry=$1”), but the scipt did not continue working after the “chroot” (as feared). So I probably need two scripts, one with the above lines upto (including) the line with the “chroot” and then a second script with “grub2-editenv …” and “reboot”, or is there a way to use just one script?
The final solution looks like this (one script):
#!/bin/bash
mount UUID=f7e9003b-c57b-46a6-bffb-9ee9e37a49f0 /mnt/tumbleweed
mount --bind /dev /mnt/tumbleweed/dev
mount --bind /proc /mnt/tumbleweed/proc
mount --rbind /sys /mnt/tumbleweed/sys
chroot /mnt/tumbleweed /bin/bash -c 'awk -F"'"'"'" '"'"'$1=="menuentry " || $1=="submenu " {print i++ " : " $2}; /\smenuentry / {print "\t" i-1">"j++ " : " $2}'"'"' /boot/grub2/grub.cfg && read -p "Nummer: " nr && grub2-editenv /boot/grub2/grubenv set next_entry=$nr && exit'
reboot
Output:
0 : openSUSE Tumbleweed
1 : Advanced options for openSUSE Tumbleweed
1>1 : openSUSE Tumbleweed, with Linux 6.14.0-1-default
1>2 : openSUSE Tumbleweed, with Linux 6.14.0-1-default (recovery mode)
1>3 : openSUSE Tumbleweed, with Linux 6.13.8-1-default
1>4 : openSUSE Tumbleweed, with Linux 6.13.8-1-default (recovery mode)
2 : Windows Boot Manager (on /dev/sdb2)
3 : Ubuntu 24.10 (24.10) (on /dev/sdb4)
4 : Advanced options for Ubuntu 24.10 (24.10) (on /dev/sdb4)
4>5 : Ubuntu (on /dev/sdb4)
4>6 : Ubuntu, with Linux 6.11.0-19-generic (on /dev/sdb4)
4>7 : Ubuntu, with Linux 6.11.0-19-generic (recovery mode) (on /dev/sdb4)
4>8 : Ubuntu, with Linux 6.11.0-18-generic (on /dev/sdb4)
4>9 : Ubuntu, with Linux 6.11.0-18-generic (recovery mode) (on /dev/sdb4)
5 : Ubuntu 24.10 (24.10) (on /dev/sdb5)
6 : Advanced options for Ubuntu 24.10 (24.10) (on /dev/sdb5)
6>10 : Ubuntu (on /dev/sdb5)
6>11 : Ubuntu, with Linux 6.11.0-21-generic (on /dev/sdb5)
6>12 : Ubuntu, with Linux 6.11.0-21-generic (recovery mode) (on /dev/sdb5)
6>13 : Ubuntu, with Linux 6.11.0-19-generic (on /dev/sdb5)
6>14 : Ubuntu, with Linux 6.11.0-19-generic (recovery mode) (on /dev/sdb5)
7 : Fedora Linux 41 (Workstation Edition) (on /dev/sdb6)
8 : Advanced options for Fedora Linux 41 (Workstation Edition) (on /dev/sdb6)
8>15 : Fedora Linux 41 (Workstation Edition) (on /dev/sdb6)
8>16 : Fedora Linux 41 (Workstation Edition) (on /dev/sdb6)
8>17 : Fedora Linux 41 (Workstation Edition) (on /dev/sdb6)
9 : Debian GNU/Linux 12 (bookworm) (on /dev/mapper/pve-root)
10 : Advanced options for Debian GNU/Linux 12 (bookworm) (on /dev/mapper/pve-root)
10>18 : Proxmox VE GNU/Linux (on /dev/mapper/pve-root)
10>19 : Proxmox VE GNU/Linux, with Linux 6.8.12-4-pve (on /dev/mapper/pve-root)
10>20 : Proxmox VE GNU/Linux, with Linux 6.8.12-4-pve (recovery mode) (on /dev/mapper/pve-root)
10>21 : Memory test (memtest86+x64.efi) (on /dev/mapper/pve-root)
10>22 : Memory test (memtest86+x64.efi, serial console) (on /dev/mapper/pve-root)
10>23 : UEFI Firmware Settings
Nummer: 0 <---MANUALLY ENTERED!
Broadcast message from root@userv on pts/2 (Tue 2025-04-08 18:03:01 UTC):
The system will reboot now!
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.