[stordis-toc]
Introduction
An open networking switch can have more than one operating system on its disk, for example ONIE and a network operating system (NOS). The UEFI firmware starts the first entry in its boot order. Use efibootmgr through SSH to change the boot order without a console connection.
Prerequisites
- An x86 switch with UEFI firmware. The switch must start in UEFI mode (refer to Step 1).
- SSH access to the switch and a user account with root or sudo rights.
- The
efibootmgrtool on the system that runs at this time. - A recovery path: a console server, a remote power distribution unit (PDU) or a person on site.
What you need
- The management IP address of the switch.
- The boot entry number of the target system (refer to Step 1).
- If the target system is ONIE: the IP address that ONIE gets from DHCP (refer to Step 3).
 CAUTION
Use a one-time boot (efibootmgr -n) when possible. If the target system does not start, a power cycle starts the previous system again.
If the target system does not connect to the network, you cannot use SSH. Then you must use the console or remote power control.
Step 1: Examine the UEFI mode and the boot entries
- Connect to the switch with SSH.
- Type these commands:
ls /sys/firmware/efi efibootmgr
These commands only read data. You do not need sudo or root rights for them.
If the ls command shows No such file or directory, the switch uses legacy BIOS mode. Do not continue. Use a console connection.
Example output (Edgecore AS9716-32D with SONiC and ONIE):
| Field | Description |
|---|---|
BootCurrent |
The entry that the switch started from. |
BootNext |
The target for the next boot only. The output shows this field only when it is set. |
BootOrder |
The sequence of entries. The firmware starts the first entry that operates correctly. |
Boot0000* |
The entry number (hexadecimal) and the entry name. The * shows an active entry. The firmware does not start inactive entries. |
Timeout |
The time that the UEFI boot manager waits before it starts the first entry. This is not the GRUB timeout. |
 NOTE
The entry numbers are not the same on all switches. A new installation of a NOS can change the numbers.
Use the entry numbers from the output of your switch.
Command builder
Paste the output of efibootmgr into the field. Then click the target system. The builder shows the commands for your switch. The builder operates only in your browser and does not send data.
The command builder needs JavaScript.
Step 2: Start the target system one time
- Type the commands below. These commands change the firmware settings and need
sudoor root rights. Replace0000with the entry number of the target system. - Make sure that the output shows
BootNext: 0000before you reboot.
sudo efibootmgr -n 0000 sudo reboot
If you are the root user, type the commands without sudo.
To cancel the one-time boot before the reboot, type sudo efibootmgr -N.
After the reboot, the switch starts the target system. The firmware then deletes BootNext. The next reboot starts the first entry in BootOrder again.
Example output:
BootNext: 0000 BootCurrent: 0001 Timeout: 5 seconds BootOrder: 0001,0000,0007,0003,0004,0006 Boot0000* ONIE: Open Network Install Environment Boot0001* SONiC-OS Boot0003* Hard Drive Boot0004* UEFI: Built-in EFI Shell Boot0006* USB Boot0007* UEFI: SanDisk, Partition 1
Step 3: Connect to ONIE (only if the target system is ONIE)
ONIE does not use the management IP address of the NOS. ONIE gets an IP address from DHCP on the management port. The console shows the address, for example ONIE: Using DHCPv4 addr: eth0: 192.168.77.82.
- Find the IP address of the switch on your DHCP server.
- Connect to ONIE with SSH as the root user:
ssh root@<ONIE-IP>
The default ONIE root user has no password.
 CAUTION
Type onie-stop immediately after you log in. ONIE starts in Install mode. In Install mode, ONIE looks for a NOS installer on the network. If ONIE finds an installer, ONIE installs it and removes the current NOS.
onie-stop
To go back to the NOS, type reboot. The switch starts the first entry in BootOrder.
reboot
The ONIE boot menu with the default entry ONIE: Install OS:
Step 4 (optional): Change the boot order permanently
Do this step if the switch must always start a different system. Put the target entry first. Keep all other entries after it.
Example for the switch in Step 1 (BootOrder: 0001,0000,0007,0003,0004,0006).
Make ONIE (0000) the default system:
sudo efibootmgr -o 0000,0001,0007,0003,0004,0006 sudo reboot
Make SONiC (0001) the default system again:
sudo efibootmgr -o 0001,0000,0007,0003,0004,0006 sudo reboot
Make ONIE (0000) the default system:
efibootmgr -o 0000,0001,0007,0003,0004,0006 reboot
Make SONiC (0001) the default system again:
efibootmgr -o 0001,0000,0007,0003,0004,0006 reboot
CAUTION
Write all entry numbers from BootOrder in the command. The -o option replaces the full list. The firmware does not start an entry that is not in the list.
Step 5: Verify the result
- Connect to the switch with SSH.
- Type
efibootmgr. - Make sure that
BootCurrentshows the entry number of the target system.
efibootmgr
Example output after a one-time boot of ONIE (0000):
BootCurrent: 0000 Timeout: 5 seconds BootOrder: 0001,0000,0007,0003,0004,0006 Boot0000* ONIE: Open Network Install Environment Boot0001* SONiC-OS Boot0003* Hard Drive Boot0004* UEFI: Built-in EFI Shell Boot0006* USB Boot0007* UEFI: SanDisk, Partition 1
BootOrder does not change. After the next reboot, the switch starts SONiC (0001) again.
Procedure completion
Congratulations!
You have successfully changed the boot target of your switch. Now you can start ONIE or another NOS without a console connection.
Happy networking!
Â
Useful links:
How to Reset Password in SONiC?
How can I set up a console connection to Edgecore Open Networking switch?
Â
For more free resources, visit: https://stordis.com/free-resources/
Comments 0
Comments
Please sign in to leave a comment.