|
67 | 67 |
|
68 | 68 | mountpoint_for_file() {
|
69 | 69 | 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 |
71 | 71 | }
|
72 | 72 |
|
73 | 73 | # extract mount point from the swi path, e.g., /mnt/flash/sonic.swi --> /mnt/flash
|
@@ -402,7 +402,7 @@ extract_image() {
|
402 | 402 | extract_image_secureboot() {
|
403 | 403 | info "Extracting necessary swi content"
|
404 | 404 | # 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" |
406 | 406 |
|
407 | 407 | ## Extract platform.tar.gz
|
408 | 408 | info "Extracting platform.tar.gz"
|
@@ -442,7 +442,7 @@ write_machine_config() {
|
442 | 442 | ## Detect SKU and create a hardware description file
|
443 | 443 | aboot_version=$(cmdline_get Aboot | sed 's/^.*norcal.-//')
|
444 | 444 | 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') |
446 | 446 | else
|
447 | 447 | aboot_build_date="unknown"
|
448 | 448 | fi
|
@@ -655,10 +655,10 @@ write_platform_specific_cmdline() {
|
655 | 655 | else
|
656 | 656 | varlog_size=256
|
657 | 657 | cmdline_add logs_inram=on
|
| 658 | + cmdline_add docker_inram=on |
658 | 659 | if [ $flash_size -le 2000 ]; then
|
659 | 660 | # enable docker_inram for switches with less than 2G of flash
|
660 | 661 | varlog_size=128
|
661 |
| - cmdline_add docker_inram=on |
662 | 662 | fi
|
663 | 663 | fi
|
664 | 664 | fi
|
@@ -741,13 +741,19 @@ write_cmdline() {
|
741 | 741 | cat "$target_path/$kernel_params" | cmdline_append
|
742 | 742 | fi
|
743 | 743 |
|
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 |
751 | 757 |
|
752 | 758 | # FIXME: legacy configuration files used by fast-reboot and eos2sonic
|
753 | 759 | # these should be deprecated over time.
|
@@ -830,6 +836,10 @@ regular_install() {
|
830 | 836 | info "Installing image under $image_path"
|
831 | 837 | extract_image
|
832 | 838 |
|
| 839 | + # NOTE: this call is necessary to process the kernel-cmdline-append file coming |
| 840 | + # from the just extracted swi |
| 841 | + write_cmdline |
| 842 | + |
833 | 843 | run_hooks post-install
|
834 | 844 | }
|
835 | 845 |
|
|
0 commit comments