例如,如果作为裸机自动化的一部分,您需要更改机器的启动顺序,例如强制它从网络或远程 ISO 启动,您可以使用ipmitool设置启动顺序(或者只是强制下一次重新启动具体的引导方法)。
获取当前启动设备
可以使用 ipmi 查询当前 BIOS 引导设备顺序,使用 bootparam 选项,
bootparamGet or set various system boot option parameters.getGet boot parameter. Currently supported values for are:0 - Set In Progress1 - Service Partition Selector2 - Service Partition Scan3 - BMC Boot Flag Valid Bit Clearing4 - Boot Info Acknowledge5 - Boot Flags6 - Boot Initiator Info7 - Boot Initiator Mailbox
# IPMI_HOST=10.20.30.40# IPMI_USER=rootipmitool -H $IPMI_HOST -U $IPMI_USER chassis bootparam get 5chassis bootparam get 5Boot parameter version: 1Boot parameter 5 is valid/unlockedBoot parameter data: c008000000Boot 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_pxeSet Boot Device to force_pxe
如果我们再读一遍上面的选项,会得到
# ipmitool chassis bootparam get 5Boot parameter version: 1Boot parameter 5 is valid/unlockedBoot parameter data: 8004000000Boot 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=persistentSet Boot Device to cdrom
# ipmitool chassis bootparam get 5Boot parameter version: 1Boot parameter 5 is valid/unlockedBoot parameter data: c014000000Boot 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#oripmitool 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
