なにかの技術メモ置き場

なにかの技術メモ置き場

@インフラエンジニア

IPMIが便利すぎる

概要

IPMI(Intelligent Platform Management Interface)が便利すぎるので、よく使うものをまとめた。

どんな不便が解消できるのか

  • BIOSに入るために特定のキー(F2とかDelとか)を連打するのが不便。タイミングミスるとさらに不便に。
  • マシンがハングしたので電源長押しして強制リセットしたいが、いちいちマシンの場所まで行かなければならないのが不便。
  • BIOSの設定をするためにマシンにモニタとキーボードを接続しなければならないのが不便。

どう便利になるか

  • リモートからコマンドを2つ実行し、待っているだけ。連打する必要もない。
  • リモートからコマンドを1つ実行するだけ。
  • リモートからできる。モニタもキーボードも接続不要。

どうやるのか

何はともあれ先に結論を。冒頭の例に応える形で具体例を以て。

  • キーを連打やタイミング待ち不要でBIOSに入る
ipmitool -I lanplus -H IPアドレス -U ユーザ名 -P パスワード chassis bootdev bios
ipmitool -I lanplus -H IPアドレス -U ユーザ名 -P パスワード power cycle
  • リモートからマシンを強制リセットする
ipmitool -I lanplus -H IPアドレス -U ユーザ名 -P パスワード power cycle
  • リモートからBIOS設定をする
ipmitool -I lanplus -H IPアドレス -U ユーザ名 -P パスワード sol activate

BIOS設定画面に入っている前提とする。入っていない場合は1つ目の例を実施すれば良い。

前提

遅くなったけど前提。

  • IPMIを搭載したマシンであること。
    • 必然的にサーバのみが該当する。残念ながらコンシューマ向けPCは該当しない。
  • リモート管理用のIPアドレス、ユーザ、パスワードが設定済みであること。
    • さすがに初期設定はマシンにモニタとキーボードを接続して行う。やりようによってはそれすら不要にできるが(DHCPなど)。
  • BIOSのコンソールリダイレクションの設定が有効であること。
  • クライアントにipmitoolコマンドがインストール済みであること。
    • OSにより導入方法が異なるのでそこは各自にお任せ。当記事ではCentOS8をクライアントとする。

IPMI搭載機器例

メーカー IPMI 機種 備考
HPE iLO ProLiant DL360 Gen10
富士通 iRMC PRIMERGY RX100 S7
NEC BMC ? -
DELL iDRAC ? -
IBM ? ? -

コマンド紹介

powerコマンド

電源の状態を表示

構文

ipmitool -I lanplus -H IPアドレス -U ユーザ名 -P パスワード power status

実行結果

[root@client ~]# ipmitool -I lanplus -H 172.16.0.102 -U Administrator -P Administrator power status
Chassis Power is on
電源オン

構文

ipmitool -I lanplus -H IPアドレス -U ユーザ名 -P パスワード power on

実行結果

[root@client ~]# ipmitool -I lanplus -H 172.16.0.102 -U Administrator -P Administrator power on
Chassis Power Control: Up/On
電源オフ(電源ボタン長押しなどの強制電源断)

構文

ipmitool -I lanplus -H IPアドレス -U ユーザ名 -P パスワード power off

実行結果

[root@client ~]# ipmitool -I lanplus -H 172.16.0.102 -U Administrator -P Administrator power off
Chassis Power Control: Down/Off
ハードリセット(強制リセット?)

構文

ipmitool -I lanplus -H IPアドレス -U ユーザ名 -P パスワード power reset

実行結果

[root@client ~]# ipmitool -I lanplus -H 172.16.0.102 -U Administrator -P Administrator power reset
Chassis Power Control: Reset
電源オフ+電源オン

構文

ipmitool -I lanplus -H IPアドレス -U ユーザ名 -P パスワード power cycle

実行結果

[root@client ~]# ipmitool -I lanplus -H 172.16.0.102 -U Administrator -P Administrator power cycle
Chassis Power Control: Cycle
電源ボタンの押下をエミュレート(OS上でシャットダウン指示に相当?)

構文

ipmitool -I lanplus -H IPアドレス -U ユーザ名 -P パスワード power soft

実行結果

[root@client ~]# ipmitool -I lanplus -H 172.16.0.102 -U Administrator -P Administrator power soft
Chassis Power Control: Soft

chassisコマンド

次回起動時に強制的にBIOS設定画面に入る

構文

ipmitool -I lanplus -H IPアドレス -U ユーザ名 -P パスワード chassis bootdev bios

実行結果

[root@client ~]# ipmitool -I lanplus -H 172.16.0.102 -U Administrator -P Administrator chassis bootdev bios
Set Boot Device to bios
次回起動時に強制的にPXEブートする

構文

ipmitool -I lanplus -H IPアドレス -U ユーザ名 -P パスワード chassis bootdev pxe

実行結果

[root@client ~]# ipmitool -I lanplus -H 172.16.0.102 -U Administrator -P Administrator chassis bootdev pxe
Set Boot Device to pxe
その他のオプション
[root@client ~]# ipmitool -I lanplus -H 172.16.0.102 -U Administrator -P Administrator chassis bootdev
bootdev  [clear-cmos=yes|no]
bootdev  [options=help,...]
  none  : Do not change boot device order
  pxe   : Force PXE boot
  disk  : Force boot from default Hard-drive
  safe  : Force boot from default Hard-drive, request Safe Mode
  diag  : Force boot from Diagnostic Partition
  cdrom : Force boot from CD/DVD
  bios  : Force boot into BIOS Setup
  floppy: Force boot from Floppy/primary removable media
[root@client ~]#

solコマンド

シリアルコンソールを有効化・接続する

構文

ipmitool -I lanplus -H IPアドレス -U ユーザ名 -P パスワード sol activate

実行結果

[root@client ~]# ipmitool -I lanplus -H 172.16.0.102 -U Administrator -P Administrator sol activate
[SOL Session operational.  Use ~? for help]

文字が表示されるのを待つ。

例えば、こんな感じ。比較用のGUI画面も載せておく。

                            4096 MB Installed

ProLiant System BIOS - P68 (05/05/2011)
Copyright 1982, 2011 Hewlett-Packard Development Company, L.P.


2 Processor(s) detected, 8 total cores enabled, Hyperthreading is enabled
Proc 1: Intel(R) Xeon(R) CPU L5630 @ 2.13GHz
Proc 2: Intel(R) Xeon(R) CPU L5630 @ 2.13GHz
QPI Speed: 5.8 GT/s
HP Power Profile Mode: Balanced Power and Performance
Power Regulator Mode: Static Low Power - Processor(s) clocked down to 1.60 GHz

Advanced Memory Protection Mode: Advanced ECC Support

f:id:none06:20210108004422p:plain

もう一例。

      
      
      
      CentOS Linux (4.18.0-240.1.1.el8_3.x86_64) 8
      CentOS Stream (4.18.0-240.el8.x86_64) 8
      CentOS Stream (0-rescue-78a98f7f4c164cdc9392bb139bad233b) 8
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      Use the   and   keys to change the selection.
      Press 'e' to edit the selected item, or 'c' for a command prompt.
      
      
      

f:id:none06:20210108004606p:plain

シリアルコンソール接続から抜ける

構文

~.

※「~(チルダ)キー」→「.(ピリオド)キー」の順に押下する
実行結果

[root@client ~]# ipmitool -I lanplus -H 172.16.0.102 -U Administrator -P Administrator sol activate
[SOL Session operational.  Use ~? for help]
Connection to localhost closed.

なぜか接続元のsshセッションまでログアウトしてしまう。よくわからない。

シリアルコンソール接続を無効化する

構文

ipmitool -I lanplus -H IPアドレス -U ユーザ名 -P パスワード sol deactivate

実行結果

[root@client ~]# ipmitool -I lanplus -H 172.16.0.102 -U Administrator -P Administrator sol deactivate
[root@client ~]#

solは非常に便利な機能なのだが、わりと調子が悪い。接続したのに表示されない場合は、deactivateしactivateし直すなどしている。

エスケープシーケンス

シリアルコンソール接続した状態で「~(チルダ)キー」→「?(クエスチョン)キー」の順に押下すると、使えるコマンドが表示される。「escape sequences」と書いてあるのでそう呼ぶらしい。

Supported escape sequences:
 ~.   - terminate connection (and any multiplexed sessions)
 ~B   - send a BREAK to the remote system
 ~C   - open a command line
 ~R   - request rekey
 ~V/v - decrease/increase verbosity (LogLevel)
 ~^Z  - suspend ssh
 ~#   - list forwarded connections
 ~&   - background ssh (when waiting for connections to terminate)
 ~?   - this message
 ~~   - send the escape character by typing it twice
(Note that escapes are only recognized immediately after newline.)

補足(後日追記)

PXEが特殊な動作をする

BIOSのbootで該当IFを有効化
該当IFのみ
Intel
Initializing and establishing link...

CLIENT MAC ADDR: 90 1B 0E 6C B6 59 GUID: 9CB9C6CA 2A69 D044 A309 8E3FEAFA679A

IPMIでPXEを指定

LAN1のIFでbootした