mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-23 14:41:31 +02:00
update_bootloaders: use uuids for legacy boot.
BUG=chromium-os:14127,chromium-os:17184 TEST=Adhoc Build a regular image (for Alex) and boot it on a Dogfood machine (which uses legacy boot). Check dmesg for PARTUUID. Unpack partitions, mount partition 12, and check for root=PARTUUID= in /efi/grub/grub.cfg (it should be there instead of root=/dev/$linuxpart). Change-Id: Ie403632f227d514a5876f8338afa4ad80708ed55 Signed-off-by: Elly Jones <ellyjones@chromium.org> Reviewed-on: http://gerrit.chromium.org/gerrit/5668 Reviewed-by: Will Drewry <wad@chromium.org>
This commit is contained in:
parent
4dd4c54ccb
commit
dfd369431d
@ -71,6 +71,12 @@ FLAGS "$@" || exit 1
|
|||||||
eval set -- "${FLAGS_ARGV}"
|
eval set -- "${FLAGS_ARGV}"
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
part_index_to_uuid() {
|
||||||
|
local image="$1"
|
||||||
|
local index="$2"
|
||||||
|
cgpt show -i "$index" -u "$image"
|
||||||
|
}
|
||||||
|
|
||||||
# If not provided by chromeos-common.sh, this will update all of the
|
# If not provided by chromeos-common.sh, this will update all of the
|
||||||
# boot loader files (both A and B) with the data pulled
|
# boot loader files (both A and B) with the data pulled
|
||||||
# from the kernel_partition. The default boot target should
|
# from the kernel_partition. The default boot target should
|
||||||
@ -81,6 +87,7 @@ if ! type -p update_x86_bootloaders; then
|
|||||||
local kernel_cmdline="$2"
|
local kernel_cmdline="$2"
|
||||||
local esp_fs_dir="$3"
|
local esp_fs_dir="$3"
|
||||||
local template_dir="$4"
|
local template_dir="$4"
|
||||||
|
local to="$5"
|
||||||
|
|
||||||
# Pull out the dm="" values
|
# Pull out the dm="" values
|
||||||
dm_table=
|
dm_table=
|
||||||
@ -94,17 +101,24 @@ if ! type -p update_x86_bootloaders; then
|
|||||||
cros_flags="cros_legacy cros_debug"
|
cros_flags="cros_legacy cros_debug"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
root_a_uuid="PARTUUID=$(part_index_to_uuid "$to" 3)"
|
||||||
|
root_b_uuid="PARTUUID=$(part_index_to_uuid "$to" 5)"
|
||||||
|
|
||||||
# Rewrite grub table
|
# Rewrite grub table
|
||||||
grub_dm_table_a=${dm_table//${old_root}/\/dev\/\$linuxpartA}
|
grub_dm_table_a=${dm_table//${old_root}/${root_a_uuid}}
|
||||||
grub_dm_table_b=${dm_table//${old_root}/\/dev\/\$linuxpartB}
|
grub_dm_table_b=${dm_table//${old_root}/${root_b_uuid}}
|
||||||
sed -e "s|DMTABLEA|${grub_dm_table_a}|g" \
|
sed -e "s|DMTABLEA|${grub_dm_table_a}|g" \
|
||||||
-e "s|DMTABLEB|${grub_dm_table_b}|g" \
|
-e "s|DMTABLEB|${grub_dm_table_b}|g" \
|
||||||
-e "s|cros_legacy|${cros_flags}|g" \
|
-e "s|cros_legacy|${cros_flags}|g" \
|
||||||
"${template_dir}"/efi/boot/grub.cfg |
|
"${template_dir}"/efi/boot/grub.cfg |
|
||||||
sudo dd of="${esp_fs_dir}"/efi/boot/grub.cfg
|
sudo dd of="${esp_fs_dir}"/efi/boot/grub.cfg
|
||||||
|
sed -e "s|/dev/\\\$linuxpartA|${root_a_uuid}|g" \
|
||||||
|
-e "s|/dev/\\\$linuxpartB|${root_b_uuid}|g" \
|
||||||
|
"${template_dir}"/efi/boot/grub.cfg |
|
||||||
|
sudo dd of="${esp_fs_dir}"/efi/boot/grub.cfg
|
||||||
|
|
||||||
# Rewrite syslinux DM_TABLE
|
# Rewrite syslinux DM_TABLE
|
||||||
syslinux_dm_table_usb=${dm_table//${old_root}/${FLAGS_usb_disk}}
|
syslinux_dm_table_usb=${dm_table//${old_root}/${root_a_uuid}}
|
||||||
sed -e "s|DMTABLEA|${syslinux_dm_table_usb}|g" \
|
sed -e "s|DMTABLEA|${syslinux_dm_table_usb}|g" \
|
||||||
-e "s|cros_legacy|${cros_flags}|g" \
|
-e "s|cros_legacy|${cros_flags}|g" \
|
||||||
"${template_dir}"/syslinux/usb.A.cfg |
|
"${template_dir}"/syslinux/usb.A.cfg |
|
||||||
@ -205,7 +219,8 @@ if [[ "${FLAGS_arch}" = "x86" ]]; then
|
|||||||
update_x86_bootloaders "${old_root}" \
|
update_x86_bootloaders "${old_root}" \
|
||||||
"${kernel_cfg}" \
|
"${kernel_cfg}" \
|
||||||
"${ESP_FS_DIR}" \
|
"${ESP_FS_DIR}" \
|
||||||
"${FLAGS_from}"
|
"${FLAGS_from}" \
|
||||||
|
"${FLAGS_to}"
|
||||||
|
|
||||||
# Install the syslinux loader on the ESP image (part 12) so it is ready when
|
# Install the syslinux loader on the ESP image (part 12) so it is ready when
|
||||||
# we cut over from rootfs booting (extlinux).
|
# we cut over from rootfs booting (extlinux).
|
||||||
|
Loading…
x
Reference in New Issue
Block a user