Skip to content

Commit 467994c

Browse files
Staphylolguohan
authored andcommitted
[Arista] Fix boot0 code for docker_inram
Enable docker_inram for all systems with 4GB or less of flash. This is mandatory to allow these systems to store 2 SONiC images. This change also fixes the missing docker_inram attribute when installing a new image from SONiC. Because the SWI image can ship with additional kernel parameters within such as `sonic_fips=` this lead to a conflict. To prevent the conflict, the extra kernel parameters from the SWI are now stored in the file `kernel-cmdline-append` which isn't used anywhere.
1 parent 37eddd4 commit 467994c

File tree

2 files changed

+25
-15
lines changed

2 files changed

+25
-15
lines changed

build_image.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,12 @@ elif [ "$IMAGE_TYPE" = "aboot" ]; then
202202
zip -g $OUTPUT_ABOOT_IMAGE .platforms_asic
203203

204204
if [ "$ENABLE_FIPS" = "y" ]; then
205-
echo "sonic_fips=1" > kernel-cmdline
205+
echo "sonic_fips=1" >> kernel-cmdline-append
206206
else
207-
echo "sonic_fips=0" > kernel-cmdline
207+
echo "sonic_fips=0" >> kernel-cmdline-append
208208
fi
209-
zip -g $OUTPUT_ABOOT_IMAGE kernel-cmdline
210-
rm kernel-cmdline
209+
zip -g $OUTPUT_ABOOT_IMAGE kernel-cmdline-append
210+
rm kernel-cmdline-append
211211

212212
zip -g $OUTPUT_ABOOT_IMAGE $ABOOT_BOOT_IMAGE
213213
rm $ABOOT_BOOT_IMAGE

files/Aboot/boot0.j2

+21-11
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ fi
6767

6868
mountpoint_for_file() {
6969
local file="$1"
70-
df "$file" | tail -1 | tr -s " " | cut -d ' ' -f6
70+
df "$file" 2>/dev/null | tail -1 | tr -s " " | cut -d ' ' -f6
7171
}
7272

7373
# extract mount point from the swi path, e.g., /mnt/flash/sonic.swi --> /mnt/flash
@@ -402,7 +402,7 @@ extract_image() {
402402
extract_image_secureboot() {
403403
info "Extracting necessary swi content"
404404
# NOTE: boot/ is not used by the boot process but only extracted for kdump
405-
unzip -oq "$swipath" 'boot/*' .imagehash -d "$image_path"
405+
unzip -oq "$swipath" 'boot/*' .imagehash kernel-cmdline-append -d "$image_path"
406406

407407
## Extract platform.tar.gz
408408
info "Extracting platform.tar.gz"
@@ -442,7 +442,7 @@ write_machine_config() {
442442
## Detect SKU and create a hardware description file
443443
aboot_version=$(cmdline_get Aboot | sed 's/^.*norcal.-//')
444444
if [ -x /bin/sysinit ]; then
445-
aboot_build_date=$(stat -c %y /bin/sysinit | sed 's/ /T/')
445+
aboot_build_date=$(stat -c %y /bin/sysinit | sed 's/ /T/g')
446446
else
447447
aboot_build_date="unknown"
448448
fi
@@ -655,10 +655,10 @@ write_platform_specific_cmdline() {
655655
else
656656
varlog_size=256
657657
cmdline_add logs_inram=on
658+
cmdline_add docker_inram=on
658659
if [ $flash_size -le 2000 ]; then
659660
# enable docker_inram for switches with less than 2G of flash
660661
varlog_size=128
661-
cmdline_add docker_inram=on
662662
fi
663663
fi
664664
fi
@@ -741,13 +741,19 @@ write_cmdline() {
741741
cat "$target_path/$kernel_params" | cmdline_append
742742
fi
743743

744-
# FIXME: sonic sometimes adds extra kernel parameters from user space
745-
# this is unsafe but some will be kept as part of the regular boot
746-
if [ -f "$image_path/kernel-cmdline" ]; then
747-
for field in $cmdline_allowlist; do
748-
cat "$image_path/kernel-cmdline" | tr ' ' '\n' | grep -E "$field" | tail -n 1 | cmdline_append
749-
done
750-
fi
744+
# NOTE: SONiC might need to provide some extra kernel parameter to change the
745+
# next boot behavior. The following lines lookup allowed parameters and
746+
# append them to the cmdline.
747+
# - kernel-cmdline is still modified but its usage should ideally be deprecated over time
748+
# - kernel-cmdline-append is for the user (SONiC) to use.
749+
# this file can be either packaged in the swi or generated from userland
750+
for cpath in "$image_path/kernel-cmdline" "$image_path/kernel-cmdline-append"; do
751+
if [ -f "$cpath" ]; then
752+
for field in $cmdline_allowlist; do
753+
cat "$cpath" | tr ' ' '\n' | grep -E "$field" | tail -n 1 | cmdline_append
754+
done
755+
fi
756+
done
751757

752758
# FIXME: legacy configuration files used by fast-reboot and eos2sonic
753759
# these should be deprecated over time.
@@ -830,6 +836,10 @@ regular_install() {
830836
info "Installing image under $image_path"
831837
extract_image
832838

839+
# NOTE: this call is necessary to process the kernel-cmdline-append file coming
840+
# from the just extracted swi
841+
write_cmdline
842+
833843
run_hooks post-install
834844
}
835845

0 commit comments

Comments
 (0)