ZFS: Difference between revisions

Tboston (talk | contribs)
No edit summary
Tboston (talk | contribs)
finalize zfs install on root example
Line 42: Line 42:




==== '''Simple NixOS ZFS installation''' ====
==== '''Simple NixOS ZFS in root installation''' ====


Start from here in the NixOS manual: [https://nixos.org/manual/nixos/stable/#sec-installation-manual].
Start from here in the NixOS manual: [https://nixos.org/manual/nixos/stable/#sec-installation-manual].
Line 112: Line 112:


'''Note:''' zpool config can significantly affect performance (especially the ashift option) so you may want to do some research. The [https://jrs-s.net/2018/08/17/zfs-tuning-cheat-sheet/ ZFS tuning cheatsheet] or [https://wiki.archlinux.org/title/ZFS#Storage_pools ArchWiki] is a good place to start.
'''Note:''' zpool config can significantly affect performance (especially the ashift option) so you may want to do some research. The [https://jrs-s.net/2018/08/17/zfs-tuning-cheat-sheet/ ZFS tuning cheatsheet] or [https://wiki.archlinux.org/title/ZFS#Storage_pools ArchWiki] is a good place to start.
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
zpool create -O encryption=on -O keyformat=passphrase -O keylocation=prompt -O compression=zstd -O mountpoint=none -O xattr=sa -O acltype=posixacl -o ashift=12 zpool /dev/nvme0n1p2
zpool create -O encryption=on -O keyformat=passphrase -O keylocation=prompt -O compression=zstd -O mountpoint=none -O xattr=sa -O acltype=posixacl -o ashift=12 zpool /dev/nvme0n1p3
# enter the password to decrypt the pool at boot
Enter new passphrase:
Re-enter new passphrase:


# Create datasets
zfs create zpool/root
zfs create zpool/root
zfs create zpool/nix
zfs create zpool/nix
Line 143: Line 148:
</syntaxhighlight>
</syntaxhighlight>


'''Make fat filesystem on boot partition'''
'''Format boot partition with fat as filesystem'''
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
mkfs.fat -F 32 -n boot /dev/nvme0n1p1
mkfs.fat -F 32 -n boot /dev/nvme0n1p1
</syntaxhighlight>
'''Enable swap'''
<syntaxhighlight lang="bash">
mkswap -L swap /dev/nvme0n1p2
swapon
</syntaxhighlight>
</syntaxhighlight>


Line 151: Line 162:
'''Installation:'''
'''Installation:'''


Install: [https://nixos.org/manual/nixos/stable/#sec-installation-manual-installing]
We're now using Disk IDs and not the device name because device names might change and NixOS Config Generation will be using the IDs anyway. Get the device ID in <code>/dev/disk/by-id/</code>, in our case here it is <code>nvme-SKHynix_HFS512GDE9X081N_FNB6N634510106K5O</code>
 
Jump to "2. UEFI systems"


# Mount boot
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
mkdir -p /mnt/boot
mkdir -p /mnt/boot
mount /dev/disk/by-partlabel/boot /mnt/boot
mount /dev/disk/by-id/nvme-SKHynix_HFS512GDE9X081N_FNB6N634510106K5O-part1 /mnt/boot
 
# Generate the nixos config
nixos-generate-config --root /mnt
...
writing /mnt/etc/nixos/hardware-configuration.nix...
writing /mnt/etc/nixos/configuration.nix...
For more hardware-specific settings, see https://github.com/NixOS/nixos-hardware.
</syntaxhighlight>
</syntaxhighlight>


Jump to "4." ... /mnt/etc/nixos/configuration.nix ...
Now edit the configuration.nix that was just created in <code>/mnt/etc/nixos/configuration.nix</code> and make sure to have at least the following content in it.
 
Continue from here and add this boot loader and filesystems config to your configuration.nix:


<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
Line 208: Line 223:
}
}
</syntaxhighlight>
</syntaxhighlight>
Now you may install nixos with <code>nixos-install</code>


== Importing on boot ==
== Importing on boot ==