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

[installer] Create a blank grubenv if doesn't exist #17414

Merged
merged 1 commit into from
Dec 14, 2023

Conversation

nazariig
Copy link
Collaborator

@nazariig nazariig commented Dec 5, 2023

GRUB environment file is neither generated when SONiC is installed from ONiE nor when GRUB starts boot chain sequence

https://github.com/sonic-net/sonic-buildimage/blob/202305/installer/default_platform.conf#L506

    cat <<EOF >> $grub_cfg
if [ -s \$prefix/grubenv ]; then
    load_env
fi
if [ "\${saved_entry}" ]; then
    set default="\${saved_entry}"
fi
if [ "\${next_entry}" ]; then
    set default="\${next_entry}"
    unset next_entry
    save_env next_entry
fi
if [ "\${onie_entry}" ]; then
    set next_entry="\${default}"
    set default="\${onie_entry}"
    unset onie_entry
    save_env onie_entry next_entry
fi
EOF

The GRUB environment file is being regenerated (if not present) each time after system cold reboot, when SONiC reboot script is being called

https://github.com/sonic-net/sonic-utilities/blob/202305/scripts/reboot#L152

# Verify the next image by sonic-installer
local message=$(sonic-installer verify-next-image 2>&1)
if [ $? -ne 0 ]; then
    VERBOSE=yes debug "Failed to verify next image: ${message}"
    exit ${EXIT_SONIC_INSTALLER_VERIFY_REBOOT}
fi

In fact, GRUB environment list command is responsible for regeneration

root@r-anaconda-15:/home/admin# ls /host/grub/
fonts  grub.cfg  grubenv  i386-pc  locale
root@r-anaconda-15:/home/admin# rm -f /host/grub/grubenv
root@r-anaconda-15:/home/admin# ls /host/grub/
fonts  grub.cfg  i386-pc  locale
root@r-anaconda-15:/home/admin# grub-editenv /host/grub/grubenv list
root@r-anaconda-15:/home/admin# ls /host/grub/
fonts  grub.cfg  grubenv  i386-pc  locale

Why I did it

  • To fix BIOS firmware update after fresh image installation from ONiE
Work item tracking
  • N/A

How I did it

  • Initialized empty GRUB environment file after ONiE installation

How to verify it

  1. Install image from ONiE
  2. Run BIOS firmware upgrade

Which release branch to backport (provide reason below if selected)

  • 201811
  • 201911
  • 202006
  • 202012
  • 202106
  • 202111
  • 202205
  • 202211
  • 202305

Tested branch (Please provide the tested image version)

Description for the changelog

  • N/A

Link to config_db schema for YANG module changes

  • N/A

A picture of a cute animal (not mandatory but encouraged)

      .---.        .-----------
     /     \  __  /    ------
    / /     \(  )/    -----
   //////   ' \/ `   ---
  //// / // :    : ---
 // /   /  /`    '--
//          //..\\
       ====UU====UU====
           '//||\\`
             ''``

@nazariig
Copy link
Collaborator Author

nazariig commented Dec 5, 2023

/azpw run

@mssonicbld
Copy link
Collaborator

/AzurePipelines run

Copy link

You have several pipelines (over 10) configured to build pull requests in this repository. Specify which pipelines you would like to run by using /azp run [pipelines] command. You can specify multiple pipelines using a comma separated list.

@nazariig
Copy link
Collaborator Author

nazariig commented Dec 5, 2023

/azpw run Azure.sonic-buildimage

@mssonicbld
Copy link
Collaborator

/AzurePipelines run Azure.sonic-buildimage

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@dgsudharsan
Copy link
Collaborator

@StormLiangMS Tested on top of 202305 commit 688245a

@saiarcot895
Copy link
Contributor

What was the issue in #17216? What is being fixed here?

@nazariig
Copy link
Collaborator Author

What was the issue in #17216? What is being fixed here?

@saiarcot895 this fix includes a secure upgrade case

@liat-grozovik liat-grozovik merged commit 6d043a2 into sonic-net:master Dec 14, 2023
23 checks passed
@liat-grozovik liat-grozovik changed the title [installer]: Create a blank grubenv if doesn't exist [installer] Create a blank grubenv if doesn't exist Dec 14, 2023
mssonicbld pushed a commit to mssonicbld/sonic-buildimage that referenced this pull request Dec 15, 2023
- Why I did it
To fix BIOS firmware update after fresh image installation from ONiE

- How I did it
Initialized empty GRUB environment file after ONiE installation

- How to verify it
Install image from ONiE
Run BIOS firmware upgrade

Signed-off-by: Nazarii Hnydyn <[email protected]>
@mssonicbld
Copy link
Collaborator

Cherry-pick PR to 202305: #17525

mssonicbld pushed a commit to mssonicbld/sonic-buildimage that referenced this pull request Jan 31, 2024
- Why I did it
To fix BIOS firmware update after fresh image installation from ONiE

- How I did it
Initialized empty GRUB environment file after ONiE installation

- How to verify it
Install image from ONiE
Run BIOS firmware upgrade

Signed-off-by: Nazarii Hnydyn <[email protected]>
@mssonicbld
Copy link
Collaborator

Cherry-pick PR to 202311: #17965

mssonicbld pushed a commit that referenced this pull request Feb 1, 2024
- Why I did it
To fix BIOS firmware update after fresh image installation from ONiE

- How I did it
Initialized empty GRUB environment file after ONiE installation

- How to verify it
Install image from ONiE
Run BIOS firmware upgrade

Signed-off-by: Nazarii Hnydyn <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants