From 680730cc1a1fef815a05e50c104ce31f9019e695 Mon Sep 17 00:00:00 2001 From: Michael Marineau Date: Sat, 30 Aug 2014 17:46:38 -0700 Subject: [PATCH] configure_bootloaders: add grub install stub code Not currently used, this configuration which sets up grub to re-use the syslinux configuration only works with recent git versions, not any releases. Compatibility is also limited because the serial configuration in syslinux must be duplicated in the grub config. --- build_library/configure_bootloaders.sh | 26 +++++++++++++++++++++----- build_library/grub.cfg | 9 +++++++++ 2 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 build_library/grub.cfg diff --git a/build_library/configure_bootloaders.sh b/build_library/configure_bootloaders.sh index f3f5bf35dc..7458838646 100755 --- a/build_library/configure_bootloaders.sh +++ b/build_library/configure_bootloaders.sh @@ -51,7 +51,7 @@ GRUB_DIR="${FLAGS_boot_dir}/grub" SYSLINUX_DIR="${FLAGS_boot_dir}/syslinux" # Build configuration files for pygrub/pvgrub -configure_grub() { +configure_pvgrub() { sudo mkdir -p "${GRUB_DIR}" # Add hvc0 for hypervisors @@ -177,12 +177,28 @@ copy_to_esp() { done } +# Install GRUB2 to the disk image +install_grub() { + # Install under boot/coreos/grub instead of boot/grub to prevent + # more recent versions of pygrub that attempt to read grub2 configs + # from finding it, pygrub and pvgrub must stick with using menu.lst + sudo mkdir -p "${FLAGS_esp_dir}/coreos/grub" + sudo grub-install \ + --target=i386-pc \ + --modules=part_gpt \ + --boot-directory="${FLAGS_esp_dir}/coreos" \ + "${FLAGS_disk_image}" + sudo cp "${BUILD_LIBRARY_DIR}/grub.cfg" \ + "${FLAGS_esp_dir}/coreos/grub/grub.cfg" +} + +[[ -d "${FLAGS_esp_dir}" ]] || die_notrace "--esp_dir is required" +[[ -f "${FLAGS_disk_image}" ]] || die_notrace "--disk_image is required" + if [[ "${FLAGS_arch}" = "x86" || "${FLAGS_arch}" = "amd64" ]]; then - configure_grub + configure_pvgrub configure_syslinux - if [[ -n "${FLAGS_esp_dir}" ]]; then - copy_to_esp - fi + copy_to_esp else error "No bootloader configuration for ${FLAGS_arch}" fi diff --git a/build_library/grub.cfg b/build_library/grub.cfg new file mode 100644 index 0000000000..69bf7d0a36 --- /dev/null +++ b/build_library/grub.cfg @@ -0,0 +1,9 @@ +# Use both default console and ttyS0 +serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1 +terminal_input console serial +terminal_output console serial + +# Re-use the existing syslinux configuration +echo "Loading SYSLINUX configuration..." +insmod syslinuxcfg +syslinux_configfile -s /syslinux/syslinux.cfg