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

[Aboot] Support boot from device #12532

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
23 changes: 21 additions & 2 deletions files/Aboot/boot0.j2
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,20 @@ cmdline_allowlist="crashkernel hwaddr_ma1 sonic_fips"
# for backward compatibility with the sonic_upgrade= behavior
install="${install:-${sonic_upgrade:-}}"

# sets the boot device to boot from
boot_device="flash"

if grep -q block_drive= /etc/cmdline; then
boot_device="drive"

# ensure boot-config is up to date on flash
if [ -f "$boot_config" ] && [ "$(<"$boot_config" md5sum)" != "$(</mnt/flash/boot-config md5sum)" ]; then
cp "$boot_config" "/mnt/flash/boot-config"
reboot
fi

fi

is_secureboot_enabled() {
if $in_aboot; then
if [ -x /bin/securebootctl ] && securebootctl sb -display | grep -q "Secure Boot enabled"; then
Expand Down Expand Up @@ -147,6 +161,11 @@ update_boot_config() {
else
echo "$key=$value" >> "$boot_config"
fi

# Ensure boot_config at flash drive
if [ "$boot_device" != "flash" ]; then
cp "$boot_config" "/mnt/flash/boot-config"
fi
}

get_boot_config() {
Expand Down Expand Up @@ -390,7 +409,7 @@ extract_image() {
fi

## use new reduced-size boot swi
local swi_boot_path="flash:$image_name/$boot_image"
local swi_boot_path="$boot_device:$image_name/$boot_image"
update_boot_config SWI "$swi_boot_path"
update_boot_config SWI_DEFAULT "$swi_boot_path"

Expand All @@ -413,7 +432,7 @@ extract_image_secureboot() {
chmod a+r "$installer_image_path"
swipath="$installer_image_path"

local swi_boot_path="flash:$image_name/$installer_image"
local swi_boot_path="$boot_device:$image_name/$installer_image"
update_boot_config SWI "$swi_boot_path"
update_boot_config SWI_DEFAULT "$swi_boot_path"

Expand Down