What folders need to be mounted before chroot

bootchroot

I am attempting to update a broken Linux Mint 32 bit installation using chroot from a live cd. Different websites give different folders that need to be mounted before chroot.

The error I am trying to solve is here
What folders to mount and why?

Best Answer

well; gentoo wiki is very nice in that respect; (assuming that you are booted to working environment like livecd/usb) first we assume your chroot system is on /dev/sdaX. so we go mount it:

mkdir -p /mnt/distro
mount /dev/sdaX /mnt/distro

if your chroot (problematic environment) has seprate /boot, /var or any other partitions we mount them like above.

root #mount -o bind /proc /mnt/distro/proc

then depend on what kind of system you are building (systemd or init ):

root #mount --rbind /sys /mnt/distro/sys 
root #mount --make-rslave /mnt/distro/sys 
root #mount --rbind /dev /mnt/distro/dev 
root #mount --make-rslave /mnt/distro/dev

if youare building init-based system like OpenRc don't do --make-rslave lines.

then to chroot in a right way do this:

root #chroot /mnt/distro /bin/env -i TERM=$TERM /bin/bash 
root #source /etc/profile 
root #export PS1="(chroot) $PS1"

Note; that your chroot environment may differ and /bin/env wasn't there. so it should be at usr/bin/env.

Related Question