5 Easy Steps to Fix chroot Errors in Rescue Mode (Reset Root Password)
A practical, step-by-step recovery guide for Linux administrators and DevOps engineers.
Introduction: Understanding chroot Errors in Rescue Mode
When a Linux server fails to boot, rescue mode (a provider rescue image or a live CD) is the usual route to recover the system. A common stumbling block is chroot errors such as:
chroot: failed to run command '/bin/bash': No such file or directoryThis guide explains why these errors happen, how to find and mount the correct partition, prepare a working chroot environment, and safely reset the root password.
Step 1: Why chroot Errors Occur
The rescue environment provides its own root filesystem. To operate on the installed system, you must mount the installed system’s root partition (often under /mnt) and then chroot into it. If you mount the wrong partition (for example /boot), /bin/bash will be missing and chroot fails.
Step 2: Identify the Correct Root Partition
lsblk -fLook for the largest Linux partition (ext4/xfs/ext3) containing the system tree. On RAID systems, the root is usually the largest filesystem (not /boot or swap).
Step 3: Unmount Previous Mounts (Resolve “Target is Busy”)
umount -l /mnt/dev /mnt/proc /mnt/sys /mnt/run 2>/dev/null
umount -l /mnt 2>/dev/nullCheck active mounts:
mount | grep /mnt
fuser -vm /mnt
lsof | grep /mntNote: Use lazy unmount -l in rescue environments.
Step 4: Mount the Correct Root Filesystem
mount /dev/md3 /mnt
# or single disk
mount /dev/sda3 /mntVerify contents with ls /mnt. If only vmlinuz or grub files appear, you mounted the wrong partition.
Step 5: Bind System Directories and Prepare chroot
mount --bind /dev /mnt/dev
mount --bind /proc /mnt/proc
mount --bind /sys /mnt/sys
mount --bind /run /mnt/runThen enter chroot:
chroot /mnt /bin/bash
# or alternatives:
chroot /mnt /usr/bin/bash
chroot /mnt /bin/shReset the Root Password
Once inside the chroot environment:
passwd root
sync
exitExiting returns you to the rescue environment.
Clean Up and Reboot
umount /mnt/dev /mnt/proc /mnt/sys /mnt/run 2>/dev/null
umount /mnt
rebootTroubleshooting Tips for chroot Errors
- Check architecture and libraries:
file /mnt/bin/bash,ldd /mnt/bin/bash - Check RAID status:
cat /proc/mdstat - Try
/usr/bin/bashif /usr is separate - Use a full live CD matching your server’s CPU architecture
Conclusion
Most chroot failures are due to mounting the wrong partition or missing virtual filesystem binds. Mount the correct root, bind /dev, /proc, /sys, /run, chroot, reset the root password, and perform clean unmounts before rebooting.




