ZFS: Difference between revisions

Tboston (talk | contribs)
mNo edit summary
Tboston (talk | contribs)
use variables for simplicity
Line 108: Line 108:
   3        10487808      1000215175  471.9 GiB  8300  Linux filesystem
   3        10487808      1000215175  471.9 GiB  8300  Linux filesystem
</syntaxhighlight>
</syntaxhighlight>
'''Let's get our device names and put them as variables from now on.
Get the device ID in <code>/dev/disk/by-id/</code>, in our case here it is <code>nvme-SKHynix_HFS512GDE9X081N_FNB6N634510106K5O</code>
'''
<syntaxhighlight lang=bash>
BOOT=/dev/disk/by-id/nvme-SKHynix_HFS512GDE9X081N_FNB6N634510106K5O-part1
SWAP=/dev/disk/by-id/nvme-SKHynix_HFS512GDE9X081N_FNB6N634510106K5O-part2
DISK=/dev/disk/by-id/nvme-SKHynix_HFS512GDE9X081N_FNB6N634510106K5O-part3


'''Make zfs pool with encryption and mount points:'''
'''Make zfs pool with encryption and mount points:'''
Line 114: Line 122:


<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/nvme0n1p3
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 $DISK
# enter the password to decrypt the pool at boot
# enter the password to decrypt the pool at boot
Enter new passphrase:
Enter new passphrase:
Line 150: Line 158:
'''Format boot partition with fat as filesystem'''
'''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 $BOOT
</syntaxhighlight>
</syntaxhighlight>


'''Enable swap'''
'''Enable swap'''
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
mkswap -L swap /dev/nvme0n1p2
mkswap -L swap $SWAP
swapon /dev/nvme0n1p2
swapon $SWAP
</syntaxhighlight>
</syntaxhighlight>


'''Installation:'''
'''Installation:'''
 
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>
 
# Mount boot
# Mount boot
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
mkdir -p /mnt/boot
mkdir -p /mnt/boot
mount /dev/disk/by-id/nvme-SKHynix_HFS512GDE9X081N_FNB6N634510106K5O-part1 /mnt/boot
mount $BOOT /mnt/boot


# Generate the nixos config
# Generate the nixos config