Hi,
I am trying to setup a zfs example, but I am not able to get it work properly.
First I create the partitions, basically:
- no swap,
- a partition for root, which will be enabled with zfs + encryption
- a partition for boot with zfs (no encryption – could be encrypted?)
- a partition for efi (fat32) with esp flag turned on
Then I create the pools:
zpool create \
-o compatibility=grub2 \
-o ashift=12 \
-o autotrim=on \
-O acltype=posixacl \
-O canmount=off \
-O compression=lz4 \
-O devices=off \
-O normalization=formD \
-O relatime=on \
-O xattr=sa \
-O mountpoint=/boot \
-R "/mnt" \
zboot \
/dev/vda2
zpool create \
-o ashift=12 \
-o autotrim=on \
-R "/mnt" \
-O acltype=posixacl \
-O canmount=off \
-O compression=zstd \
-O dnodesize=auto \
-O normalization=formD \
-O relatime=on \
-O xattr=sa \
-O mountpoint=/ \
zroot \
/dev/vda3
First question: maybe I can avoid the compatibility with grub2, since I am using systemd-boot?
Nevertheless, it should not be an error…
Then I create the datasets and the EFI:
mkfs.fat -F 32 -n EFI /dev/vda1
zfs create \
-o canmount=off \
-o mountpoint=none \
zboot/nixos
zfs create \
-o canmount=off \
-o mountpoint=none \
-o encryption=on \
-o keylocation=prompt \
-o keyformat=passphrase \
zroot/nixos
zfs create -o mountpoint=legacy zboot/nixos/boot
zfs create -o mountpoint=legacy zroot/nixos/root
zfs create -o mountpoint=legacy zroot/nixos/home
And here already I do not know if it is fine to pass legacy
and canmount=off
, since for what I read they seems old options, but all the tutorial found uses them…
Then I mount, as:
mount -t zfs zroot/nixos/root /mnt/
mkdir -p /mnt/boot
mount -t zfs zboot/nixos/boot /mnt/boot
mkdir -p /mnt/boot/efi
mount /dev/vda1 /mnt/boot/efi
mkdir -p /mnt/home
mount -t zfs zroot/nixos/home /mnt/home
Then the configuration:
boot.loader.systemd-boot.enable = true;
boot.loader.efi.efiSysMountPoint = "/boot/efi";
boot.loader.efi.canTouchEfiVariables = true;
boot.initrd.systemd.enable = true;
boot.kernelPackages = pkgs.zfs.latestCompatibleLinuxPackages;
boot.supportedFilesystems = [ "zfs" ];
boot.initrd.supportedFilesystems = [ "zfs" ];
boot.zfs.requestEncryptionCredentials = true;
networking.hostId = "12345678";
boot.zfs.forceImportAll = false;
boot.zfs.forceImportRoot = false;
And the hw config:
fileSystems."/" =
{ device = "zroot/nixos/root";
fsType = "zfs";
};
fileSystems."/boot" =
{ device = "zboot/nixos/boot";
fsType = "zfs";
};
fileSystems."/boot/efi" =
{ device = "/dev/disk/by-uuid/824F-1CB0";
fsType = "vfat";
};
fileSystems."/home" =
{ device = "zroot/nixos/home";
fsType = "zfs";
};
swapDevices = [ ];
The current error is the following:
> nixos-install --no-root-password --root /mnt --cores 0
Traceback (most recent call last):
File "/nix/store/9c2qb99qs0yswf0xkfrqgawxbiq580lp-systemd-boot", line 341, in <module>
main()
File "/nix/store/9c2qb99qs0yswf0xkfrqgawxbiq580lp-systemd-boot", line 258, in main
subprocess.check_call(["/nix/store/8lgs0dqh9ks1164fp4g14gq7w1ihjbf0-systemd-253.5/bin/bootctl", "--esp-path=/boot/efi"] + bootctl_flags + ["install"])
File "/nix/store/lwzzgbnj41d657lpxczk6l5f7d5zcnj1-python3-3.10.11/lib/python3.10/subprocess.py", line 369, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/nix/store/8lgs0dqh9ks1164fp4g14gq7w1ihjbf0-systemd-253.5/bin/bootctl', '--esp-path=/boot/efi', 'install']' returned non-zero exit status 1.
Can someone please explain me what I am doing wrong please?
Thank you.
Regards