Talk:ZFS: Difference between revisions

From NixOS Wiki
imported>Vater
m Vater moved page Talk:NixOS on ZFS to Talk:ZFS
imported>Thedude
Suggest adding 'sleep' to multi-pool encrypted ZFS example.
Line 13: Line 13:


--[[User:Mohe2015|Mohe2015]] ([[User talk:Mohe2015|talk]]) 15:46, 22 March 2021 (UTC)
--[[User:Mohe2015|Mohe2015]] ([[User talk:Mohe2015|talk]]) 15:46, 22 March 2021 (UTC)
== Multiple Encrypted Pools Issue ==
I tried following the "Import and unlock multiple encrypted pools/dataset at boot" section (and friends) but could not get it to work, with the dataset either not being mounted, or the boot aborting with a permission error. What finally fixed it for me:
  # Create pool like so:
  zpool create <your-other-options> -O keyformat=passphrase pool_name $DISK_HDD
 
And use this for initrd.network.postCommands:
        cat <<EOF > /root/.profile
        if pgrep -x "zfs" > /dev/null
        then
          zpool import hdd  # Import pool like in example
          sleep 3          #  <---- THIS IS THE IMPORTANT PART
          zfs load-key -a
          killall zfs
        else
          echo "zfs not running -- maybe the pool is taking some time to load for some unforseen reason."
        fi
        EOF
Long story short, I think the example on the ZFS page should include the sleep.

Revision as of 19:23, 23 October 2021

Add boot.initrd.supportedFilesystems = ["zfs"]; ?

What about recommending to also add

boot.initrd.supportedFilesystems = ["zfs"];

See https://github.com/NixOS/nixpkgs/pull/99386#issuecomment-798813567

I think recommending to add this would allow you in the far future to use zfs as filesystem without forcing to add grub support for zfs if you don't need it.

I currently have https://github.com/NixOS/nixpkgs/pull/117071 open to revert back to that behaviour like it's been in 20.09 (adding a zfs filesystem also adds support to grub, more exactly the original behaviour was to always enable zfs support in grub even without any zfs filesystem)

--Mohe2015 (talk) 15:46, 22 March 2021 (UTC)Reply


Multiple Encrypted Pools Issue

I tried following the "Import and unlock multiple encrypted pools/dataset at boot" section (and friends) but could not get it to work, with the dataset either not being mounted, or the boot aborting with a permission error. What finally fixed it for me:

 # Create pool like so:
 zpool create <your-other-options> -O keyformat=passphrase pool_name $DISK_HDD
 

And use this for initrd.network.postCommands:

       cat <<EOF > /root/.profile
       if pgrep -x "zfs" > /dev/null
       then
         zpool import hdd  # Import pool like in example
         sleep 3           #  <---- THIS IS THE IMPORTANT PART
         zfs load-key -a
         killall zfs
       else
         echo "zfs not running -- maybe the pool is taking some time to load for some unforseen reason."
       fi
       EOF

Long story short, I think the example on the ZFS page should include the sleep.