RHEL仮想マシンがdracut…を吐いて起動しなくなった時の対処

今年の1月にこんなことがありまして。

こっちで作ったRHELのテンプレートからデプロイした仮想マシン、用事があって再起動したらいきなし起動しなくなって超焦ったという…
まあ、原因はツイートの通り他の担当者のやらかしなんだけど、修正はオイラがやったので、対応した時の手順をメモとして。

【事象】

仮想マシンがシャットダウン後以下のメッセージで起動しなくなった問題。

dracut-initqueue[xxx]: Warning: Could not boot.
dracut-initqueue[XXX]: Warning: /dev/rhel_該当機/root does not exist
dracut-initqueue[XXX]: Warning: /dev/mapper/rhel_該当機-root does not exist
            Starting Dracut Emergency Shell...
Warning: /dev/rhel_該当機/root does not exist
Warning: /dev/mapper/rhel_該当機-root does not exist

Generating "/run/initramfs/sosreport.txt"

Entering emergency mode. Exit the shell to continue.
Type "journalctl" to view system logs.
You might want to save "/run/initramfs/sosreport.txt" to a USB stick or /boot
after mounting them and attach it to a bug report.

dracut:/#

【原因】

マウントするLVMのvgname/lvname、grubのroot・swap指定、fstabのファイルシステムの記述の不一致

※某担当者がvgrenameとlvrenameした後、grub.cfgとfstabの更新をしておらず、また、その時点で再起動していなかった為発覚しなかった

テンプレートから新たにデプロイした仮想マシンを確認した所、LVMの名前がrhel_テンプレ-rootとrhel_テンプレ-swapで、かつfstabとgrub.cfgの記述も同様であった事から確定

実機上のパラメータ
vgname:rhel_該当機
lvname:rhel_該当機-root,rhel_該当機-swap
grub.cfg及びfstab上の誤った記載:rhel_テンプレ-root,rhel_テンプレ-swap

【修正方法】

1.レスキューモードで起動

  1. 仮想マシンをコンソールのツールバーからパワーオフする
  2. 仮想マシン設定のハードウェア編集で、rhelのisoをマウントし、起動時に接続にチェックを入れる
  3. 仮想マシンを起動したら即座にF2キーを連打してBIOS画面を起動する(起動が早くてタイミングが難しいので、実はここが一番面倒)
  4. Boot OrderでCDROMをHDDより上位にする
  5. F10で設定を保存してBIOSから抜ける
  6. rhelのisoからブートし、ブートメニューが表示されたら、Troubleshootingを選択
  7. トラブルシューティングメニューで、Rescue a Red Hat Enterprise Linux Systemを選択し、レスキューモードを起動する
  8. Enterで続行すると、以下のメッセージ及び選択肢が示されるので、3を選択してbashを起動させる
    (メニューの文言はうろ覚えだが、3を選択は確定)
   The rescue environment will now attempt to find your Linux installation and mount it under the directory /mnt/sysimage. You can then make any changes required to your system. If you want to proceed with this step choose 'Continue'. You can also choose to mount your file systems read-only instead of read-write by choosing 'Read-only'. If for some reason this process fails you can choose 'Skip' and this step will be skipped and you will go directly to a command shell.

   1. mount /mnt/sysimage
   2. Read-only
   3. skip shell
   4. reboot

2.ディスクのマウントとchroot

  1. localectlでキーマップを日本語にする(しないとアンダースコアが打てない…)
     localectl set-keymap jp106`
  1. LVMパーティション領域が無効化されているので、vgnameを確認し、パーティションを有効化する
      vgscan #vg情報表示
         Reading all physical volumes. This may take a while...
         Found volume group "rhel_該当機" using metadata type lvm2 
      vgchange -ay rhel_該当機 #LVMパーティション領域有効化
      lvdisplay #lv情報表示
  1. 必要なファイルシステムをマウントする

    今回/mntにマウントしたが、別に/mntの下に別ディレクトリを作ってマウントでも可
      mount /dev/mappaer/rhel_該当機-root /mnt
      mount /dev/sda1 /mnt/boot
      mount --bind /dev /mnt/dev
      mount --bind /sys /mnt/sys
      mount --bind /proc/ /mnt/proc
  1. chrootで/mntを一時的にシステムディスクとする
      chroot /mnt

3.設定修正

  1. /etc/fstabの/とswapを修正する。※レスキューモード入りたてのfstabは空なので、必ずchroot後に確認と編集を実施する事

    /dev/sda1のuuidは基本的に変更ないが、念の為にUUIDを確認し、fstabの内容と差異がないか確認しておく
      cat /etc/fstab
         /dev/mapper/rhel_テンプレ-root    /        xfs   defaults 0  0
         /dev/sda1のuuid                   /boot    xfs   defaults 0  0
         /dev/mapper/rhel_テンプレ-swap    swap     swap  defaults 0  0
            #rhel_テンプレ-rootとrhel_テンプレ-swapを修正

      vi /etc/fstab
         /dev/mapper/rhel_該当機-root    /        xfs   defaults 0  0
         /dev/sda1のuuid                   /boot    xfs   defaults 0  0
         /dev/mapper/rhel_該当機-swap    swap     swap  defaults 0  0

      blkid /dev/sda1 #/dev/sda1のUUIDを念の為に確認
  1. fstabの修正ができたら、/boot/grub2/grub.cfgも同様にrhel_テンプレ~の記述を正しいパラメータに修正する(事前に grep "rhel_テンプレ"で確認しておく。)
  2. exitでchrootを終了させ、サーバーをリブートする
  3. rhelのisoから起動して、TroubleshootingからBoot from local driveを選択
  4. 正常にブートし、ログインできることを確認する
  5. 一旦シャットダウンし、仮想マシンの編集でrhelのisoを外す
  6. 仮想マシンを起動し、F2を連打してBIOS画面を表示させる
  7. Boot OrderでCDROMをHDDの下に移動させ、F10で設定を保存する
  8. BIOSを終了し、OS起動とログインを確認する

以上!

…原因わかるまでマジ心臓に悪かった…