补充说明
arch-chroot 是 arch-install-scripts 中的工具,比传统 chroot 更智能:它会自动挂载 /proc、/sys、/dev、/run 等虚拟文件系统,并处理好 DNS(/etc/resolv.conf)与终端环境。安装 Arch 时在 pacstrap 和 genfstab 之后使用,用于进入新系统完成配置。
语法
arch-chroot <目标目录> [命令...]
实例
进入 /mnt 的新系统(默认打开 bash):
arch-chroot /mnt
在目标系统内执行单条命令:
arch-chroot /mnt pacman -S vim
arch-chroot /mnt ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
arch-chroot /mnt systemctl enable NetworkManager
退出:exit 或 Ctrl+D。
用户注意
- 必须以 root 运行。
- 目标目录必须是已挂载的系统根目录,例如安装阶段的
/mnt。 - chroot 后操作需谨慎,改动直接作用于目标系统。