Linuxは起動プロセス中にいつ/どのようにシステムユーザーを作成しますか?

Linuxは起動プロセス中にいつ/どのようにシステムユーザーを作成しますか?

NFSマウントルートファイルシステム(Debian 10)からボードをインポートしようとしています。起動中にシリアルポートを介してエラーが報告されます。

[FAILED] Failed to start Create System Users.
See 'systemctl status systemd-sysusers.service' for details.

これは印刷された唯一のエラーメッセージです。 (まだユーザーが作成されていないため)ログインできないため、詳細を確認するコマンドを実行できません。

ルートファイルシステムはSDカードにあるときにマザーボードが起動できるため、問題はありません。

では、Linuxの起動時に「システムユーザーの作成」プロセスはどのように実行されますか?このエラーの原因は何ですか?

ベストアンサー1

起動プロセス中に、systemdは構成および有効になっているすべてのサービスを初期化します。明確に指定された要件やその他の指標に基づいてランク付けします。

あなたの場合、Debianにはファイルに定義されているsystemd-sysusersサービスとともにsystemdが含まれています。/usr/lib/systemd/system/systemd-users.service

サービスの基本コンテンツは次のとおりです。

#  SPDX-License-Identifier: LGPL-2.1-or-later                                                                                                                                         #                                                                                                                                                                                     #  This file is part of systemd.                                                                                                                                                      #                                                                                                                                                                                     #  systemd is free software; you can redistribute it and/or modify it                                                                                                                 #  under the terms of the GNU Lesser General Public License as published by                                                                                                           #  the Free Software Foundation; either version 2.1 of the License, or                                                                                                                #  (at your option) any later version.

[Unit]
Description=Create System Users
Documentation=man:sysusers.d(5) man:systemd-sysusers.service(8)
DefaultDependencies=no
Conflicts=shutdown.target
After=systemd-remount-fs.service
Before=sysinit.target shutdown.target systemd-update-done.service
ConditionNeedsUpdate=/etc

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=systemd-sysusers
TimeoutSec=90s

# Optionally, pick up a root password and shell for the root user from a
# credential passed to the service manager. This is useful for importing this
# data from nspawn's --set-credential= switch.
LoadCredential=passwd.hashed-password.root
LoadCredential=passwd.plaintext-password.root
LoadCredential=passwd.shell.root

このExecStart行は、このサービスに対して実行する項目をsystemdに通知します。この場合に実行されます。/usr/bin/systemd-sysusersパラメータはありません。このユーティリティの一部の出力は、以下にあります。/var/log/メッセージ。私の場合(CentOS 9 Stream)の成功した実行結果は次のとおりです。

Aug 15 10:11:26 MY-VM systemd-sysusers[257]: Suggested group ID 65534 for nobody already used.
Aug 15 10:11:26 MY-VM systemd-sysusers[257]: Creating group 'nobody' with GID 999.
Aug 15 10:11:26 MY-VM systemd-sysusers[257]: Creating group 'users' with GID 100.
Aug 15 10:11:26 MY-VM systemd-sysusers[257]: Creating group 'dbus' with GID 996.
Aug 15 10:11:26 MY-VM systemd-sysusers[257]: Creating user 'dbus' (System Message Bus) with UID 996 and GID 996.
Aug 15 10:11:28 MY-VM systemd[1]: systemd-sysusers.service: Deactivated successfully.

発生したエラーを検出したときにリストされている最も可能性の高い原因は次のとおりです。ルートドライブ/パーティションに書き込めません(ディスクがいっぱい、権限、読み取り専用マウントなど)、および1つ以上の設定エラー次または文法エラー:/etc/passwd, /etc/shadow, /etc/gshadow, /etc/group

systemdサービスユニットファイルには、読める文書のマニュアルページもリストされています。

おすすめ記事