例如,如果作为裸机自动化的一部分,您需要更改机器的启动顺序,例如强制它从网络或远程 ISO 启动,您可以使用ipmitool设置启动顺序(或者只是强制下一次重新启动具体的引导方法)。

获取当前启动设备

可以使用 ipmi 查询当前 BIOS 引导设备顺序,使用 bootparam 选项,

  1. bootparam
  2. Get or set various system boot option parameters.
  3. get
  4. Get boot parameter. Currently supported values for are:
  5. 0 - Set In Progress
  6. 1 - Service Partition Selector
  7. 2 - Service Partition Scan
  8. 3 - BMC Boot Flag Valid Bit Clearing
  9. 4 - Boot Info Acknowledge
  10. 5 - Boot Flags
  11. 6 - Boot Initiator Info
  12. 7 - Boot Initiator Mailbox
  1. # IPMI_HOST=10.20.30.40
  2. # IPMI_USER=root
  3. ipmitool -H $IPMI_HOST -U $IPMI_USER chassis bootparam get 5
  4. chassis bootparam get 5
  5. Boot parameter version: 1
  6. Boot parameter 5 is valid/unlocked
  7. Boot parameter data: c008000000
  8. Boot Flags :
  9. - Boot Flag Valid
  10. - Options apply to all future boots
  11. - BIOS PC Compatible (legacy) boot  
  12. - Boot Device Selector : Force Boot from default Hard-Drive
  13. - Console Redirection control : System Default
  14. - BIOS verbosity : Console redirection occurs per BIOS configuration setting (default)
  15. - BIOS Mux Control Override : BIOS uses recommended setting of the mux at the end of POST

设置下次启动时的启动方式

  1. # ipmitool chassis bootparam set bootflag force_pxe
  2. Set Boot Device to force_pxe

如果我们再读一遍上面的选项,会得到

  1. # ipmitool chassis bootparam get 5
  2. Boot parameter version: 1
  3. Boot parameter 5 is valid/unlocked
  4. Boot parameter data: 8004000000
  5. Boot Flags :
  6. - Boot Flag Valid
  7. - Options apply to only next boot
  8. - BIOS PC Compatible (legacy) boot
  9. - Boot Device Selector : Force PXE
  10. - Console Redirection control : System Default
  11. - BIOS verbosity : Console redirection occurs per BIOS configuration setting (default)
  12. - BIOS Mux Control Override : BIOS uses recommended setting of the mux at the end of POST

设置固定启动设备(持久化)

  1. # ipmitool chassis bootdev cdrom options=persistent
  2. Set Boot Device to cdrom
  1. # ipmitool chassis bootparam get 5
  2. Boot parameter version: 1
  3. Boot parameter 5 is valid/unlocked
  4. Boot parameter data: c014000000
  5. Boot Flags :
  6. - Boot Flag Valid
  7. - Options apply to all future boots
  8. - BIOS PC Compatible (legacy) boot
  9. - Boot Device Selector : Force Boot from CD/DVD
  10. - Console Redirection control : System Default
  11. - BIOS verbosity : Console redirection occurs per BIOS configuration setting (default)
  12. - BIOS Mux Control Override : BIOS uses recommended setting of the mux at the end of POST

What about UEFI

几乎是一样的,只要在options参数中添加’ efiboot ‘。

  1. ipmitool chassis bootdev pxe options=efiboot
  2. #or
  3. 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