You are not logged in.

#1 2018-10-21 13:44:46

starfry
Member
From: Surrey, UK
Registered: 2010-08-18
Posts: 230

Using mkinitcpio in a chroot (fails to detect ZFS root filesystem)

I have a build process that works except for building the initramfs image file. The process involves building into a temporary directory using 'pacstrap' and performing additional steps using 'arch-chroot', one of which involves configuring and building the initial ram filesystem.

The problem that I have is that the 'autodetect' hook fails to detect the root file system and, therefore, produces an incomplete initramfs. This happens because the hook calls 'findmnt -uno fstype -T /' to establish the root file system's type. That fails in my chroot.

I notice this happens when building on a ZFS host. I have tried using an ext4 build host and that detects the root file system as ext4. The system being built is for a ZFS root file system (so it's incorrectly reported on an ext4 build host).

What I need to do is to tell mkinitcpio that the root file system (of the chrooted build) is ZFS. How can I do this?

Offline

#2 2018-10-22 00:02:26

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: Using mkinitcpio in a chroot (fails to detect ZFS root filesystem)

Hmm, why does findmnt report it as not zfs then?

Anyway, I wonder why this doesn't instead use

stat -f -c %T /

Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#3 2018-10-24 20:06:06

starfry
Member
From: Surrey, UK
Registered: 2010-08-18
Posts: 230

Re: Using mkinitcpio in a chroot (fails to detect ZFS root filesystem)

Sorry it took me a while to get around to checking it. Your suggestion of using stat does work correctly. is this something we might be able to get fixed in mkinitcpio? Should I raise a bug report for this?

Offline

#4 2018-10-24 21:04:03

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: Using mkinitcpio in a chroot (fails to detect ZFS root filesystem)

Apparently, because for e.g. ext4 it returns "ext2/ext3".

What does `wipefs` return for you?


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#5 2018-10-24 22:00:57

starfry
Member
From: Surrey, UK
Registered: 2010-08-18
Posts: 230

Re: Using mkinitcpio in a chroot (fails to detect ZFS root filesystem)

Not sure if that was a joke wink

AFAIK wipefs requires a device rather than a path you'd need to get the device's underlying path.

Offline

#6 2018-10-24 22:09:09

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: Using mkinitcpio in a chroot (fails to detect ZFS root filesystem)

If it's a joke, the authors of stat are the ones telling it! (But under the hood, ext2/3/4 are the same thing with different feature flags.)

As for wipefs, correct -- what's the problem there?

For that matter, what does findmnt return?


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#7 2018-10-25 19:22:01

starfry
Member
From: Surrey, UK
Registered: 2010-08-18
Posts: 230

Re: Using mkinitcpio in a chroot (fails to detect ZFS root filesystem)

eschwartz wrote:

As for wipefs, correct -- what's the problem there?

Inside the chroot, I cannot determine the device (or don't know how to). Normally I would use findmnt to discover that.

eschwartz wrote:

For that matter, what does findmnt return?

When I run 'findmnt -uno fstype -T /' (or without the options) it just exits with a status code 1.

I modified my /usr/lib/initcpio/install/autodetect at line 33 to change from this:

# detect filesystem for root                                                          
if rootfstype=$(findmnt -uno fstype -T '/'); then     

to this

# detect filesystem for root                                                          
if rootfstype=$(findmnt -uno fstype -T '/' || stat -f -c %T '/' ); then     

Which works for me and should also work on any existing configuration where findmnt works as expected. Do you think that might make for a sensible compromise solution ?

(apologies for irratic responses, I guess time-zones are at play)

Offline

Board footer

Powered by FluxBB