Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script generated boot menu for all arches #1613

Merged
merged 5 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions live/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- [Image Definition](#image-definition)
- [KIWI Files](#kiwi-files)
- [Image Configuration](#image-configuration)
- [GRUB2 menu](#grub2-menu)
- [SSH Server](#ssh-server)
- [Autologin](#autologin)
- [Firefox Profile](#firefox-profile)
Expand Down Expand Up @@ -121,6 +122,15 @@ The main Kiwi source files are located in the [src](src) subdirectory:

The Live ISO is configured to allow using some features and allow running Agama there.

## GRUB2 Menu

grub.cfg, defining boot menu items of the Agama image, is generated by scripts stored in
[config-cdroot](https://github.com/openSUSE/agama/tree/master/live/config-cdroot).

Both x86_64 and aarch64 grub.cfg are basically copies of KIWI autogenerated grub.cfg.
The x86_64 grub.cfg contains UEFI fix for Booting from disk (Issue #1609).


### SSH Server

The SSH connection for the root user is enabled in the
Expand Down
102 changes: 102 additions & 0 deletions live/config-cdroot/fix_bootconfig.aarch64
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
#! /bin/bash

# Custom menu to ensure that we boot correctly
# from local disk on UEFI
# https://github.com/openSUSE/agama/issues/1609
# KIWI config

dst="$1"

if [ ! -d "$dst" ] ; then
echo "fix_bootconfig.aarch64: image dir \"$dst\" not found"
exit 1
fi

# KIWI config which should normally be inherited
# from a parent process in our case xorriso
# but that's not the case.
test -f $dst/.profile && . $dst/.profile

#
# Create grub.cfg
#
cat >$dst/boot/grub2/grub.cfg <<XXX
# kiwi generated one time grub2 config file
set btrfs_relative_path="y"
export btrfs_relative_path
search --file --set=root /boot/0x11cebed2
set default=0
if [ -n "\$extra_cmdline" ]; then
submenu "Bootable snapshot \$snapshot_num" {
menuentry "If OK, run snapper rollback and reboot." { true; }
}
fi
if [ -n "\${iso_path}" ]; then
isoboot="iso-scan/filename=\${iso_path}"
fi
set timeout=10
set timeout_style=menu
if [ "\${grub_platform}" = "efi" ]; then
echo "Please press 't' to show the boot menu on this console"
fi
set gfxmode=auto
set font=(\$root)/boot/aarch64/loader/grub2/fonts/unicode.pf2
set ascii_font=grub2/themes/openSUSE/ascii.pf2
set sans_bold_14_font=grub2/themes/openSUSE/DejaVuSans-Bold14.pf2
set sans_10_font=grub2/themes/openSUSE/DejaVuSans10.pf2
set sans_12_font=grub2/themes/openSUSE/DejaVuSans12.pf2
if [ -f \${font} ];then
loadfont \${font}
fi
if [ -f (\$root)/boot/\${ascii_font} ];then
loadfont (\$root)/boot/\${ascii_font}
fi
if [ -f (\$root)/boot/\${sans_bold_14_font} ];then
loadfont (\$root)/boot/\${sans_bold_14_font}
fi
if [ -f (\$root)/boot/\${sans_10_font} ];then
loadfont (\$root)/boot/\${sans_10_font}
fi
if [ -f (\$root)/boot/\${sans_12_font} ];then
loadfont (\$root)/boot/\${sans_12_font}
fi
if [ -f (\$root)/boot/grub2/themes/openSUSE/theme.txt ];then
set theme=(\$root)/boot/grub2/themes/openSUSE/theme.txt
fi
terminal_input console
terminal_output gfxterm
menuentry "$kiwi_iname" --class os --unrestricted {
set gfxpayload=keep
echo Loading kernel...
linux (\$root)/boot/aarch64/loader/linux \${extra_cmdline} \${isoboot}
echo Loading initrd...
initrd (\$root)/boot/aarch64/loader/initrd
}
menuentry "Failsafe -- $kiwi_iname" --class os --unrestricted {
set gfxpayload=keep
echo Loading kernel...
linux (\$root)/boot/aarch64/loader/linux \${extra_cmdline} \${isoboot} ide=nodma apm=off noresume edd=off nomodeset 3
echo Loading initrd...
initrd (\$root)/boot/aarch64/loader/initrd
}
menuentry "Mediacheck" --class os --unrestricted {
set gfxpayload=keep
echo Loading kernel...
linux (\$root)/boot/aarch64/loader/linux mediacheck=1 plymouth.enable=0 \${isoboot}
echo Loading initrd...
initrd (\$root)/boot/aarch64/loader/initrd
}
menuentry "Boot from Hard Disk" --class opensuse --class gnu-linux --class gnu --class os {
exit
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you test if that exit works properly on arm? does it move to the next entry in boot menu?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello Josef, this was a copypaste from the Arm agama-installer without any modifications.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but nope we currently only test on intel in openQA and I have no arm device at hand.

}
if [ -f "/.snapshots/grub-snapshot.cfg" ]; then
source "/.snapshots/grub-snapshot.cfg"
fi
if [ "\${grub_platform}" = "efi" ]; then
hiddenentry "Text mode" --hotkey "t" {
set textmode=true
terminal_output console
}
fi
XXX

13 changes: 9 additions & 4 deletions live/config-cdroot/fix_bootconfig.ppc64le
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ if [ ! -d "$dst" ] ; then
exit 1
fi

# KIWI config which should normally be inherited
# from a parent process in our case xorriso
# but that's not the case.
test -f $dst/.profile && . $dst/.profile

# ----------------

# Note:
Expand Down Expand Up @@ -74,22 +79,22 @@ chmod 644 $boot_dir/{initrd,linux}
cat >$dst/boot/grub2/grub.cfg <<XXX
gfxmode=auto

set default='Agama Live'
set default="$kiwi_iname"

insmod gettext

if sleep --interruptible 0 ; then
timeout=60
fi

menuentry 'Agama Live' --class os --unrestricted {
menuentry "$kiwi_iname" --class os --unrestricted {
echo 'Loading kernel...'
linux /boot/ppc64le/linux
echo 'Loading initrd...'
initrd /boot/ppc64le/initrd
}

menuentry 'Check Installation Media -- Agama Live' --class os --unrestricted {
menuentry "Check Installation Media -- $kiwi_iname" --class os --unrestricted {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I felt that it would be nice to cosistently use $kiwi_iname across all arches. I did not dare to touch s390x.

echo 'Loading kernel...'
linux /boot/ppc64le/linux mediacheck=1 plymouth.enable=0
echo 'Loading initrd...'
Expand All @@ -115,7 +120,7 @@ XXX
#
cat >$dst/ppc/bootinfo.txt <<XXX
<chrp-boot>
<description>Agama Live</description>
<description>$kiwi_iname</description>
<os-name>openSuSE Tumbleweed</os-name>
<boot-script>boot &device;:1,\boot\grub2\grub.elf</boot-script>
</chrp-boot>
Expand Down
110 changes: 110 additions & 0 deletions live/config-cdroot/fix_bootconfig.x86_64
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
#! /bin/bash

# Custom menu to ensure that we boot correctly
# from local disk on UEFI
# https://github.com/openSUSE/agama/issues/1609
# KIWI config

dst="$1"

if [ ! -d "$dst" ] ; then
echo "fix_bootconfig.x86_64: image dir \"$dst\" not found"
exit 1
fi

# KIWI config which should normally be inherited
# from a parent process in our case xorriso
# but that's not the case.
test -f $dst/.profile && . $dst/.profile

#
# Create grub.cfg
#
cat >$dst/boot/grub2/grub.cfg <<XXX
# kiwi generated one time grub2 config file
set btrfs_relative_path="y"
export btrfs_relative_path
search --file --set=root /boot/0xebe87947
set default=0
if [ -n "\$extra_cmdline" ]; then
submenu "Bootable snapshot \$snapshot_num" {
menuentry "If OK, run snapper rollback and reboot." { true; }
}
fi
if [ -n "\${iso_path}" ]; then
isoboot="iso-scan/filename=\${iso_path}"
fi
set timeout=10
set timeout_style=menu
if [ "\${grub_platform}" = "efi" ]; then
echo "Please press 't' to show the boot menu on this console"
fi
set gfxmode=auto
set font=(\$root)/boot/x86_64/loader/grub2/fonts/unicode.pf2
set ascii_font=grub2/themes/openSUSE/ascii.pf2
set sans_bold_14_font=grub2/themes/openSUSE/DejaVuSans-Bold14.pf2
set sans_10_font=grub2/themes/openSUSE/DejaVuSans10.pf2
set sans_12_font=grub2/themes/openSUSE/DejaVuSans12.pf2
if [ -f \${font} ];then
loadfont \${font}
fi
if [ -f (\$root)/boot/\${ascii_font} ];then
loadfont (\$root)/boot/\${ascii_font}
fi
if [ -f (\$root)/boot/\${sans_bold_14_font} ];then
loadfont (\$root)/boot/\${sans_bold_14_font}
fi
if [ -f (\$root)/boot/\${sans_10_font} ];then
loadfont (\$root)/boot/\${sans_10_font}
fi
if [ -f (\$root)/boot/\${sans_12_font} ];then
loadfont (\$root)/boot/\${sans_12_font}
fi
if [ -f (\$root)/boot/grub2/themes/openSUSE/theme.txt ];then
set theme=(\$root)/boot/grub2/themes/openSUSE/theme.txt
fi
terminal_input console
terminal_output gfxterm
menuentry "$kiwi_iname" --class os --unrestricted {
set gfxpayload=keep
echo Loading kernel...
linux (\$root)/boot/x86_64/loader/linux \${extra_cmdline} \${isoboot}
echo Loading initrd...
initrd (\$root)/boot/x86_64/loader/initrd
}
menuentry "Failsafe -- $kiwi_iname" --class os --unrestricted {
set gfxpayload=keep
echo Loading kernel...
linux (\$root)/boot/x86_64/loader/linux \${extra_cmdline} \${isoboot} ide=nodma apm=off noresume edd=off nomodeset 3
echo Loading initrd...
initrd (\$root)/boot/x86_64/loader/initrd
}
menuentry "Mediacheck" --class os --unrestricted {
set gfxpayload=keep
echo Loading kernel...
linux (\$root)/boot/x86_64/loader/linux mediacheck=1 plymouth.enable=0 \${isoboot}
echo Loading initrd...
initrd (\$root)/boot/x86_64/loader/initrd
}
menuentry "Boot from Hard Disk" --class opensuse --class gnu-linux --class gnu --class os {
if search --no-floppy --file /efi/boot/fallback.efi --set ; then
for os in opensuse sles leap; do
Copy link
Contributor Author

@lkocman lkocman Sep 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like somebody exchanged opensuse for leap in the past ... so now Agama:Devel/agama-installer has leap too :-)

Screenshot from 2024-09-17 09-00-00

if [ -f /efi/\$os/grub.efi ] ; then
chainloader /efi/\$os/grub.efi
boot
fi
done
fi
exit
}
if [ -f "/.snapshots/grub-snapshot.cfg" ]; then
source "/.snapshots/grub-snapshot.cfg"
fi
if [ "\${grub_platform}" = "efi" ]; then
hiddenentry "Text mode" --hotkey "t" {
set textmode=true
terminal_output console
}
fi
XXX

16 changes: 16 additions & 0 deletions live/src/agama-installer.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
-------------------------------------------------------------------
Mon Sep 16 15:46:23 UTC 2024 - Lubos Kocman <[email protected]>

- Define boot menu for all arches by scripts in config-cdroot
newly added x86_64 and aarch64 write stock copies from kiwi
generated grub.cfg

- intel uefi boot fix from "Boot from disk item" (gh#openSUSE/agama#1609)

- Keep -x on purpose for future trubleshooting (advice from Marcus)

- Use $kiwi_iname instead of static agama-live reference in all of
config-cdroom/* with exception of s390x, where for some reason
we use SUSE Linux... string instead


-------------------------------------------------------------------
Mon Sep 9 15:55:16 UTC 2024 - Eugenio Paolantonio <[email protected]>

Expand Down
12 changes: 9 additions & 3 deletions live/src/fix_bootconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,18 @@
# This script (a) adjusts the boot config, (b) runs xorriso, and (c) makes
# it zIPL bootable on s390x.
#
set -ex

# KIWI config
test -f .profile && . .profile

dst=${1#iso:}

# KIWI config
Copy link
Contributor Author

@lkocman lkocman Sep 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's important to do this after setting $dst. I was not able to get acccess to $kiwi_* variables (set in /.profile) fix_bootconfig.$arch . So I simply copied the .profile into the $dst from where the xorriso -> fix_bootconfig.$arch was executed.

This was working (vars inherited, without copying the file) if the fix_bootconfig was called outside xorriso.

# Copy it to $dst from where it can be later read by xorriso
if [ -f .profile ]; then
source .profile
cp .profile "$dst"
fi

arch=`uname -m`

# removing live root setting from command line - it's in /etc/cmdline.d instead
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that this block is needed since we have now static grub.cfg

Expand Down Expand Up @@ -67,7 +73,7 @@ done
volid=${kiwi_install_volid:-$kiwi_iname}

[ -x $bootfix ] && $bootfix $dst
rm -f $dst/fix_bootconfig.*
rm -f $dst/fix_bootconfig.* $dst/.profile

case $arch in
s390x)
Expand Down