Welcome to the Linux Foundation Forum!

Lab 3.1 chroot

I am having a problem with 3.1 where the command: chroot /mnt/chroot-ubuntu-xenial/ /bin/bash

Results in the following:

chroot: failed to run command '/bin/bash' : no such file or directory.

The file and directory both exist of course. I even ran this in /bin/bash and got the same message with the following:

chroot /mnt/chroot-ubuntu-xenial/ ./bash

And got the same message. Then I tried

chroot /mnt/chroot-ubuntu-xenial/

And got the same message. Then I tried

chroot=/mnt/chroot-ubuntu-xenial/ /bin/bash

And this time I didn't get an error message, but the following command:

cat /etc/os-release

showed no change to the os-release.

Others have apparently worked this out. What am I doing wrong?

Comments

  • rogerh
    rogerh Posts: 10

    I went back into the steps and found an issue:

    Under 'Install an Ubuntu xenial guest in the subdirectory created earlier, this is what I interpreted the command to be:

    debootstrap xenial /mnt/chroot-ubuntu-xenial/ http://archive.ubuntu.com/ubuntu/

    Download was successful

    I revisited this command the second time around with the following:

    debootstrap xenial /mnt/chroot-ubuntu-xenial/

    Download was successful in this case as well. The difference this time is when I used the chroot command

    chroot /mnt/chroot-ubuntu-xenial/ /bin/bash

    I didn't get an error message and

    cat /etc/os-release

    gave me the correct results. Strange problem with that command that didn't work the first time even though everything downloaded, but it worked the second time.

  • chrispokorni
    chrispokorni Posts: 2,376

    Hi,

    When you run chroot ... /bin/bash, it is trying to find bash on the guest instance. If your guest OS instance did not successfully install in the /mnt/chroot-ubuntu-xenial/ directory with debootstrap, then you would see these error messages.

    Perhaps your guest installation command did not run successfully. Assuming your debootstrap installed successfully on your host, run this command again, as root, to ensure your guest installs as well:

    root@ubuntu:~# debootstrap xenial /mnt/chroot-ubuntu-xenial/ http://archive.ubuntu.com/ubuntu/

    After this successful install, you should be able to verify both OS releases, host (bionic) 18.04 (which is not expected to change in any way), and guest (xenial) 16.04.

    Regards,
    -Chris

  • rogerh
    rogerh Posts: 10

    Thanks Chris!

  • Experienced the problem. After executing the second time it was resolved.

Categories

Upcoming Training