ZFS: Difference between revisions

imported>2r
immutable root
imported>2r
zfs root
Line 25: Line 25:
## In /etc/nixos/configuration.nix:
## In /etc/nixos/configuration.nix:
   systemd.services.zfs-mount.enable = false;
   systemd.services.zfs-mount.enable = false;
boot.initrd.postDeviceCommands = ''
  zpool import -Nf rpool
  zfs rollback -r rpool/nixos/empty@start
  zpool export -a
'';
</syntaxhighlight>
</syntaxhighlight>


<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
## In /etc/nixos/hardware-configuration.nix:
## In /etc/nixos/hardware-configuration.nix:
## Create new root datasets
# zfs create -o canmount=noauto -o mountpoint=/ rpool/nixos/empty
# zfs snapshot rpool/nixos/empty@start


## Replace existing entry for / (root) with
## Replace existing entry for / (root) with
   fileSystems."/" = {
   fileSystems."/" =
     device = "none";
     { device = "rpool/nixos/empty";
    fsType = "tmpfs";
      fsType = "zfs"; options = [ "zfsutil" "noatime" "X-mount.mkdir" ];
    options = [ "defaults" "size=1G" "mode=755" ];
    };
  };


## Mount old root at /altroot
## Mount old root at /altroot