|
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
|
@@ -701,27 +701,40 @@ write_default_cmdline() {
|
701 | 701 | cmdline_clear
|
702 | 702 |
|
703 | 703 | if $in_aboot; then
|
704 |
| - # generate the default kernel parameters for the platform |
| 704 | + # Generate the default kernel parameters for the platform |
705 | 705 | cat /etc/cmdline | sed "/^\(${bootconfigvars// /\|}\|crashkernel\|loglevel\|ignore_loglevel\)\(\$\|=\)/d;/^\$/d" | cmdline_append
|
706 |
| - elif grep -q "$delimiter" /proc/cmdline; then |
707 |
| - # we are on a recent sonic image using delimiter. extracting the part of the |
| 706 | + elif grep -q "$delimiter" /proc/cmdline && ! grep -Eq "varlog_size=.* $delimiter" /proc/cmdline; then |
| 707 | + # We are on a recent sonic image using delimiter. extracting the part of the |
708 | 708 | # cmdline coming from aboot is trivial.
|
| 709 | + # The 2nd part of the condition ensures that the append bug is not present. |
| 710 | + # When it is it should go through the last case of this if/else block to |
| 711 | + # regenerate the aboot cmdline |
709 | 712 | cat /proc/cmdline | sed -E "s/^(.*) $delimiter .*$/\1/" | tr ' ' '\n' | cmdline_append
|
710 |
| - else |
711 |
| - # we are either on SONiC or EOS and the commandline doesn't have a delimiter |
712 |
| - # for the Aboot part. Take an educated guess at a right delimiter. |
713 |
| - # Subject to breakage if EOS or SONiC cmdline change. |
| 713 | + elif grep -q "SWI=" /proc/cmdline; then |
| 714 | + # We are in EOS and the cmdline doesn't have a delimiter for the aboot part |
714 | 715 | cat /proc/cmdline | sed -E 's/^(.*) rw .*$/\1/' | tr ' ' '\n' | cmdline_append
|
| 716 | + else |
| 717 | + # We are in SONiC and the cmdline doesn't have a delimiter for the aboot part. |
| 718 | + # sid= should most of the time be the last parameter provided by Aboot |
| 719 | + # Alternatively we are in SONiC and the cmdline-aboot-end delimiter was |
| 720 | + # added after image specific parameters due to a BUG which is solved by the |
| 721 | + # following statement. |
| 722 | + cat /proc/cmdline | sed -E 's/^(.* sid=[^ ]+).*$/\1/' | tr ' ' '\n' | cmdline_append |
715 | 723 | fi
|
716 | 724 |
|
717 | 725 | cmdline_add "$delimiter"
|
718 | 726 | }
|
719 | 727 |
|
720 | 728 | write_cmdline() {
|
721 | 729 | # use extra parameters from kernel-params hook if the file exists
|
722 |
| - if [ -f "$target_path/$kernel_params" ] && ! $secureboot; then |
723 |
| - info "Loading extra kernel parameters from $kernel_params" |
724 |
| - cat "$target_path/$kernel_params" | cmdline_append |
| 730 | + if [ -f "$target_path/$kernel_params" ]; then |
| 731 | + if $secureboot && $debug; then |
| 732 | + warn "Unsafe: Loading extra kernel parameters from $kernel_params" |
| 733 | + cat "$target_path/$kernel_params" | cmdline_append |
| 734 | + elif ! $secureboot; then |
| 735 | + info "Loading extra kernel parameters from $kernel_params" |
| 736 | + cat "$target_path/$kernel_params" | cmdline_append |
| 737 | + fi |
725 | 738 | fi
|
726 | 739 |
|
727 | 740 | # FIXME: sonic sometimes adds extra kernel parameters from user space
|
@@ -807,12 +820,12 @@ regular_install() {
|
807 | 820 |
|
808 | 821 | mkdir -p $image_path
|
809 | 822 |
|
810 |
| - info "Generating boot-config, machine.conf and cmdline" |
811 |
| - write_regular_configs "$image_path" |
812 |
| - |
813 | 823 | info "Installing image under $image_path"
|
814 | 824 | extract_image
|
815 | 825 |
|
| 826 | + info "Generating boot-config, machine.conf and cmdline" |
| 827 | + write_regular_configs "$image_path" |
| 828 | + |
816 | 829 | run_hooks post-install
|
817 | 830 | }
|
818 | 831 |
|
|
0 commit comments