Nixos ZFS on root: all zpools and datasets have mountpoint set to none

Hello, I’m experimenting with zfs lately and I reformat all the hard drives on my (still under construction) server with zfs. I used the official guide https://wiki.nixos.org/wiki/ZFS#Guides through the “Simple NixOS ZFS on root installation” way (I did some adjustments, essentially I didn’t use swap or encryption).

What confuses me is that while on ext4 for example partitions would mount to specific points (like I had a /home partion that mounted on /home), using both zfs list and lsblk, all the datasets of the zpool (and the zpool of course) appear to have no mountpoints (mountpoint is none on zfs list and the field is empty on lsblk).

$ zfs list
NAME         USED  AVAIL  REFER  MOUNTPOINT
zroot       14.1G   877G    96K  none
zroot/home  5.75M   877G  5.75M  none
zroot/nix   13.9G   877G  13.9G  none
zroot/root   660K   877G   660K  none
zroot/var    149M   877G   149M  none
$ lsblk -o NAME,SIZE,TYPE,MOUNTPOINTS,LABEL,START,PTTYPE,FSSIZE,FSAVAIL,FSUSED,FSUSE%,FSTYPE,STATE /dev/nvme0n1
NAME          SIZE TYPE MOUNTPOINTS LABEL   START PTTYPE FSSIZE FSAVAIL FSUSED FSUSE% FSTYPE     STATE
nvme0n1     931,5G disk                           gpt                                            live
├─nvme0n1p1     4G part /boot       boot     2048 gpt        4G      4G  39,4M     1% vfat       
└─nvme0n1p2 927,5G part             zroot 8390656 gpt                                 zfs_member 

I suppose I’m missing something, maybe zfs doesn’t work that way, or nixos handles it differently?

Here’s the hardware-configuration.nix file: https://codeberg.org/BlastboomStrice/dotfiles/src/branch/main/.config/nixos-config/hosts/nixos-base/hardware-configuration.nix

I also have a lengthy file with essentially the commands I used to imperatively set up zfs if you need that, but since it’s a bit too much to process I guess this command should say enough (I do notice that sets mountpoints to none, but then the guide says how to mount these datasets):

sudo zpool create -f -O compression=zstd -O mountpoint=none -O xattr=sa -O acltype=posixacl -o ashift=12 zroot /dev/disk/by-id/nvme-Samsung_SSD_970_EVO_Plus_1TB_XXXXXXXXXXXXXXXX-part2
2 Likes

zpool mountpoint should be none, zfs dataset should be legacy, then configured like

fileSystems."/" =
    { device = "rpool/nixos";
      fsType = "zfs";
      neededForBoot = true;
    };

to be managed by systemd or zfsutil with a mountpoint set per zfs volume (zfs set mountpoint=/a/path). The zpool(s) are imported on boot, if zfsutils is used volumes got mounted following their mountpoint zfs parameter, if legacy is used are mount by systemd.

Personally I have swap and crypto root over zfs but with legacy mountpoints and works flawlessly since years, never tried the zfsutil option though.

Your boot.initrd.kernelModules = ; should be boot.initrd.kernelModules = [ “zfs” ]; and might be needed supportedFilesystems = { zfs = true; }; as well.

As a personal preference instead of using by-id devices I prefer by-partlables so I can more easily swap drives if needed.

2 Likes

Ahh I see, you use legacy mountpoints and let the system handle them, while when set to none zfs handle them. I thought the MOUNTPOINTS column should report where they mount to, but instead it reports the type of the mountpoints.
I also found this that explains it as well: https://superuser.com/questions/1830695/what-are-the-differences-between-mountpoint-legacy-and-mountpoint-none-for-zfs-d

About the options you mention, since the nixos wiki guide didn’t mention them I skipped them and doesn’t seem to be an issue for now.
I think I should have mentioned that the system seems to work properly, it’s just that I couldn’t figure what the MOUNTPOINTS column and its values meant.

About by-partlabels, hm interesting point, will probably not go with that, but may keep it mind.

Thanks:)

1 Like