From 06444a4ffc30c2e69901c498539d243a3e202a3e Mon Sep 17 00:00:00 2001 From: Brandon Philips Date: Wed, 17 Jul 2013 18:00:00 -0700 Subject: [PATCH 1/3] chore(build_library): strip out verity logic remove some unused verity variables. --- build_library/create_legacy_bootloader_templates.sh | 7 ------- 1 file changed, 7 deletions(-) diff --git a/build_library/create_legacy_bootloader_templates.sh b/build_library/create_legacy_bootloader_templates.sh index 16a26df433..e9c533ff6b 100755 --- a/build_library/create_legacy_bootloader_templates.sh +++ b/build_library/create_legacy_bootloader_templates.sh @@ -55,13 +55,6 @@ fi common_args="init=/sbin/init console=tty0 boot=local rootwait ro noresume" common_args="${common_args} noswap ${FLAGS_boot_args}" -# Common verified boot command-line args -verity_common="dm_verity.error_behavior=${FLAGS_verity_error_behavior}" -verity_common="${verity_common} dm_verity.max_bios=${FLAGS_verity_max_ios}" -# Ensure that dm-verity waits for its device. -# TODO(wad) should add a timeout that display a useful message -verity_common="${verity_common} dm_verity.dev_wait=${dev_wait}" - # Populate the x86 rootfs to support legacy and EFI bios config templates. # The templates are used by the installer to populate partition 12 with # the correct bootloader configuration. From ed037ea05c867e0d00a27797ecfa73b5ccae663d Mon Sep 17 00:00:00 2001 From: Brandon Philips Date: Wed, 17 Jul 2013 18:00:56 -0700 Subject: [PATCH 2/3] chore(build_library): remove efi image we don't really care about booting on pure efi systems right now and I don't think this all works so remove it for now. --- .../create_legacy_bootloader_templates.sh | 57 ------------------- update_bootloaders.sh | 7 --- 2 files changed, 64 deletions(-) diff --git a/build_library/create_legacy_bootloader_templates.sh b/build_library/create_legacy_bootloader_templates.sh index e9c533ff6b..d20ca6a91c 100755 --- a/build_library/create_legacy_bootloader_templates.sh +++ b/build_library/create_legacy_bootloader_templates.sh @@ -134,63 +134,6 @@ label coreos.B EOF info "Emitted ${SYSLINUX_DIR}/root.B.cfg" - cat </dev/null -Partition 12 contains the active bootloader configuration when -booting from a non-Chrome OS BIOS. EFI BIOSes use /efi/* -and legacy BIOSes use this syslinux configuration. -EOF - info "Emitted ${SYSLINUX_DIR}/README" - - # To cover all of our bases, now populate templated boot support for efi. - sudo mkdir -p "${FLAGS_to}"/efi/boot - - if [[ -f /bin/grub2-mkimage ]];then - # Use the newer grub2 1.99+ - sudo grub2-mkimage -p /efi/boot -O x86_64-efi \ - -o "${FLAGS_to}/efi/boot/bootx64.efi" \ - part_gpt fat ext2 hfs hfsplus normal boot chain configfile linux - else - # Remove this else case after a few weeks (sometime in Dec 2011) - sudo grub-mkimage -p /efi/boot -o "${FLAGS_to}/efi/boot/bootx64.efi" \ - part_gpt fat ext2 normal boot sh chain configfile linux - fi - # Templated variables: - # DMTABLEA, DMTABLEB -> '0 xxxx verity ... ' - # This should be replaced during postinst when updating the ESP. - cat </dev/null -set default=0 -set timeout=2 - -# NOTE: These magic grub variables are a Chrome OS hack. They are not portable. - -menuentry "local image A" { - linux \$grubpartA/boot/vmlinuz ${common_args} i915.modeset=1 cros_efi root=/dev/\$linuxpartA -} - -menuentry "local image B" { - linux \$grubpartB/boot/vmlinuz ${common_args} i915.modeset=1 cros_efi root=/dev/\$linuxpartB -} - -menuentry "verified image A" { - linux \$grubpartA/boot/vmlinuz ${common_args} ${verity_common} \ - i915.modeset=1 cros_efi root=${ROOTDEV} dm=\\"DMTABLEA\\" -} - -menuentry "verified image B" { - linux \$grubpartB/boot/vmlinuz ${common_args} ${verity_common} \ - i915.modeset=1 cros_efi root=${ROOTDEV} dm=\\"DMTABLEB\\" -} - -# FIXME: usb doesn't support verified boot for now -menuentry "Alternate USB Boot" { - linux (hd0,3)/boot/vmlinuz ${common_args} root=/dev/sdb3 i915.modeset=1 cros_efi -} -EOF - if [[ ${FLAGS_enable_rootfs_verification} -eq ${FLAGS_TRUE} ]]; then - sudo sed -i -e 's/^set default=.*/set default=2/' \ - "${FLAGS_to}/efi/boot/grub.cfg" - fi - info "Emitted ${FLAGS_to}/efi/boot/grub.cfg" exit 0 fi diff --git a/update_bootloaders.sh b/update_bootloaders.sh index d2eb7c6921..afe1bd95da 100755 --- a/update_bootloaders.sh +++ b/update_bootloaders.sh @@ -96,13 +96,6 @@ trap cleanup EXIT sudo mount "${ESP_DEV}" "${ESP_FS_DIR}" if [[ "${FLAGS_arch}" = "x86" || "${FLAGS_arch}" = "amd64" ]]; then - # Populate the EFI bootloader configuration - sudo mkdir -p "${ESP_FS_DIR}/efi/boot" - sudo cp "${FLAGS_from}"/efi/boot/bootx64.efi \ - "${ESP_FS_DIR}/efi/boot/bootx64.efi" - sudo cp "${FLAGS_from}/efi/boot/grub.cfg" \ - "${ESP_FS_DIR}/efi/boot/grub.cfg" - # Copy over the grub configurations for cloud machines and the # kernel into both the A and B slot sudo mkdir -p "${ESP_FS_DIR}"/boot/grub From 7ea2b4924f30c669f39077e946f271e30a33b19d Mon Sep 17 00:00:00 2001 From: Brandon Philips Date: Wed, 17 Jul 2013 18:02:27 -0700 Subject: [PATCH 3/3] feat(boot_kernel): add support for the boot kernel This adds the boot_kernel to the build boot partiton and updates the relevant config files. Mission accomplished. TODO: Update the installer to not worry about moving files around anymore --- bin/cros_make_image_bootable | 1 + .../create_legacy_bootloader_templates.sh | 27 ++++++++++--------- update_bootloaders.sh | 3 +++ 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/bin/cros_make_image_bootable b/bin/cros_make_image_bootable index 2a89df9215..70d42c4c8f 100755 --- a/bin/cros_make_image_bootable +++ b/bin/cros_make_image_bootable @@ -232,6 +232,7 @@ make_image_bootable() { --arch=${FLAGS_arch} \ --to="${bootloader_to}" \ --from="${FLAGS_rootfs_mountpoint}"/boot \ + --vmlinuz_boot_kernel="${FLAGS_rootfs_mountpoint}"/boot/vmlinuz-boot_kernel \ --vmlinuz="${FLAGS_rootfs_mountpoint}"/boot/vmlinuz \ ${bootloader_to_flags} diff --git a/build_library/create_legacy_bootloader_templates.sh b/build_library/create_legacy_bootloader_templates.sh index d20ca6a91c..796cf6ca81 100755 --- a/build_library/create_legacy_bootloader_templates.sh +++ b/build_library/create_legacy_bootloader_templates.sh @@ -72,6 +72,10 @@ if [[ "${FLAGS_arch}" = "x86" || "${FLAGS_arch}" = "amd64" ]]; then cat </dev/null timeout 0 +title CoreOS bootengine +root (hd0,0) +kernel /syslinux/vmlinuz-boot_kernel ${common_args} root=gptprio: cros_legacy + title CoreOS A root (hd0,0) kernel /syslinux/vmlinuz.A ${common_args} root=${ROOTA} cros_legacy @@ -82,12 +86,8 @@ kernel /syslinux/vmlinuz.B ${common_args} root=${ROOTB} cros_legacy EOF info "Emitted ${GRUB_DIR}/menu.lst.A" - cat </dev/null -default 1 -EOF - sudo sh -c "cat ${GRUB_DIR}/menu.lst.A >> ${GRUB_DIR}/menu.lst.B" + sudo cp ${GRUB_DIR}/menu.lst.A ${GRUB_DIR}/menu.lst.B info "Emitted ${GRUB_DIR}/menu.lst.B" - sudo cp ${GRUB_DIR}/menu.lst.A ${GRUB_DIR}/menu.lst # /boot/syslinux must be installed in partition 12 as /syslinux/. @@ -97,9 +97,9 @@ EOF cat </dev/null PROMPT 0 TIMEOUT 0 +DEFAULT boot_kernel -# the actual target -include /syslinux/default.cfg +include /syslinux/boot_kernel.cfg # coreos.A include /syslinux/root.A.cfg @@ -109,15 +109,16 @@ include /syslinux/root.B.cfg EOF info "Emitted ${SYSLINUX_DIR}/syslinux.cfg" - # To change the active target, only this file needs to change. - cat </dev/null -DEFAULT coreos.A -EOF - info "Emitted ${SYSLINUX_DIR}/default.cfg" - # Different files are used so that the updater can only touch the file it # needs to for a given change. This will minimize any potential accidental # updates issues, hopefully. + cat </dev/null +label boot_kernel + menu label boot_kernel + kernel vmlinuz-boot_kernel + append ${common_args} root=gptprio: cros_legacy +EOF + info "Emitted ${SYSLINUX_DIR}/boot_kernel.cfg" cat </dev/null label coreos.A menu label coreos.A diff --git a/update_bootloaders.sh b/update_bootloaders.sh index afe1bd95da..2144b180e7 100755 --- a/update_bootloaders.sh +++ b/update_bootloaders.sh @@ -32,6 +32,8 @@ DEFINE_integer to_size -1 \ "Size in bytes of 'to' to use if it is a file. -1 is ignored. (Default: -1)" DEFINE_string vmlinuz "/tmp/vmlinuz" \ "Path to the vmlinuz file to use (Default: /tmp/vmlinuz)" +DEFINE_string vmlinuz_boot_kernel "/tmp/vmlinuz-boot_kernel" \ + "Path to the vmlinuz-boot_kernel file to use (Default: /tmp/vmlinuz)" # Parse flags FLAGS "$@" || exit 1 @@ -108,6 +110,7 @@ if [[ "${FLAGS_arch}" = "x86" || "${FLAGS_arch}" = "amd64" ]]; then sudo cp -r "${FLAGS_from}"/syslinux/. "${ESP_FS_DIR}"/syslinux # Stage both kernels with the only one we built. + sudo cp -f "${FLAGS_vmlinuz_boot_kernel}" "${ESP_FS_DIR}"/syslinux/vmlinuz-boot_kernel sudo cp -f "${FLAGS_vmlinuz}" "${ESP_FS_DIR}"/syslinux/vmlinuz.A sudo cp -f "${FLAGS_vmlinuz}" "${ESP_FS_DIR}"/syslinux/vmlinuz.B