/etc/fstabの記述ミスでRaspberry Piが起動しなくなった話

Linux
この記事は約7分で読めます。

 

 

先日Raspberry Pi 4にSDカードを追加した記事を書きました。

作業しているときに、Raspberry Piが正常に起動しないトラブルが発生したのでそれについて書いていきます。

                 

発生までの経緯

 

  • OS起動時に追加したSDカードが自動マウントされるよう/etc/fstabに記述を追加した(つもりだった)

  • reboot後、ネットワークに接続できなくなりssh接続はできなくなった
    ネットワークアダプター自体が反応しない状態で、疎通不可となった。

  • リモートでは手出しできなくなって困った

 

やったこと

 

  1. Raspberry Piをモニターにつないでみる

    Raspberry Piの電源を入れると真っ黒な画面が表示されます。

    が、その後何も表示されないままです。

    なお、電源投入後のLED点灯状態は問題なさそうです。


  2. キーボードをつないでEscキーを押してみる

    真っ黒な画面でEscキーを押してみたところ画像のようなメッセージが表示されました。
    You are in emergency mode. After logging in, type "journalctl -xb" to view system logs, "systemctrl reboot" to reboot, "systemctl default" or "exit" to boot into default mode.
    Give root password for maintenance
    (or press Control-D to continue):


    翻訳
    エマージェンシーモードになっています。ログイン後、「journalctl -xb」と入力するとシステムログが表示され、「systemctrl reboot」と入力すると再起動し、「systemctl default」または「exit」と入力するとデフォルトモードで起動します。
    メンテナンスのためにrootのパスワードを入力してください。
    (またはControl-Dを押して続行します。)

    ということで、rootパスワードを入力し、コマンドの入力ができる状態にしました。



  3. ジャーナルを保存

    journalctl -xbでsystemdのログが出力されるので、後から確認できるようにファイルに出力しました。



  4. /etc/fstabを編集

    /etc/fstabの編集後にRaspberry Piが起動しなくなったので、fstabへの記述ミスが原因なのは明らかなので、自分が追記した記述をコメントアウトしました。


  5. reboot

    最後にrebootしたところ、ちゃんと起動してくれました。

    ネットワークへの接続も問題なく、sshで操作も可能でした。

 

ログを見返してみる

 

journalctrl -xbで出力されたログから”fail”や”error”や”fstab”でgrepしてみました。

$ cat journal.log | grep -ie fail -ie error -ie fstab
10月 07 12:29:02 raspberrypi systemd-fsck[140]: fsck: /etc/fstab: parse error at line 6 -- ignored
10月 07 12:29:02 raspberrypi systemd-remount-fs[147]: mount: /etc/fstab: parse error at line 6 -- ignored
10月 07 12:29:02 raspberrypi systemd-remount-fs[147]: mount: /etc/fstab: parse error at line 6 -- ignored
10月 07 12:29:05 raspberrypi systemd-udevd[180]: Process '/usr/sbin/th-cmd --socket /var/run/thd.socket --passfd --udev' failed with exit code 1.
-- /etc/fstab or Where= field in systemd unit file) and is not empty.
10月 07 12:29:05 raspberrypi systemd-udevd[162]: Process '/usr/sbin/th-cmd --socket /var/run/thd.socket --passfd --udev' failed with exit code 1.
10月 07 12:29:05 raspberrypi mount[316]: mount: /home/pi/sd: wrong fs type, bad option, bad superblock on /dev/sda1, missing codepage or helper program, or other error.
10月 07 12:29:05 raspberrypi systemd[1]: home-pi-sd.mount: Failed with result 'exit-code'.
-- Subject: Unit failed
-- The unit home-pi-sd.mount has entered the 'failed' state with result 'exit-code'.
10月 07 12:29:05 raspberrypi systemd[1]: Failed to mount /home/pi/sd.
-- Subject: A start job for unit home-pi-sd.mount has failed
-- A start job for unit home-pi-sd.mount has finished with a failure.
-- The job identifier is 26 and the job result is failed.
10月 07 12:29:05 raspberrypi systemd[1]: Dependency failed for Local File Systems.
-- Subject: A start job for unit local-fs.target has failed
-- A start job for unit local-fs.target has finished with a failure.
10月 07 12:29:05 raspberrypi systemd[1]: local-fs.target: Job local-fs.target/start failed with result 'dependency'.
10月 07 12:29:05 raspberrypi systemd[1]: local-fs.target: Triggering OnFailure= dependencies.
10月 07 12:29:05 raspberrypi systemd-fsck[317]: fsck: /etc/fstab: parse error at line 6 -- ignored
10月 07 12:29:05 raspberrypi systemd-udevd[174]: Process '/usr/sbin/th-cmd --socket /var/run/thd.socket --passfd --udev' failed with exit code 1.
10月 07 12:29:05 raspberrypi systemd-udevd[167]: Process '/usr/sbin/th-cmd --socket /var/run/thd.socket --passfd --udev' failed with exit code 1.
10月 07 12:29:05 raspberrypi systemd-udevd[163]: Process '/usr/sbin/th-cmd --socket /var/run/thd.socket --passfd --udev' failed with exit code 1.

 

ログから分かったこと

  • /etc/fstabの6行目でparse error(構文エラー)が発生している

  • parse error(構文エラー)によってマウントが失敗している

  • ローカルファイルシステムの依存関係が失敗している

/etc/fstabの記述ミスはログから分かりましたが、その結果としてRaspberry Piが起動しなくなった関係性は私にはわかりませんでした。

も少し調べてみようと思います。

とにもかくにも/etc/fstabの記述ミスでOSが起動しなくなることがあることが分かりました。

コメント

タイトルとURLをコピーしました