Translated message

A translation of this page exists in English.

Warning message

This translation is outdated. For the most up-to-date information, please refer to the English version.

initrd-switch-root.service が失敗した状態となり、システムが緊急モードになる

Solution Verified - Updated -

Environment

  • (以前のバージョンからアップグレードした) Red Hat Enterprise Linux (RHEL) 7.8
  • systemd

Issue

  • 以下のサービスが起動時に失敗することで、システムが緊急モードに陥ります。

    # systemctl status initrd-switch-root.service
    ● initrd-switch-root.service - Switch Root
       Loaded: loaded (/usr/lib/systemd/system/initrd-switch-root.service; static; vendor preset: disabled)
       Active: failed (Result: signal) since Fri 2020-04-17 14:36:17 CEST; 5min ago
      Process: 502 ExecStart=/usr/bin/systemctl --no-block --force switch-root /sysroot (code=killed, signal=TERM)
     Main PID: 502 (code=killed, signal=TERM)
    
  • 7.x から 7.8 にアップグレードした後、マシンは緊急プロンプトで停止します。

Resolution

  • この問題は systemd-219-78.el7_9.2 で修正されています。

https://access.redhat.com/errata/RHBA-2020:5007

  • 回避策

診断手順 セクションに記載の手順を実施します。この手順に一致する場合は、次に進みます。

すべての initramfs イメージを再構築する必要があります。これは、緊急プロンプトが表示されているときに稼働中のシステムで実行されるか、chroot にあるときに Rescue DVD から実行されます。

トラブルシューティングモードで DVD を使用してシステムを起動した場合

  1. /dev/sys、および /proc がマウントされていることを確認します。マウントされていない場合は、これらを最初にマウントします。こちら を参照してください。

    # mount -o bind /dev /mnt/sysimage/dev
    # mount -o bind /sys /mnt/sysimage/sys
    # mount -o bind /proc /mnt/sysimage/proc
    
  2. chroot を実行します。

    # chroot /mnt/sysimage
    
  3. すべての initramfs イメージを永続ストレージ (/rootなど) にバックアップします。

    # cp /boot/initramfs-*.x86_64.img /root
    
  4. すべての initramfs イメージを再作成します。

    # dracut --force --regenerate-all
    

    注記: すべての initramfs イメージを再構築することを推奨します。再構築しない場合は、古いカーネルの起動中に問題が発生する可能性があります。

  5. chroot を終了します。

    # exit
    
  6. トラブルシューティングモードを終了して、ディスク上で再起動します。

    # exit
    

システムがディスク上で起動され、緊急プロンプトが実行された場合

  1. すべての initramfs イメージを永続ストレージ (/rootなど) にバックアップします。

    # cp /boot/initramfs-*.x86_64.img /root
    
  2. 以下のコマンドを使用して、initramfs イメージを再作成します。

    # dracut --force --regenerate-all
    

    注記: すべての initramfs イメージを再構築することを推奨します。再構築しない場合は、古いカーネルの起動中に問題が発生する可能性があります。

  3. 起動を続行します。

    # exit
    

問題の発生を防ぐため、RHEL 7.8 への更新直後 (その後の再起動前) に以下の手順の実行が可能

  1. すべての initramfs イメージを永続ストレージ (/rootなど) にバックアップします。

    # cp /boot/initramfs-*.x86_64.img /root
    
  2. 以下のコマンドを使用して、initramfs イメージを再作成します。

    # dracut --force --regenerate-all
    

    注記: すべての initramfs イメージを再構築することを推奨します。再構築しない場合は、古いカーネルの起動中に問題が発生する可能性があります。

Root Cause

この問題は、initramfs古い systemd バイナリーが含まれている場合に、ルートを切り替える際のタイミングの問題が原因となっています。
1.古い systemd バイナリーは、古い systemctl プログラムを内部で実行する initrd-switch-root.service ユニットを実行することにより、ルートの切り替えを開始します。
2.ルートファイルシステム上の 新しい systemd バイナリーは、古い systemctl プログラムがまだ実行されている間に、SIGTERM を initrd-switch-root.service ユニットに送信します。
3.古い systemctl プログラムに BZ 1825232 - System drops into emergency mode for no obvious reason after upgrading to latest systemd の修正がないため、古い systemctl プログラムが失敗します。
4.新しい systemd バイナリーは、initrd-switch-root.service が失敗したことを確認し、OnFailure コマンド (emergency.target) を実行します。

Diagnostic Steps

  1. システムにインストールされている systemd バイナリーのサイズを確認してください。

    # ls -l /usr/lib/systemd/systemd
    -rwxr-xr-x. 1 root root 1628536 Mar 17 10:50 /usr/lib/systemd/systemd
    
  2. 緊急モードに入る initramfs に埋め込まれた systemd バイナリーのサイズを確認してください。

    # lsinitrd /boot/initramfs-$(uname -r).img | grep "usr/lib/systemd/systemd$"
    lrwxrwxrwx   1 root     root           23 Apr 17 14:18 init -> usr/lib/systemd/systemd
    -rwxr-xr-x   1 root     root      1620416 Apr 17 14:18 usr/lib/systemd/systemd
    

上記の例ではサイズが異なります。これは、異なる systemd が initramfs で実行されていることを示しています。これにより、systemdsystemd-219-70.el7 より古い場合に、本ソリューションで説明されている問題が発生する可能性があります。

sosreport を使用した別の方法:

  1. インストールされている systemd パッケージが、systemd-219-73.el7 以降であるかどうかを確認します。

    $ cat sosreport/installed-rpms | grep systemd-219
    systemd-219-73.el7_8.5.x86_64                               Tue Apr 14 19:36:55 2020    1586860615  Red Hat, Inc.
    
  2. /boot/initramfs-$(unamr -r).img ファイルの作成時間が、上記の systemd パッケージのインストール時間より古いかどうかを確認します。

    $ cat sosreport/uname | awk '{print $3}'
    3.10.0-123.el7.x86_64
    $ cat sosreport/sos_commands/boot/ls_-lanR_.boot | grep initramfs-3.10.0-123.el7.x86_64.img
    -rw-------.  1 0 0 16944810 Sep 27  2017 initramfs-3.10.0-123.el7.x86_64.img
    
  3. 最後に消去された systemd パッケージが、systemd-219-73.el7 より古いかどうかを確認します。

    $ cat sosreport/var/log/yum.log | grep systemd-2 | tail -n1
    Apr 15 16:42:12 Erased: systemd-208-11.el7.x86_64
    

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments