You are not logged in.

#1 2018-08-10 09:32:04

MountainX
Member
Registered: 2016-02-08
Posts: 371

[SOLVED] mkinitcpio in chroot ERROR: failed to detect root filesystem

I'm installing Arch on an encrypted BTRFS filesystem.

after performing prior installation steps, including decrypting and mounting all the required devices, including the non-encrypted boot partition, and running pacstrap I enter chroot:

# arch-chroot $path
# ls /
bin  boot  dev  etc  home  lib  lib64  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var

The root filesystem is as it should be after running pacstrap. The core system is installed.

Next I edit mkinitcpio.conf as follows:

# nano /etc/mkinitcpio.conf
BINARIES=(/usr/bin/btrfs)
FILES=(/boot/keyfile.bin)
HOOKS=(base udev keyboard autodetect encrypt modconf block filesystems fsck)
# bootctl install
# mkinitcpio -p linux

mkinitcpio gives the following error:

==> ERROR: failed to detect root filesystem

The expected files are in place, but something has clearly not worked.

# ls -la /boot
drwxr-x--x 4 root root     4096 Dec 31  1969 .
drwxr-x--x 1 root root      142 Aug 10 04:21 ..
-rwxr-x--x 1 root root    XXXXX Aug 10 04:38 keyfile.bin
drwxr-x--x 4 root root     4096 Aug 10 05:02 EFI
-rwxr-x--x 1 root root 31336314 Aug 10 05:15 initramfs-linux-fallback.img
-rwxr-x--x 1 root root 20767903 Aug 10 05:15 initramfs-linux.img
-rwxr-x--x 1 root root  1747456 Aug  8 03:47 intel-ucode.img
drwxr-x--x 3 root root     4096 Aug 10 05:02 loader
-rwxr-x--x 1 root root  5330896 Aug  6 19:05 vmlinuz-linux

The newly installed system fails to boot. I cannot get past the UEFI boot menu. The OS never starts so there are no OS related errors on boot. I've had this problem for a while and I haven't found any solution yet.

Last edited by MountainX (2018-08-10 21:22:57)

Offline

#2 2018-08-10 18:41:02

randomguy
Member
Registered: 2007-06-19
Posts: 101

Re: [SOLVED] mkinitcpio in chroot ERROR: failed to detect root filesystem

Which bootloader do you use?
The error happens when you chroot from the offical install image?

Last edited by randomguy (2018-08-10 18:45:33)

Offline

#3 2018-08-10 19:20:45

MountainX
Member
Registered: 2016-02-08
Posts: 371

Re: [SOLVED] mkinitcpio in chroot ERROR: failed to detect root filesystem

randomguy wrote:

Which bootloader do you use?
The error happens when you chroot from the offical install image?

Yes. I'm doing a normal install from the official Arch image, but the unique feature for me is apparently my use of a BTRFS encrypted file system where boot is on a separate unencrypted partition and there are separate BTRFS subvolumes for root (/), /home and /var/log.

It may help to know that this error also happens when I chroot from an installed system. It happens every time I run mkinitcpio on multiple different systems where I have run arch-chroot over the last months. One obvious common feature on all these systems is the encrypted BTRFS filesystem. (They may have other aspects in common too.)

The error first began happening around the beginning of 2018 after an update to the arch-chroot script. Prior to that time I did not get these errors.  Here is a different situation under which I get what appears to be the same error. In the present situation, however, it is much more clear because I am following the standard steps for a new installation from the official install image.

Offline

#4 2018-08-10 19:25:55

mxfm
Member
Registered: 2015-10-23
Posts: 166

Re: [SOLVED] mkinitcpio in chroot ERROR: failed to detect root filesystem

# arch-chroot $path

What is $path? Where it comes from? How do you call pacstrap? Why do you include btrfs executable in initrd? What is bootloader script?

My guess is that something wrong with the $path because mkinitcpio fails with this error when it cannot detect via findmnt filesystem type of '/' which may happen if there is something wrong with mounting '/' (perhaps also when doing pactrap and arch-chroot).

P.S. What has changed since that winter thread?

Last edited by mxfm (2018-08-10 19:33:51)

Offline

#5 2018-08-10 19:34:55

firecat53
Member
From: Lake Stevens, WA, USA
Registered: 2007-05-14
Posts: 1,542
Website

Re: [SOLVED] mkinitcpio in chroot ERROR: failed to detect root filesystem

I had the same issue recently. The problem was I mounted the btrfs root to /mnt, then created the subvolumes under that. When I tried to to chroot to /mnt/@root/, that's when I got the error. The solution was to unmount btrfs root and then mount the root subvolume directly before running any of the mkinitcpio or grub-install commands. 

mount -o compress=lzo,subvol=@root /dev/mapper/root /mnt

Hope that helps.

Last edited by firecat53 (2018-08-10 19:35:53)

Offline

#6 2018-08-10 19:50:55

MountainX
Member
Registered: 2016-02-08
Posts: 371

Re: [SOLVED] mkinitcpio in chroot ERROR: failed to detect root filesystem

mxfm wrote:
# arch-chroot $path

What is $path? Where it comes from? How do you call pacstrap? Why do you include btrfs executable in initrd? What is bootloader script?

My guess is that something wrong with the $path because mkinitcpio fails with this error when it cannot detect via findmnt filesystem type of '/' which may happen if there is something wrong with mounting '/' (perhaps also when doing pactrap and arch-chroot).

EDIT: once I read what firecat53 said, I realized he was pointing me in the right direction. I had replied here with info about $path and with responses to your other questions, but I deleted those once I realized this was all related to the way BTRFS subvolumes are mounted. Just trying to keep the discussion focused on and track. No need to add a bunch of irrelevant details.

Last edited by MountainX (2018-08-10 21:25:44)

Offline

#7 2018-08-10 19:53:30

MountainX
Member
Registered: 2016-02-08
Posts: 371

Re: [SOLVED] mkinitcpio in chroot ERROR: failed to detect root filesystem

firecat53 wrote:

I had the same issue recently. The problem was I mounted the btrfs root to /mnt, then created the subvolumes under that. When I tried to to chroot to /mnt/@root/, that's when I got the error. The solution was to unmount btrfs root and then mount the root subvolume directly before running any of the mkinitcpio or grub-install commands. 

mount -o compress=lzo,subvol=@root /dev/mapper/root /mnt

Hope that helps.

Yes, I think this is my issue. Can you be more specific about the way you do your mounts? I have tried various approaches. Most recently I am mounting everything before chroot. However, while working on this issue, I have also tried mounting all subvolumes after entering chroot. I did not hit on the right combination yet. Maybe if you share more details, I'll get it. Thanks.

Offline

#8 2018-08-10 20:02:13

firecat53
Member
From: Lake Stevens, WA, USA
Registered: 2007-05-14
Posts: 1,542
Website

Re: [SOLVED] mkinitcpio in chroot ERROR: failed to detect root filesystem

mount -o compress=lzo /dev/mapper/root /mnt
# ls /mnt/
@root @home @log
# umount /mnt

Where @root, @home and @log are your subvolumes and /dev/mapper/root is the unlocked encrypted partition. I'm assuming they are all subvolumes of /dev/mapper/root, without any additional partitions involved.

mount -o compress=lzo,subvol=@root /dev/mapper/root /mnt
mount -o compress=lzo,subvol=@home /dev/mapper/root /mnt/home
mount -o compress=lzo,subvol=@log /dev/mapper/root /mnt/var/log
pacstrap /mnt
arch-chroot /mnt

Hopefully that's a bit more clear...and I didn't make any dumb mistakes...typing this off the top of my head.

Last edited by firecat53 (2018-08-10 20:05:15)

Offline

#9 2018-08-10 20:09:52

mxfm
Member
Registered: 2015-10-23
Posts: 166

Re: [SOLVED] mkinitcpio in chroot ERROR: failed to detect root filesystem

MountainX wrote:
mxfm wrote:
# arch-chroot $path

What is $path? Where it comes from? How do you call pacstrap? Why do you include btrfs executable in initrd? What is bootloader script?

My guess is that something wrong with the $path because mkinitcpio fails with this error when it cannot detect via findmnt filesystem type of '/' which may happen if there is something wrong with mounting '/' (perhaps also when doing pactrap and arch-chroot).

Yes, as firecat53 said, it is probably something related to the paths or mount points of btrfs subvolumes.

I have a top level btrfs volume that doesn't do anything except hold @root, @home and @varlog subvolumes. I feel sure this is related to my issue.

It would be more helpful if you post actual code. For example, I asked about '$path' to see how you mount root, because it is likely relevant to the issue and '$path' is not standard (not from wiki), but you keep talking about you thinking this is related to subvolumes and how your setup is unique. BTW, in January thread you also preferred to keep talking and situation has not improved since then.

Offline

#10 2018-08-10 20:32:24

MountainX
Member
Registered: 2016-02-08
Posts: 371

Re: [SOLVED] mkinitcpio in chroot ERROR: failed to detect root filesystem

deleted

Last edited by MountainX (2018-08-10 21:23:27)

Offline

#11 2018-08-10 21:22:40

MountainX
Member
Registered: 2016-02-08
Posts: 371

Re: [SOLVED] mkinitcpio in chroot ERROR: failed to detect root filesystem

firecat53 wrote:
mount -o compress=lzo /dev/mapper/root /mnt
# ls /mnt/
@root @home @log
# umount /mnt

Where @root, @home and @log are your subvolumes and /dev/mapper/root is the unlocked encrypted partition. I'm assuming they are all subvolumes of /dev/mapper/root, without any additional partitions involved.

mount -o compress=lzo,subvol=@root /dev/mapper/root /mnt
mount -o compress=lzo,subvol=@home /dev/mapper/root /mnt/home
mount -o compress=lzo,subvol=@log /dev/mapper/root /mnt/var/log
pacstrap /mnt
arch-chroot /mnt

Hopefully that's a bit more clear...and I didn't make any dumb mistakes...typing this off the top of my head.

OK, I finally got this issue resolved, thanks to your suggestions. It is exactly as you said and I just had to fiddle with the subtle details of how the BTRFS subvolumes are mounted.

Offline

Board footer

Powered by FluxBB