7

I am trying to chroot into an old HD to change a forgotten password, but chroot says permission denied? what gives? I am root! The harddrive I am trying to chroot into is an old version of edUbuntu 7.10 might that have anything to do with it?

root@h:~# chroot /media/usb0/
chroot: failed to run command `/bin/bash': Permission denied
  • Can you post the output of ls -la /media/? – cremefraiche Dec 13 '14 at 2:31
  • Also, what is the output of the full command: chroot /media/usb0 /bin/bash? Lastly, are you sure the usb is mounted at /media – eyoung100 Dec 13 '14 at 2:36
  • 3
    And I'd like ls -l /media/usb0/bin/bash and grep /media /proc/mounts – Hauke Laging Dec 13 '14 at 2:56
  • Please post the output of mount | grep /media/usb0 as well. – 200_success Dec 13 '14 at 8:09
  • Why chroot? Can't you just delete the entry in /etc/shadow, boot, login as root and set a password? – Anthon Dec 13 '14 at 15:39
12

Chroot in ubuntu or recovering Ubuntu,Debian Linux

boot from livecd of ubuntu, if you installed with system 32bit use 32bit Live CD, If 64bit use 64 bit live cd.

Mount the Linux Partitions using

# sudo blkid

Output:

sysadmin@localhost:~$ sudo blkid
[sudo] password for sysadmin: 
/dev/sda1: UUID="846589d1-af7a-498f-91de-9da0b18eb54b" TYPE="ext4" 
/dev/sda5: UUID="36e2f219-da45-40c5-b340-9dbe3cd89bc2" TYPE="swap" 
/dev/sda6: UUID="f1d4104e-22fd-4b06-89cb-8e9129134992" TYPE="ext4"

Here my / Partition is /dev/sda6

Mount the / Partition to mount point using

# sudo mount /dev/sda6 /mnt

Then Mount the linux access points, Linux devices, Proc, sys

Linux Device

# sudo mount --bind /dev/ /mnt/dev

proc system information

# sudo mount --bind /proc/ /mnt/proc

Kernel information to user space

# sudo mount --bind /sys /mnt/sys

If we need to enable the networking we need to do the following steps (Optional).

# cp /etc/resolv.conf /mnt/etc/resolv.conf

Change the Linux root to be the device we mounted earlier in step 2

# sudo chroot /mnt

Now try to change the root password it will work.

  • 1
    Once I remounted the device under root, I was able to chroot in without issues! Thanks for the tips here! – Brooke Fogg-Wolfe Dec 13 '14 at 23:04
8

You can't execute /bin/bash in your chroot and that is most likely because your filesystem is mount with the noexec option and maybe also with nosuid. You can check this running with the mount command as that will show the mount options and you may need to remount the filesystem with other options.

2

(this does not answer the chroot, but can allow you to change a forgotten unix passwd)

I understood disk is mounted on /media/usb

try

cd /media/usb/etc
vi shadow

pick line with root, wipe second field (or you can pick the crypted string of a know password from your actual /etc/shadow).

  • in case shadow don't exists, do the same in passwd

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.