![如何在 chroot 中更新和添加新包?](https://linux22.com/image/1060873/%E5%A6%82%E4%BD%95%E5%9C%A8%20chroot%20%E4%B8%AD%E6%9B%B4%E6%96%B0%E5%92%8C%E6%B7%BB%E5%8A%A0%E6%96%B0%E5%8C%85%EF%BC%9F.png)
我有一个磁盘映像,但这个磁盘映像没有 libjpeg 之类的软件包。首先,我将磁盘映像挂载到目录,然后将根目录更改为此目录。不幸的是,apt-get update
在apt-get install
chroot 中无法正常工作,我不知道还能尝试什么。当我运行apt-get update
并时发生以下错误apt-get install
:
bash: apt-get: command not found
如何解决这个问题呢?
答案1
尝试这个:
CHROOT_DRIVE=/dev/sda2 # or /dev/mmcblk1p2
CHROOT_PATH=/mnt/recovery # or /tmp/recovery # to have it auto cleanup on reboot
mkdir -p "${CHROOT_PATH}"
mount "${CHROOT_DRIVE}" "${CHROOT_PATH}"
mount -t sysfs none "${CHROOT_PATH}/sys"
mount -t proc none "${CHROOT_PATH}/proc"
mount --bind /dev/ "${CHROOT_PATH}/dev"
mount --bind /dev/pts "${CHROOT_PATH}/dev/pts"
mount -o bind /etc/resolv.conf "${CHROOT_PATH}/etc/resolv.conf"
chroot "${CHROOT_PATH}"
完成后:
exit
umount -R "${CHROOT_PATH}"