最近遇到一个有点复杂的问题,研究了半天没解决,想试试用 AI 来搞行不行,之前看有 V 友分享 AI 使用方面的一些经验,感觉现阶段的 AI 应该是能解决我遇到的这个问题的,但我预算有限,想在实际开搞之前先让 V 友帮我预估一下搞定这个问题大概要花多少钱。
问题如下:
dnf --installroot=/var/lib/lxc/f43/rootfs --setopt=reposdir=/etc/yum.repos.d/ --releasever=43 install system-release vi vim systemd passwd dnf rootfiles nmap-ncat openssh-server util-linux iproute iputils perl fzf bash-completion
我在 fedora 44 上用以上这条命令创建了一个 fedora 43 的极简 rootfs ,用 LXC 启动时无法进入控制台,会卡在这里:
root@develop:~# lxc-start -F f43
systemd 258.9-1.fc43 running in system mode (+PAM +AUDIT +SELINUX -APPARMOR +IMA +IPE +SMACK +SECCOMP -GCRYPT +GNUTLS +OPENSSL +ACL +BLKID +CURL +ELFUTILS +FIDO2 +IDN2 -IDN -IPTC +KMOD +LIBCRYPTSETUP +LIBCRYPTSETUP_PLUGINS +LIBFDISK +PCRE2 +PWQUALITY +P11KIT +QRENCODE +TPM2 +BZIP2 +LZ4 +XZ +ZLIB +ZSTD +BPF_FRAMEWORK +BTF +XKBCOMMON +UTMP +SYSVINIT +LIBARCHIVE)
Detected virtualization lxc.
Detected architecture x86-64.
Welcome to Fedora Linux 43 (Forty Three)!
Queued start job for default target graphical.target.
[ OK ] Created slice system-container\x2dgetty.slice - Slice /system/container-getty.
[ OK ] Created slice system-getty.slice - Slice /system/getty.
[ OK ] Created slice system-modprobe.slice - Slice /system/modprobe.
[ OK ] Created slice system-sshd\x2dkeygen.slice - Slice /system/sshd-keygen.
[ OK ] Created slice user.slice - User and Session Slice.
省略一些日志
[ OK ] Started sshd.service - OpenSSH server daemon.
[ OK ] Finished systemd-user-sessions.service - Permit User Sessions.
[ OK ] Started console-getty.service - Console Getty.
[ OK ] Started [email protected] - Container Getty on /dev/pts/1.
[ OK ] Started [email protected] - Container Getty on /dev/pts/2.
[ OK ] Started [email protected] - Container Getty on /dev/pts/3.
[ OK ] Started [email protected] - Container Getty on /dev/pts/4.
[ OK ] Reached target getty.target - Login Prompts.
[ OK ] Started dbus-broker.service - D-Bus System Message Bus.
[ OK ] Started systemd-logind.service - User Login Management.
[ OK ] Reached target multi-user.target - Multi-User System.
[ OK ] Reached target graphical.target - Graphical Interface.
在容器内查看启动日志有报错:
[root@f43-lxc ~]# journalctl -b -o short-monotonic --no-pager
省略一些日志
[23878.264260] f43-lxc sshd[73]: Server listening on 0.0.0.0 port 22.
[23878.264298] f43-lxc sshd[73]: Server listening on :: port 22.
[23878.264404] f43-lxc systemd[1]: Started sshd.service - OpenSSH server daemon.
[23878.269095] f43-lxc systemd[1]: Finished systemd-user-sessions.service - Permit User Sessions.
[23878.270020] f43-lxc systemd[1]: Started console-getty.service - Console Getty.
[23878.271603] f43-lxc systemd[1]: Started [email protected] - Container Getty on /dev/pts/1.
[23878.273357] f43-lxc systemd[1]: Started [email protected] - Container Getty on /dev/pts/2.
[23878.275185] f43-lxc systemd[1]: Started [email protected] - Container Getty on /dev/pts/3.
[23878.275923] f43-lxc systemd[1]: Started [email protected] - Container Getty on /dev/pts/4.
[23878.276071] f43-lxc systemd[1]: [email protected] - Getty on tty1 skipped, unmet condition check ConditionPathExists=/dev/tty0
[23878.276086] f43-lxc systemd[1]: Reached target getty.target - Login Prompts.
[23878.276254] f43-lxc systemd[1]: Started dbus-broker.service - D-Bus System Message Bus.
[23878.281245] f43-lxc dbus-broker-launch[92]: Ready
[23878.294315] f43-lxc systemd-logind[84]: Failed to open /dev/input/event0: No such file or directory
[23878.294420] f43-lxc systemd-logind[84]: New seat seat0.
[23878.294575] f43-lxc systemd[1]: Started systemd-logind.service - User Login Management.
[23878.294641] f43-lxc systemd-logind[84]: Failed to open /dev/input/event15: No such file or directory
[23878.294916] f43-lxc systemd[1]: Reached target multi-user.target - Multi-User System.
[23878.295094] f43-lxc systemd[1]: Reached target graphical.target - Graphical Interface.
[23878.295327] f43-lxc systemd[1]: Startup finished in 536ms.
[23878.297253] f43-lxc systemd-logind[84]: Failed to open /dev/input/event1: No such file or directory
[23878.311089] f43-lxc (agetty)[132]: console-getty.service: Failed to set up standard input: No such file or directory
[23878.311116] f43-lxc (agetty)[132]: console-getty.service: Failed at step STDIN spawning /sbin/agetty: No such file or directory
[23878.311788] f43-lxc systemd[1]: console-getty.service: Deactivated successfully.
[23878.338688] f43-lxc systemd-logind[84]: Failed to open /dev/input/event11: No such file or directory
[23878.349390] f43-lxc systemd-logind[84]: Failed to open /dev/input/event2: No such file or directory
[23878.352076] f43-lxc systemd-logind[84]: Failed to open /dev/input/event12: No such file or directory
[23878.355802] f43-lxc systemd-logind[84]: Failed to open /dev/input/event9: No such file or directory
[23878.356585] f43-lxc systemd-logind[84]: Failed to open /dev/input/event4: No such file or directory
[23878.363069] f43-lxc systemd-logind[84]: Failed to open /dev/input/event10: No such file or directory
[23878.367810] f43-lxc systemd-logind[84]: Failed to open /dev/input/event5: No such file or directory
[23878.463918] f43-lxc systemd[1]: console-getty.service: Scheduled restart job, restart counter is at 1.
[23878.465127] f43-lxc systemd[1]: Started console-getty.service - Console Getty.
[23878.465639] f43-lxc systemd[1]: systemd-vconsole-setup.service - Virtual Console Setup skipped, unmet condition check ConditionPathExists=/dev/tty0
[23878.475216] f43-lxc (agetty)[156]: console-getty.service: Failed to set up standard input: No such file or directory
[23878.475238] f43-lxc (agetty)[156]: console-getty.service: Failed at step STDIN spawning /sbin/agetty: No such file or directory
[23878.475834] f43-lxc systemd[1]: console-getty.service: Deactivated successfully.
[23878.644621] f43-lxc systemd[1]: console-getty.service: Scheduled restart job, restart counter is at 2.
[23878.645588] f43-lxc systemd[1]: Started console-getty.service - Console Getty.
[23878.657089] f43-lxc (agetty)[157]: console-getty.service: Failed to set up standard input: No such file or directory
[23878.657109] f43-lxc (agetty)[157]: console-getty.service: Failed at step STDIN spawning /sbin/agetty: No such file or directory
[23878.657604] f43-lxc systemd[1]: console-getty.service: Deactivated successfully.
[23878.889562] f43-lxc systemd[1]: console-getty.service: Scheduled restart job, restart counter is at 3.
[23878.890736] f43-lxc systemd[1]: Started console-getty.service - Console Getty.
[23878.902112] f43-lxc (agetty)[158]: console-getty.service: Failed to set up standard input: No such file or directory
[23878.902139] f43-lxc (agetty)[158]: console-getty.service: Failed at step STDIN spawning /sbin/agetty: No such file or directory
[23878.902764] f43-lxc systemd[1]: console-getty.service: Deactivated successfully.
[23879.238697] f43-lxc systemd[1]: console-getty.service: Scheduled restart job, restart counter is at 4.
[23879.239842] f43-lxc systemd[1]: Started console-getty.service - Console Getty.
[23879.257111] f43-lxc (agetty)[159]: console-getty.service: Failed to set up standard input: No such file or directory
[23879.257140] f43-lxc (agetty)[159]: console-getty.service: Failed at step STDIN spawning /sbin/agetty: No such file or directory
[23879.257806] f43-lxc systemd[1]: console-getty.service: Deactivated successfully.
[23879.489021] f43-lxc systemd[1]: console-getty.service: Scheduled restart job, restart counter is at 5.
[23879.489166] f43-lxc systemd[1]: console-getty.service: Start request repeated too quickly.
[23879.489172] f43-lxc systemd[1]: console-getty.service: Failed with result 'start-limit-hit'.
[23879.489214] f43-lxc systemd[1]: Failed to start console-getty.service - Console Getty.
[root@f43-lxc ~]#
lxc 的配置如下:
root@develop:~# cat /var/lib/lxc/f43/config
lxc.include = /usr/share/lxc/config/common.conf
lxc.rootfs.path = dir:/var/lib/lxc/f43/rootfs
lxc.uts.name = f43-lxc
lxc.mount.auto = sys:rw
如果把 lxc.mount.auto = sys:rw 注释掉就能正常进入控制台,但我需要用这个,同样的配置在 fedora 42 容器里是正常的,但 fedora 43, fedora 44 都有一样的问题。