You are not logged in.

#1 2019-07-26 02:19:43

Empanada
Member
Registered: 2019-07-26
Posts: 7

Arch-chroot Fails - Can't Find /bin/bash

Problem background: Arch was previously sharing a drive with Windows. When I removed Windows, I used gparted to move boot and / "left", allowing / to be expanded into the newly free space. I was aware this might cause failure to boot, but it seemed it would be a simple matter to chroot in from a live USB and fix it afterward. It did break, of course, but now chroot seems to be broken as well. I'm doing the following from an Arch live USB, made today using the .iso from archlinux.org with GNOME Disk Utility.

root@archiso ~ # mkdir /mnt/arch
root@archiso ~ # cryptsetup luksOpen /dev/sdb4 encrypted-volume
Enter passphrase for /dev/sdb4:
root@archiso ~ # mount /dev/mapper/encrypted-volume /mnt/arch
root@archiso ~ # mount /dev/sdb3 /mnt/arch/boot
mount: /mnt/arch/boot: more filesystems detected on /dev/sdb3: use -t <type> or wipefs(8).
1 root@archiso ~ # arch-chroot /mnt/arch
chroot: failed to run command ■/bin/bash■: No such file or directory

I confirmed that /mnt/arch/bin/bash exists, so this isn't the problem.
I remember reading that the chroot failure can be caused by damaged libraries that bash depends on, but everything worked fine before I moved the partition, and I haven't tried to upgrade or install/remove anything since.
Any ideas would be greatly appreciated!

Offline

#2 2019-07-26 05:18:56

Soptik
Member
Registered: 2019-03-11
Posts: 64

Re: Arch-chroot Fails - Can't Find /bin/bash

What is the output of

ls /mnt/arch

What happens when you run /mnt/arch/bin/bash ?

And did chroot always work the way you’re setting it up now?

If bash in /mnr/arch doesn’t work, you can always reinstall bash without chroot. Pacman has —root option:

pacman —root /mnt/arch -S bash

Last edited by Soptik (2019-07-26 05:30:40)

Offline

#3 2019-07-26 06:29:25

frostschutz
Member
Registered: 2013-11-15
Posts: 1,658

Re: Arch-chroot Fails - Can't Find /bin/bash

do you have a separate partition for /usr? if so, you have to mount that, too. (all binaries are on /usr and / is just an empty shell... this is the reason we don't do separate / and /usr anymore)

also check what is going in with your /boot

Offline

#4 2019-07-26 13:18:45

Empanada
Member
Registered: 2019-07-26
Posts: 7

Re: Arch-chroot Fails - Can't Find /bin/bash

Soptik wrote:

What is the output of

ls /mnt/arch
 bin   boot   dev   proc   run   sys   tmp   usr
Soptik wrote:

What happens when you run

/mnt/arch/bin/bash

?

root@archiso ~ # /mnt/arch/bin/bash
[root@archiso] ~]#

It appears to work.

Soptik wrote:

Did chroot always work the way you're setting it up now?

I use it so infrequently that I couldn't say whether I'm doing it the same as last time.

frostschutz wrote:

Do you have a separate partition for /usr?

No.

frostschutz wrote:

Also check what is going on with your /boot

Before mounting sdb3 to /mnt/arch/boot:

root@archiso ~ # ls /mnt/arch/boot
grub   initramfs-linux.img    initramfs-linux-fallback.img    vmlinuz-linux

Which doesn't seem right, as I have a separate boot partition that isn't mounted yet.

wipefs /dev/sdb3* returns:

DEVICE    OFFSET    TYPE    UUID                                      LABEL
sdb3      0x438     ext2    cebddc73-a4cc-4685-8328-c0cf9f102229   
sdb3      0x3       ntfs    925AC7F45AC7D2E1                          System Reserved

That's weird... Why's there an ntfs filesystem on my boot partition?

Offline

#5 2019-07-26 22:28:47

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,715

Re: Arch-chroot Fails - Can't Find /bin/bash

Empanada wrote:

That's weird... Why's there an ntfs filesystem on my boot partition?

Did you install it in accordance with the official documentation?  If so, you made an error.

Or, perhaps, did you use any kind of install script?


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
---
How to Ask Questions the Smart Way

Offline

#6 2019-07-27 01:43:17

Empanada
Member
Registered: 2019-07-26
Posts: 7

Re: Arch-chroot Fails - Can't Find /bin/bash

I did use the official documentation. That was about four years ago, and I don't remember much detail, but I just followed the wiki instructions. It's worked fine since.

Offline

#7 2019-07-27 07:10:25

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,500

Re: Arch-chroot Fails - Can't Find /bin/bash

Windows could have rambo'd the FS header in there after you attempted to make it extfs?

I'd compare the timestamps resp. "file vmlinuz-linux" outputs of the files in umounted and mounted /boot and check which partition you're actually booting from (re*naming* the files in the unmounted /boot should not change anything if you're booting from sdb3)
If the up-to-date kernel is on sdb4 and some dated ones on sdb3 you simply forgot to mount that partition before updating.

Offline

#8 2019-07-27 16:49:25

Empanada
Member
Registered: 2019-07-26
Posts: 7

Re: Arch-chroot Fails - Can't Find /bin/bash

I've confirmed that the up to date kernel is on sdb3. Looks like /boot was created accidentally at some point in 2017, and isn't what I've been using to boot from.

I did the following to see if I could chroot after mounting the correct boot partition:
(using live USB)

mkdir /mnt/arch
cryptsetup luksOpen /dev/sdb4 encrypted-volume
mount /dev/mapper/encrypted-volume /mnt/arch
mv /mnt/arch/boot /mnt/arch/boot2 #rename the boot partition that shouldn't be there
mkdir /mnt/arch/boot
mount -t ext2 /dev/sdb3 /mnt/arch/boot
arch-chroot /mnt/arch

This results in the same old error about /bin/bash.

After learning a bit more about the GRUB2 command line, I tried to attack the problem from a different angle:
(in GRUB rescue mode)

set prefix=(hd0,3)/grub
insmod normal
normal

This gets me out of rescue mode into the normal GRUB command line, where I can specify the initrd and kernel to use:

linux (hd0,3)/vmlinuz-linux cryptdevice=/dev/sdb4:root root=/dev/mapper/root
initrd (hd0,3)/initramfs-linux.img
boot

After entering the password, I get the following:

:: performing fsck on '/dev/mapper/root'
/dev/mapper/root: clean, 522756/2542736 files, 3141005/10162688 blocks
******************** WARNING ***********************
*                                                  *
* The root device is not configured to be mounted  *
* read-write! It may be fsck'd again later.        *
*                                                  *
****************************************************
:: mounting '/dev/mapper/root' on real root
:: running cleanup hook [udev]
ERROR: Root device mounted successfully, but /sbin/init does not exist.
Bailing out, you are on your own. Good luck.

sh: can't access tty; job control turned off
[rootfs ]#

stat /sbin/init shows that it does exist, and appears to be a symlink to busybox.
Trying the above procedure with the lts or zen kernels, which were also kept up to date, results in the same output.
It seems that solving either the chroot problem OR the /sbin/init problem could get me to the point of being able to fix this. Should I start a new thread for this, or keep it all here?

Offline

#9 2019-07-27 16:55:14

loqs
Member
Registered: 2014-03-06
Posts: 19,101

Re: Arch-chroot Fails - Can't Find /bin/bash

From the rootfs prompt

stat /new_root/sbin/init

Offline

#10 2019-07-27 17:17:03

Empanada
Member
Registered: 2019-07-26
Posts: 7

Re: Arch-chroot Fails - Can't Find /bin/bash

loqs wrote:

From the rootfs promp

stat /new_root/sbin/init

No such file or directory.
Ah, that's where the contents of / are...

Offline

#11 2019-07-27 17:31:37

loqs
Member
Registered: 2014-03-06
Posts: 19,101

Re: Arch-chroot Fails - Can't Find /bin/bash

sbin should be a symlink to usr/bin and usr/bin/init a symlink to ../lib/systemd/systemd is one of those two links or their targets missing?

Offline

#12 2019-07-27 18:24:11

Empanada
Member
Registered: 2019-07-26
Posts: 7

Re: Arch-chroot Fails - Can't Find /bin/bash

/lib/systemd/systemd is missing
/lib/systemd contains libsystemd-shared-240.so and systemd-udevd

When I add init=/lib/systemd/systemd-udevd in the kernel line in grub, I get the same error as before, but now claiming that systemd-udevd does not exist.

Offline

#13 2019-07-27 19:34:32

loqs
Member
Registered: 2014-03-06
Posts: 19,101

Re: Arch-chroot Fails - Can't Find /bin/bash

From the live media

pacman --root=/mnt/ -Qkk &> pacman-qkk.log

Then please post the contents of pacman-qkk.log to a pastebin (see the tip box to post from the live media)

Offline

#14 2019-07-27 19:57:49

Empanada
Member
Registered: 2019-07-26
Posts: 7

Re: Arch-chroot Fails - Can't Find /bin/bash

No need for a pastebin here:

error: failed to initialize alpm library
(could not find or read directory: /mnt/arch/var/lib/pacman/)

/mnt/arch/var doesn't exist.

root@archiso /mnt/arch # find . -name "pacman"
./usr/share/bash-completion/completions/pacman
./usr/share/pacman
./usr/bin/pacman

Last edited by Empanada (2019-07-27 21:43:32)

Offline

#15 2019-07-27 20:00:21

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,500

Re: Arch-chroot Fails - Can't Find /bin/bash

According to #4 there isn't even a /var directory - is /var usually an extra partition?

Offline

Board footer

Powered by FluxBB