From a6e29467678f17278ff571e833b812e8eb745541 Mon Sep 17 00:00:00 2001 From: alberand Date: Fri, 19 Mar 2021 18:57:49 +0100 Subject: [PATCH] Add BOOT_METHOD variable to control how to generate GRUB2 config --- README.pod | 5 +++++ novaboot | 18 ++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/README.pod b/README.pod index 3472d52..039a1eb 100644 --- a/README.pod +++ b/README.pod @@ -931,6 +931,11 @@ The following variables are interpreted in the novaboot script: =over 8 +=item BOOT_METHOD + +Specifies the way GRUB2 boots the kernel. For kernels with multiboot +support use C method (the default). For Linux kernel use C method. + =item BUILDDIR Novaboot chdir()s to this directory before file generation phase. The diff --git a/novaboot b/novaboot index d6a60ed..abd5b9c 100755 --- a/novaboot +++ b/novaboot @@ -575,18 +575,23 @@ sub generate_grub2_config($$$$;$$) print $fg "menuentry $title {\n"; print $fg "$prolog\n" if $prolog; my $first = 1; + my $boot_method = $variables->{BOOT_METHOD} // "multiboot"; + my $module_load_method = "module"; + if ($boot_method eq "linux") { + $module_load_method = "initrd"; + } foreach (@$modules_ref) { if ($first) { $first = 0; my ($kbin, $kcmd) = split(' ', $_, 2); $kcmd = '' if !defined $kcmd; - print $fg " multiboot ${base}$kbin $kcmd\n"; + print $fg " $boot_method ${base}$kbin $kcmd\n"; } else { my @args = split; # GRUB2 doesn't pass filename in multiboot info so we have to duplicate it here $_ = join(' ', ($args[0], @args)); s|\brom://|$rom_prefix|g; # We do not need to translate path for GRUB2 - print $fg " module $base$_\n"; + print $fg " $module_load_method $base$_\n"; } } print $fg "}\n"; @@ -1729,6 +1734,10 @@ specified F is used. The content of the menu entry can be customized with B<--grub-preamble>, B<--grub2-prolog> or B<--grub_prefix> options. +GRUB2 can boot multiboot-compliant kernels and a few kernels with specific +support. L could be used to specify the command used by GRUB2 to +load the kernel. See L. + To use the generated menu entry on your development machine that uses GRUB2, append the following snippet to F file and regenerate your grub configuration, @@ -2285,6 +2294,11 @@ The following variables are interpreted in the novaboot script: =over 8 +=item BOOT_METHOD + +Specifies the way GRUB2 boots the kernel. For kernels with multiboot +support use C method (the default). For Linux kernel use C method. + =item BUILDDIR Novaboot chdir()s to this directory before file generation phase. The -- 2.39.2