Return to

Zfs on Root on Gentoo not auto importing at boot

So I’ve really gone off the deep end here and I’ve tried to install Gentoo on my old netbook thing and I have everything working, except the import of the root pool on boot (which is basically everything). The thing that really confuses me is that when I try to boot, it drops me into a busybody recovery shell and I can manually import the pool, exit the shell, and everything boots fine. For some context, I use Gentoo on my desktop and server, but in a non-ZFS capacity. I’ve only used ZFS on my FreeNas box and that’s mostly through the web UI.

I’ve been trying to follow the guides here and here. I don’t really know where to look for the issues, but I think it has something to do with what I’m telling grub is my root pool.

Whenever I try to boot with GRUB and I hit ‘e’ to edit, I can see the Linux line says linux /vmlinuz-5.4.38-FC.01 root=ZFS=tank/gentoo/ROOT to dozfs real_root=ZFS=tank. I’ve tried different permuations of tank vs tank/gentoo vs tank/gentoo/ROOT for root and real_root, but to no avail. However, after I get to the recovery shell, zpool import -R /mnt/root tank imports everything correctly to the /mnt/root directory. Then I can type exit and it boots fine. What gives?

Also, if you need more information please don’t hesitate to ask. As I said before, I don’t know where to look for these kind of issues so I don’t mind doing some digging.

have you properly configured your /etc/zfs/zfs.cache and exported the pool, rather than just shut down?

If ZFS doesn’t export properly, sometimes it won’t mount on boot.

Not 100% if this will help but I had issues on Debian with zfs root. Had to set a wait time on the grub. My brain is failing me on the exact command but some googling should point you in the right direction.
Sometimes the drives aren’t ready to mount when grub goes to mount the pool…

1 Like

definitely did not look into that. I’ll try that and give it a quick test

1 Like

Also not a bad thing to look into as this is an older system. Do you remember what was good wait time? 5s? 10s?

I think I had mine set to 10s but you can always start there and lower it see if it still boots


If your drives aren’t online after 10s you have other problems.


Still a no go. I’ve set a delay to 10 seconds but same results. I’ve even modified the linux line in grub to say dozfs=force and remove the real_root, but nothing.

@SgtAwesomesauce, I’ve run zpool set cachefile=/etc/zfs/zpool.cache tank, and there’s no error, but when I run zpool get cachefile tank immediately after, it says there’s a value of ‘none’. Is there some other way of setting that value? Should I delete the existing /etc/zfs/zpool.cache first?

What are you using to create your initramfs? Some ppl got issues with genkernel, dracut is more straghtforward.

First things first

make modules_install
emerge -v zfs-kmod zfs`

Actually dracut uses some failover methods as it doesn’t require finicky hostid and other things.

The trick is to add in /etc/dracut.conf this:


and as a save measure exclude in command options lvm and dm like this:

-o "dm lvm"

those add unnecessary complexity to the init process and if you aren’t using those it’s pointless include them. Those are added by default by dracut. It doesn’t meant you wont be able to use, those can be started with ‘rc-udpdate’ any time later in the boot process.

In your init for a minimal set up the only ones needed in init are the following

rc-update zfs-import boot
rc-update zfs-mount boot

The other two I don’t know what they do:


I am not familiar with the crazy complexities of grub, but a safe way to have all together is to add initramfs.cpio into the kernel. For this AFTER creating the initramfs.cpio add the path in the kernel:

General setup -> Initial RAM filesystem and RAM disk

Again make:

cd /usr/src/linux

And use the resulting bzImage

By the way ‘dozfs=force’ is INCORRECT, use this:


This option is kinda bulletproof, there’s a new more elegant way of doing but I haven’t looked at it yet.