例如,如果作为裸机自动化的一部分,您需要更改机器的启动顺序,例如强制它从网络或远程 ISO 启动,您可以使用ipmitool设置启动顺序(或者只是强制下一次重新启动具体的引导方法)。
获取当前启动设备
可以使用 ipmi 查询当前 BIOS 引导设备顺序,使用 bootparam
选项,
bootparam
Get or set various system boot option parameters.
get
Get boot parameter. Currently supported values for are:
0 - Set In Progress
1 - Service Partition Selector
2 - Service Partition Scan
3 - BMC Boot Flag Valid Bit Clearing
4 - Boot Info Acknowledge
5 - Boot Flags
6 - Boot Initiator Info
7 - Boot Initiator Mailbox
# IPMI_HOST=10.20.30.40
# IPMI_USER=root
ipmitool -H $IPMI_HOST -U $IPMI_USER chassis bootparam get 5
chassis bootparam get 5
Boot parameter version: 1
Boot parameter 5 is valid/unlocked
Boot parameter data: c008000000
Boot Flags :
- Boot Flag Valid
- Options apply to all future boots
- BIOS PC Compatible (legacy) boot
- Boot Device Selector : Force Boot from default Hard-Drive
- Console Redirection control : System Default
- BIOS verbosity : Console redirection occurs per BIOS configuration setting (default)
- BIOS Mux Control Override : BIOS uses recommended setting of the mux at the end of POST
设置下次启动时的启动方式
# ipmitool chassis bootparam set bootflag force_pxe
Set Boot Device to force_pxe
如果我们再读一遍上面的选项,会得到
# ipmitool chassis bootparam get 5
Boot parameter version: 1
Boot parameter 5 is valid/unlocked
Boot parameter data: 8004000000
Boot Flags :
- Boot Flag Valid
- Options apply to only next boot
- BIOS PC Compatible (legacy) boot
- Boot Device Selector : Force PXE
- Console Redirection control : System Default
- BIOS verbosity : Console redirection occurs per BIOS configuration setting (default)
- BIOS Mux Control Override : BIOS uses recommended setting of the mux at the end of POST
设置固定启动设备(持久化)
# ipmitool chassis bootdev cdrom options=persistent
Set Boot Device to cdrom
# ipmitool chassis bootparam get 5
Boot parameter version: 1
Boot parameter 5 is valid/unlocked
Boot parameter data: c014000000
Boot Flags :
- Boot Flag Valid
- Options apply to all future boots
- BIOS PC Compatible (legacy) boot
- Boot Device Selector : Force Boot from CD/DVD
- Console Redirection control : System Default
- BIOS verbosity : Console redirection occurs per BIOS configuration setting (default)
- BIOS Mux Control Override : BIOS uses recommended setting of the mux at the end of POST
What about UEFI
几乎是一样的,只要在options参数中添加’ efiboot ‘。
ipmitool chassis bootdev pxe options=efiboot
#or
ipmitool chassis bootdev pxe options=efiboot,persistent
推荐阅读
Just a moment…
IPMI trick: Set the boot device | ma.ttwagner.com
How to query the current BIOS boot device order using ipmi ? - Red Hat Customer Portal
Unable to set options=efiboot,persistent · Issue #163 · ipmitool/ipmitool
bootparam get 5 for boot mode shows wrong boot mode · Issue #236 · ipmitool/ipmitool
ironic