-
Notifications
You must be signed in to change notification settings - Fork 1.8k
202511 [PR:25067] [Arista] UEFI boot support for Arista platform #26532
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
base: 202511
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| ARISTA_SID="Redstart*Moby" | ||
| ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="modprobe.blacklist=snd_hda_intel,hdaudio,amd_sfh" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| ARISTA_SID="*MorandaP" | ||
| ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="modprobe.blacklist=snd_hda_intel,hdaudio,amd_sfh" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| ARISTA_SID="Shearwater*QuicksilverP" | ||
| ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="modprobe.blacklist=snd_hda_intel,hdaudio" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| ARISTA_SID="Redstart*QuicksilverP512" | ||
| ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="modprobe.blacklist=snd_hda_intel,hdaudio,amd_sfh" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| ARISTA_SID="PikeIslandZ PikeIslandZ-F PikeIslandZ-R PikeIslandZ-F PikeIslandZ-R" | ||
| ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| ARISTA_SID="*CitrineDd" | ||
| ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="modprobe.blacklist=snd_hda_intel,hdaudio,amd_sfh" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| ARISTA_SID="*CitrineDdBk" | ||
| ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="modprobe.blacklist=snd_hda_intel,hdaudio,amd_sfh" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,3 +6,4 @@ nls_cp437 | |
| nls_utf8 | ||
| nvme | ||
| zstd | ||
| efivarfs | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,159 @@ | ||||||||||||||||||||||||||||||||||||||||||||||
| #!/bin/sh -e | ||||||||||||||||||||||||||||||||||||||||||||||
| # This hook is the 2nd stage of the swi2bin installation | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| PREREQS="" | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| prereqs() { echo "$PREREQS"; } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| case $1 in | ||||||||||||||||||||||||||||||||||||||||||||||
| prereqs) | ||||||||||||||||||||||||||||||||||||||||||||||
| prereqs | ||||||||||||||||||||||||||||||||||||||||||||||
| exit 0 | ||||||||||||||||||||||||||||||||||||||||||||||
| ;; | ||||||||||||||||||||||||||||||||||||||||||||||
| esac | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| perform_swi2bin=false | ||||||||||||||||||||||||||||||||||||||||||||||
| verbose=false | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| for x in $(cat /proc/cmdline); do | ||||||||||||||||||||||||||||||||||||||||||||||
| case "$x" in | ||||||||||||||||||||||||||||||||||||||||||||||
| arista.swi2bin=verbose) | ||||||||||||||||||||||||||||||||||||||||||||||
| perform_swi2bin=true | ||||||||||||||||||||||||||||||||||||||||||||||
| verbose=true | ||||||||||||||||||||||||||||||||||||||||||||||
| ;; | ||||||||||||||||||||||||||||||||||||||||||||||
| arista.swi2bin|arista.swi2bin=*) | ||||||||||||||||||||||||||||||||||||||||||||||
| perform_swi2bin=true | ||||||||||||||||||||||||||||||||||||||||||||||
| ;; | ||||||||||||||||||||||||||||||||||||||||||||||
| esac | ||||||||||||||||||||||||||||||||||||||||||||||
| done | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| if ! $perform_swi2bin; then | ||||||||||||||||||||||||||||||||||||||||||||||
| exit 0 | ||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| if $verbose; then | ||||||||||||||||||||||||||||||||||||||||||||||
| set -x | ||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| log() { | ||||||||||||||||||||||||||||||||||||||||||||||
| echo "[+] $@" | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| is_bin_signed() { | ||||||||||||||||||||||||||||||||||||||||||||||
| test "$(tail -n 1 "$1")" = "-----END CMS-----" | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| log "Entering initrd phase of installation" | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| nosname=SONiC-OS | ||||||||||||||||||||||||||||||||||||||||||||||
| image_name="$(cat /proc/cmdline | sed -e 's/.*loop=\(\S*\)\/.*/\1/')" | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| bin_signed=false | ||||||||||||||||||||||||||||||||||||||||||||||
| if is_bin_signed "$rootmnt/host/$image_name/sonic.bin"; then | ||||||||||||||||||||||||||||||||||||||||||||||
| bin_signed=true | ||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+48
to
+54
|
||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| log "Mounting root filesystem" | ||||||||||||||||||||||||||||||||||||||||||||||
| rootdir=/install-root | ||||||||||||||||||||||||||||||||||||||||||||||
| installtmp=/tmp/install | ||||||||||||||||||||||||||||||||||||||||||||||
| rwdir="$installtmp/rw" | ||||||||||||||||||||||||||||||||||||||||||||||
| workdir="$installtmp/workdir" | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| mkdir -p "$rootdir" | ||||||||||||||||||||||||||||||||||||||||||||||
| mkdir -p "$installtmp" | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| mount -t tmpfs none "$installtmp" | ||||||||||||||||||||||||||||||||||||||||||||||
| mkdir -p "$rwdir" | ||||||||||||||||||||||||||||||||||||||||||||||
| mkdir -p "$workdir" | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| mount -n -o "lowerdir=$rootmnt,upperdir=$rwdir,workdir=$workdir" -t overlay root-overlay "$rootdir" | ||||||||||||||||||||||||||||||||||||||||||||||
| mount -o bind "$rootmnt/host" "$rootdir/host" | ||||||||||||||||||||||||||||||||||||||||||||||
| mount -t proc proc "$rootdir/proc" | ||||||||||||||||||||||||||||||||||||||||||||||
| mount -t devtmpfs udev "$rootdir/dev" | ||||||||||||||||||||||||||||||||||||||||||||||
| mount -t sysfs sysfs "$rootdir/sys" | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| log "Installing grub" | ||||||||||||||||||||||||||||||||||||||||||||||
| espdev="$(blkid --label ESP)" | ||||||||||||||||||||||||||||||||||||||||||||||
| blkdev="/dev/$(basename "$(readlink -f "/sys/class/block/$(basename "$espdev")/..")")" | ||||||||||||||||||||||||||||||||||||||||||||||
| esppartnum="$(echo "$espdev" | grep -Eo '[0-9]+$')" | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| mkdir -p "$rootdir/boot" | ||||||||||||||||||||||||||||||||||||||||||||||
| mount -o bind "$rootmnt/host/$image_name/boot" "$rootdir/boot" | ||||||||||||||||||||||||||||||||||||||||||||||
| mkdir -p "$rootdir/boot/efi" | ||||||||||||||||||||||||||||||||||||||||||||||
| mount "$espdev" "$rootdir/boot/efi" | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+75
to
+83
|
||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| # ensure grub folder exists | ||||||||||||||||||||||||||||||||||||||||||||||
| mkdir -p "$rootdir/host/grub" | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| # mounting efivarfs which is necessary for efitools to work | ||||||||||||||||||||||||||||||||||||||||||||||
| mount -t efivarfs efivarfs "$rootdir/sys/firmware/efi/efivars" | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| # installing grub packages from platform.tar.gz | ||||||||||||||||||||||||||||||||||||||||||||||
| chroot "$rootdir" sh -c "dpkg -i /host/$image_name/platform/grub/*" | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| # install grub-efi on /boot/efi/SONiC-OS and configuration on /host/grub/ | ||||||||||||||||||||||||||||||||||||||||||||||
| chroot "$rootdir" grub-install \ | ||||||||||||||||||||||||||||||||||||||||||||||
| --target=x86_64-efi \ | ||||||||||||||||||||||||||||||||||||||||||||||
| --boot-directory=/host \ | ||||||||||||||||||||||||||||||||||||||||||||||
| --efi-directory=/boot/efi \ | ||||||||||||||||||||||||||||||||||||||||||||||
| --bootloader-id=$nosname | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| if $bin_signed; then | ||||||||||||||||||||||||||||||||||||||||||||||
| log "Installing signed shim/grub/mm" | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| # installing signed grub, shim, mm and other efi tools | ||||||||||||||||||||||||||||||||||||||||||||||
| mkdir -p "$rootdir/boot/efi/EFI/$nosname" | ||||||||||||||||||||||||||||||||||||||||||||||
| cp "$rootdir/host/$image_name/boot/"*.efi "$rootdir/boot/efi/EFI/$nosname" | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
| cp "$rootdir/host/$image_name/boot/"*.efi "$rootdir/boot/efi/EFI/$nosname" | |
| set -- "$rootdir/host/$image_name/boot/"*.efi | |
| if [ ! -e "$1" ]; then | |
| echo "Error: expected signed EFI artifacts matching $rootdir/host/$image_name/boot/*.efi, but none were found" >&2 | |
| exit 1 | |
| fi | |
| cp "$@" "$rootdir/boot/efi/EFI/$nosname" |
Copilot
AI
Apr 4, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This writes a new /host/grub/grub.cfg via cat > ..., which overwrites any existing configuration. The subsequent sed -i only deletes the injected entry and cannot restore the original file contents. To avoid data loss, either (a) append the temporary entry and remove it later, or (b) back up the original grub.cfg and restore it after the installer completes (including on failure paths).
Copilot
AI
Apr 4, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rm -rf "/tmp/host/$image_name" can delete unintended host-partition data if $image_name is empty or not the expected directory name (it is derived from kernel cmdline parsing). Add a guard (e.g., ensure image_name matches an expected prefix and that the target path is within /tmp/host/ and exists as a directory) before performing this removal.
| rm -rf "/tmp/host/$image_name" | |
| target_dir="/tmp/host/$image_name" | |
| case "$image_name" in | |
| ""|.|..|*/*) | |
| log "Refusing to remove unexpected image directory: $image_name" | |
| ;; | |
| *) | |
| if [ -d "$target_dir" ]; then | |
| target_real="$(cd "$target_dir" 2>/dev/null && pwd -P)" || target_real="" | |
| case "$target_real" in | |
| /tmp/host/*) | |
| rm -rf -- "$target_dir" | |
| ;; | |
| *) | |
| log "Refusing to remove path outside /tmp/host: $target_dir" | |
| ;; | |
| esac | |
| else | |
| log "Skipping cleanup for missing image directory: $target_dir" | |
| fi | |
| ;; | |
| esac |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| #!/bin/sh -e | ||
|
|
||
| PREREQS="" | ||
| PREREQS="swi2bin" | ||
|
|
||
| prereqs() { echo "$PREREQS"; } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -595,6 +595,7 @@ menuentry '$demo_grub_entry' { | |||||
| if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi | ||||||
| insmod part_msdos | ||||||
| insmod ext2 | ||||||
| insmod efi_gop | ||||||
|
||||||
| insmod efi_gop | |
| if [ x$grub_platform = xefi ]; then insmod efi_gop; fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is_bin_signed()runstail -n 1on the provided path. With#!/bin/sh -e, if the file is missing (e.g., due to a parsing issue forimage_nameor an unexpected layout),tailwill fail and abort the initramfs script, potentially breaking boot. Add an explicit existence/readability check (e.g., return false if the file is absent) before callingtail.