Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230
chroot: failed to run command ‘/bin/bash’
chroot: failed to run command ‘/bin/bash’
After I reinstalled Windows 10 to my dual boot computer, I cannot reach to the grub menu anymore. To fix this, I booted with a refind live USB stick. It recognized my debian stable system. However when I select the linux system, I don't see the grub menu, debian directly tries to boot, but it fails... During the boot it asks me for my encryption password and it passes that step successfully, however after "Mounted /home" line, it hangs for 1-2 minutes booting fails and it asks me to ENTER to continue. When I press ENTER, process fails with this message: "Cannot open access to console, the root account is locked."
At this point I decided to fix this problem with a most recent debian live USB stick. Unfortunately when I try to chroot to my debian system from the live usb environment, I get "chroot: failed to run command ‘/bin/bash’: No such file or directory" error. I did some research, but the suggestions online are not clear for me. I have been using debian for years but my knowledge of it is poor and I don't want to mess my system up by doing something wrong.
Could you please tell me how can I chroot to my debian system from a debian live usb environment?
At this point I decided to fix this problem with a most recent debian live USB stick. Unfortunately when I try to chroot to my debian system from the live usb environment, I get "chroot: failed to run command ‘/bin/bash’: No such file or directory" error. I did some research, but the suggestions online are not clear for me. I have been using debian for years but my knowledge of it is poor and I don't want to mess my system up by doing something wrong.
Could you please tell me how can I chroot to my debian system from a debian live usb environment?
-
- Global Moderator
- Posts: 3049
- Joined: 2017-09-17 07:12
- Has thanked: 5 times
- Been thanked: 132 times
Re: chroot: failed to run command ‘/bin/bash’
Can you elaborate ?dx486 wrote:I cannot reach to the grub menu anymore
Is this a BIOS/legacy or EFI setup ?
Did you chroot into the right filesystem ?dx486 wrote:chroot: failed to run command ‘/bin/bash’: No such file or directory
How is the system organized (partitions/encryption/LVM...) ?
Re: chroot: failed to run command ‘/bin/bash’
I was using my computer with a dual-boot setup: Windows 10 & debian 9 stable. Grub menu was appearing every time I start my computer.p.H wrote:Can you elaborate ?dx486 wrote:I cannot reach to the grub menu anymore
Is this a BIOS/legacy or EFI setup ?
One day I decided to reinstall Windows 10. I deleted Windows partitions and reinstalled Windows 10 by a Windows 10 usb stick.
After that Windows 10 directly boots. There is no grub menu anymore.
It is an EFI setup.
The debian system's partitions are organized with LVM, encrypted during installation. There is only 1 volume group, contains /, /home and swap. Also there is a separate unencrypted /boot partition. I tried to chroot /boot partition. I cannot directly chroot to / partition as it is encrypted. But as I am writing this I realized that trying to chroot into /boot is nonsense...p.H wrote:Did you chroot into the right filesystem ?dx486 wrote:chroot: failed to run command ‘/bin/bash’: No such file or directory
How is the system organized (partitions/encryption/LVM...) ?
Hmm... I guess there is no bash in /boot partition, that's why it cannot find it and gives that error message. I probably should decrypt my / partition with cryptsetup, then chroot to my / to fix the grub, right?
I installed cryptsetup to debian live system and unlocked encrypted partition as explained here, but I got the same error here. This is a volume group, so I probably that's why I cannot mount it. Probably I should try this. This is getting too complicated.
-
- Global Moderator
- Posts: 3049
- Joined: 2017-09-17 07:12
- Has thanked: 5 times
- Been thanked: 132 times
Re: chroot: failed to run command ‘/bin/bash’
Did you also delete the EFI system partition ? Did you create a separate EFI partition for Debian ?dx486 wrote:I deleted Windows partitions and reinstalled Windows 10 by a Windows 10 usb stick.
After that Windows 10 directly boots. There is no grub menu anymore.
It is an EFI setup.
If you deleted the EFI partition used by Debian, you deleted GRUB. You will have to update the UUID for the new EFI partition in /etc/fstab and reinstall GRUB.
If you did not delete the EFI partition containing GRUB, you should be able to select Debian from the UEFI firmware boot menu. Windows boots just because it became first in the boot order. The boot order can be changed with efibootmgr or in the UEFI firmware setup.
Correct. You must open the encrypted volume and enable the LVM volumes (install lvm2 if not present).dx486 wrote:I guess there is no bash in /boot partition, that's why it cannot find it and gives that error message. I probably should decrypt my / partition with cryptsetup, then chroot to my / to fix the grub, right?
Code: Select all
cryptsetup luksOpen /dev/sdXY sdXY_crypt
vgchange -ay
mount /dev/mapper/<vg>-<lv> /mnt
Note that the Debian installer rescue mode offers a more convenient way to chroot a Debian system.
Re: chroot: failed to run command ‘/bin/bash’
First of all, thank you for your helpful replies!
I managed to chroot and read the /etc/fstab file. It is written there in the comments that debian's EFI files were installed to /dev/sda2, while boot files were installed to /dev/sda6 (flagged as /boot during installation). Now Windows' EFI partition is still /dev/sda2, therefore it seems I don't need to change the UUID in the fstab, I just need to reinstall GRUB... However I could not do that. I will explain why below.
However I could not do "apt update" in chroot mode (to / root) with the error message: "The method driver /usr/lib/apt/methods/https could not be found". For the same reason I could not run the command There are no "https" entry in the sources.list file or sources.list.d/base.list file. I don't know why I am getting this error. I cannot use apt or apt-get. I am stuck at this point. I will probably just backup my /home partition and reinstall debian. It seems it will be much hassle-free.
Yes, I deleted EFI system partition, thinking debian's EFI files would be in the /boot partition, but it seems I was wrong.p.H wrote:Did you also delete the EFI system partition ? Did you create a separate EFI partition for Debian ?dx486 wrote:I deleted Windows partitions and reinstalled Windows 10 by a Windows 10 usb stick.
After that Windows 10 directly boots. There is no grub menu anymore.
It is an EFI setup.
If you deleted the EFI partition used by Debian, you deleted GRUB. You will have to update the UUID for the new EFI partition in /etc/fstab and reinstall GRUB.
If you did not delete the EFI partition containing GRUB, you should be able to select Debian from the UEFI firmware boot menu. Windows boots just because it became first in the boot order. The boot order can be changed with efibootmgr or in the UEFI firmware setup.
I managed to chroot and read the /etc/fstab file. It is written there in the comments that debian's EFI files were installed to /dev/sda2, while boot files were installed to /dev/sda6 (flagged as /boot during installation). Now Windows' EFI partition is still /dev/sda2, therefore it seems I don't need to change the UUID in the fstab, I just need to reinstall GRUB... However I could not do that. I will explain why below.
I first installed cryptsetup and then lvm2 to the live environment. Then I run the commands you mentioned, then chroot was successful.p.H wrote:Correct. You must open the encrypted volume and enable the LVM volumes (install lvm2 if not present).dx486 wrote:I guess there is no bash in /boot partition, that's why it cannot find it and gives that error message. I probably should decrypt my / partition with cryptsetup, then chroot to my / to fix the grub, right?and so on.Code: Select all
cryptsetup luksOpen /dev/sdXY sdXY_crypt vgchange -ay mount /dev/mapper/<vg>-<lv> /mnt
Note that the Debian installer rescue mode offers a more convenient way to chroot a Debian system.
However I could not do "apt update" in chroot mode (to / root) with the error message: "The method driver /usr/lib/apt/methods/https could not be found". For the same reason I could not run the command
Code: Select all
apt-get install --reinstall grub-efi
- Head_on_a_Stick
- Posts: 14114
- Joined: 2014-06-01 17:46
- Location: London, England
- Has thanked: 81 times
- Been thanked: 133 times
Re: chroot: failed to run command ‘/bin/bash’
Are you sure? How about any other files under /etc/apt/sources.list.d/?dx486 wrote:There are no "https" entry in the sources.list file or sources.list.d/base.list file
This will print out all source lines:
Code: Select all
grep -v '^#\|^$' /etc/apt/sources.list{,.d/*}
Installing the apt-transport-https package will allow APT to use https sources, here is the .deb so you can use `dpkg -i` to install it:
http://deb.debian.org/debian/pool/main/ ... _amd64.deb
deadbang
-
- Global Moderator
- Posts: 3049
- Joined: 2017-09-17 07:12
- Has thanked: 5 times
- Been thanked: 132 times
Re: chroot: failed to run command ‘/bin/bash’
The partition number did not change but this is not what is used. If the partition has been deleted, re-created and re-formated, it has a new UUID and you must update it in /etc/fstab. Check withdx486 wrote:I managed to chroot and read the /etc/fstab file. It is written there in the comments that debian's EFI files were installed to /dev/sda2, while boot files were installed to /dev/sda6 (flagged as /boot during installation). Now Windows' EFI partition is still /dev/sda2, therefore it seems I don't need to change the UUID in the fstab
Code: Select all
blkid /dev/sda2
Did you also mount /boot, /boot/efi, all the pseudo-filesystems which may be needed (/proc, /sys, /dev...) and so on ?dx486 wrote:Then I run the commands you mentioned, then chroot was successful.
Why do you want to reinstall this package ? It is absolutely useless and does nothing by itself. It just depends on grub-efi-amd64|ia32 depending on the system architecture. Anyway you do not need to reinstall this package either. You do not even need to run a chroot to reinstall GRUB. You can do it from the live system.dx486 wrote:I could not run the commandCode: Select all
apt-get install --reinstall grub-efi
From the chroot :
Mount /boot, /boot/efi, /proc, /dev, /sys.
Run "grub-install" without argument.
Done.
From the live system :
Mount the boot partition on /boot and the EFI partition on /boot/efi (create these directories if not present).
Install the package grub-efi-amd64-bin and its dependencies.
Run "grub-install" without argument.
Done.
Re: chroot: failed to run command ‘/bin/bash’
Thank you for your answer.Head_on_a_Stick wrote:Are you sure? How about any other files under /etc/apt/sources.list.d/?dx486 wrote:There are no "https" entry in the sources.list file or sources.list.d/base.list file
This will print out all source lines:It is possible that one of your mirrors automatically redirects to https so try using http://deb.debian.org instead (the website itself redirects to https but the source shouldn't if you specify http).Code: Select all
grep -v '^#\|^$' /etc/apt/sources.list{,.d/*}
Installing the apt-transport-https package will allow APT to use https sources, here is the .deb so you can use `dpkg -i` to install it:
http://deb.debian.org/debian/pool/main/ ... _amd64.deb
Yes you are right, there were a file under the "sources.list.d" directory contained one https link.
I renamed this file to not include it (it was for a third party app) and I become sure that there are not any https anywhere.
"sources.list" file contained "http://ftp.us..." links and "base.list" file contained "http://deb.debian.org..." links... Just in case, I've changed all "ftp.us" links to "http://deb.debian.org" links as you suggested.
Then error regarding "https" disappeared but "Could not resolve" error appeared. Then I pinged google and realized that http addresses were not recognized in chroot mode...
I don't understand why did this happen as this was a perfectly working system. Why it did not see hosts file under /etc?
I guess I need to copy live system's hosts file to the chroot system, probably with these commands:
Code: Select all
sudo cp /mnt/etc/hosts /mnt/etc/hosts.old
sudo cp /etc/hosts /mnt/etc/hosts
sudo cp /etc/resolv.conf /mnt/etc/resolv.conf
Last edited by dx486 on 2019-03-20 06:01, edited 2 times in total.
Re: chroot: failed to run command ‘/bin/bash’
This is a much easier method. I will be happy if I can do this. I want to try this without trying anything else. However I have a question first. When I boot to live USB, there is already a /boot of the live USB. How can I mount the boot partition to this already existing path?p.H wrote:From the live system :
Mount the boot partition on /boot and the EFI partition on /boot/efi (create these directories if not present).
Install the package grub-efi-amd64-bin and its dependencies.
Run "grub-install" without argument.
Done.
Update: OK, I just tried to mount it to that path anyway and it mounted.
Last edited by dx486 on 2019-03-20 08:32, edited 2 times in total.
-
- Global Moderator
- Posts: 3049
- Joined: 2017-09-17 07:12
- Has thanked: 5 times
- Been thanked: 132 times
Re: chroot: failed to run command ‘/bin/bash’
You just mount the partition as usual. Whether the mount directory is empty or not is irrelevant.
Alternatively you can mount the boot and EFI partitions on directories of your choice, but then you have to indicate them in the grub-install command with --boot-directory= and --efi-directory= options.
Alternatively you can mount the boot and EFI partitions on directories of your choice, but then you have to indicate them in the grub-install command with --boot-directory= and --efi-directory= options.
Re: chroot: failed to run command ‘/bin/bash’
OK, I just tried to mount it to that path anyway and it mounted.
/dev/sda2 was my Windows' EFI partition. It only contained 2 directory: EFI/Boot and EFI/Microsoft.
/dev/sda5 was my Debian's /boot partition.
Mounted /dev/sda2 on /boot
Mounted /dev/sda5 on /boot/EFI
Installed grub-efi-amd64-bin and grub2-common packages on live USB.
Run
on live USB.
Result:
Now I see a "grub" directory created in the /dev/sda2.
I also see some changes in the /dev/sda5. There are a "grub" and "efi" directory there, among other files.
/dev/sda2 was my Windows' EFI partition. It only contained 2 directory: EFI/Boot and EFI/Microsoft.
/dev/sda5 was my Debian's /boot partition.
Mounted /dev/sda2 on /boot
Mounted /dev/sda5 on /boot/EFI
Installed grub-efi-amd64-bin and grub2-common packages on live USB.
Run
Code: Select all
sudo grub-install
Result:
Code: Select all
Installing for x84_64-efi platform.
grub-install: error: cannot find EFI directory.
I also see some changes in the /dev/sda5. There are a "grub" and "efi" directory there, among other files.
- Head_on_a_Stick
- Posts: 14114
- Joined: 2014-06-01 17:46
- Location: London, England
- Has thanked: 81 times
- Been thanked: 133 times
Re: chroot: failed to run command ‘/bin/bash’
You have it backwards: mount /dev/sda5 under /boot and mount /dev/sda2 (the EFI system partition) under /boot/efidx486 wrote:/dev/sda2 was my Windows' EFI partition. It only contained 2 directory: EFI/Boot and EFI/Microsoft.
/dev/sda5 was my Debian's /boot partition.
Mounted /dev/sda2 on /boot
Mounted /dev/sda5 on /boot/EFI
Without any arguments that command will look for the ESP under /boot/efi but you have mounted it under /bootdx486 wrote:Runon live USB.Code: Select all
sudo grub-install
Either mount the ESP (/dev/sda2) under /boot/efi (and mount /dev/sda5 under /boot beforehand) and run the `grub-install` command without arguments or do as p.H suggested:
p.H wrote:you can mount the boot and EFI partitions on directories of your choice, but then you have to indicate them in the grub-install command with --boot-directory= and --efi-directory= options
deadbang
Re: chroot: failed to run command ‘/bin/bash’
A minor correction, grub-efi-amd64-bin's dependencies don't include grub2-common, which has the binary viz. grub-install.p.H wrote:From the live system :
Mount the boot partition on /boot and the EFI partition on /boot/efi (create these directories if not present).
Install the package grub-efi-amd64-bin and its dependencies.
Run "grub-install" without argument.
Done.
Having said that am immensely grateful to this post. Yesterday I applied an image of my running laptop to my other laptop, an ssd one and was clueless about installing grub efi. This post made it amply clear.
I had figured out how to install grub on an mbr disk but was not sure about a gpt one. Thank you to all the posters here.
-
- Global Moderator
- Posts: 3049
- Joined: 2017-09-17 07:12
- Has thanked: 5 times
- Been thanked: 132 times
Re: chroot: failed to run command ‘/bin/bash’
This has nothing to do with GPT vs MBR. GRUB for EFI supports both partition schemes.sickpig wrote:I had figured out how to install grub on an mbr disk but was not sure about a gpt one.
Re: chroot: failed to run command ‘/bin/bash’
Oh wasn't aware of that.
Thanks p.H, have learnt a lot just by reading your posts. U sir are an institution as far as grub and overall boot logic is concerned.
Thanks p.H, have learnt a lot just by reading your posts. U sir are an institution as far as grub and overall boot logic is concerned.