如何在 chroot 中更新和添加新包?

如何在 chroot 中更新和添加新包?

我有一个磁盘映像,但这个磁盘映像没有 libjpeg 之类的软件包。首先,我将磁盘映像挂载到目录,然后将根目录更改为此目录。不幸的是,apt-get updateapt-get installchroot 中无法正常工作,我不知道还能尝试什么。当我运行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}"

相关内容