AI 能用来全自动化解决 Linux 系统问题吗?

wniming 2026-07-03 16:42 1

最近遇到一个有点复杂的问题,研究了半天没解决,想试试用 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 都有一样的问题。

最新回复 (11)
  • wu67 07-03 16:52
    1
    全自动场景, 你怎么解决 AI 的幻觉问题呢?

    系统有些删除/变更操作是不可逆的, 一旦产生了幻觉, 那不就 boom 了?
  • wniming 楼主 07-03 17:01
    2
    @wu67 我没有用 AI 全自动化解决过这类问题,我是看上个月有位 V 友分享的关于现阶段 AI 能力的帖子: https://v2ex.com/t/1218995
    感觉 AI 这么强了应该能搞定我遇到的这个问题,我只需要安装一台虚拟机然后把 AI 工具安装上去,然后给虚拟机做一个快照,剩下的就可以交给 AI 自己搞了,如果 AI 把系统搞崩了就还原一下快照,感觉我遇到的这个是纯软件问题,AI 应该搞得定,就是不知道要花多少钱。
  • kang77649119 07-03 17:10
    3
    走限时免费的模型,商汤现在有活动,不需要花钱
    当然模型决定能力,如果你有顶级模型,那是事倍功半的(先免费尝试一波)
  • iloveayu 07-03 17:18
    4
    你遇到的这个问题应该就是卡在某个点上了,开个 MIMO 最低 39 的套餐那些 token 就足够解决了。
  • imkuang 07-03 17:31
    5
    你这个描述这么详细,现象这么明确的问题直接把你这个帖子的内容丢给任何一个水平在线的 AI 应该都直接能分析出来原因了,不用专门搞啥东西
  • dancercl 07-03 17:44
    6
    可以,但要用牛逼模型,然后让模型给你写一个符合运维安全原则的 CLAUDE.md 或 AGENTS.md ,然后再写一个自动调用独立 agent 来 review 指令的流程。

    用烂模型分分钟删数据,比如 minimax 。
    我用 gpt-5.5 运维很久了,一直没出过任何事故。
  • techmale 07-03 17:53
    7
    1. 必须 SOTA 模型,必须 SOTA 模型,必须 SOTA 模型
    2. 你需要给他一个明确的从「写」到「 dryrun 」到「 run 」到「 apply 」的具体处理策略! i.e. AGENTS.md
    3. 如果系统初期就以 Nix 类似的方式去管理,会更好 (Nix-Darwin is a godsend for macOS 😩)
  • champaulmmc 07-03 18:11
    8
    zcode 可以远程 ssh 连接,但是正如楼上说的操作不安全
  • rb6221 07-03 18:20
    9
    有的兄弟,有的
    https://skills.aliyun.com/skills/alibabacloud-ecs-diagnose
  • unused 07-03 18:43
    10
    看起来问题很明确了,AI 应该容易解决

    盲猜你这行把 common.conf 的默认值覆盖了,没有 mount 全
  • wniming 楼主 07-03 20:03
    11
    @imkuang
    @unused

    用 chatgpt 解决了:
    https://chatgpt.com/share/6a479809-0f68-83ea-bdd9-0e918608653c

    之前问 chatgpt ,chatgpt 鬼扯一大堆,没有分析出根因:
    https://chatgpt.com/share/6a47a371-3390-83ea-9899-e8d17eb1d0ab

    不过之前这次对话 chatgpt 引用了一个 issue: https://github.com/systemd/systemd/issues/39036
    这个 issue 也是在 LXC 里使用 rw 权限的 sysfs 触发的,systemd 的原作者认为是 LXC 的 bug ,不打算修。。。
* 帖子来源V2EX
返回