ZFS: Difference between revisions

X-osc (talk | contribs)
fix headings
Change the /etc/aliases configuration to use Nix instead
(One intermediate revision by one other user not shown)
Line 82: Line 82:
Under manual partitioning [https://nixos.org/manual/nixos/stable/#sec-installation-manual-partitioning] do this instead:
Under manual partitioning [https://nixos.org/manual/nixos/stable/#sec-installation-manual-partitioning] do this instead:


==== Partition your disk with your favorite partition tool ====
==== Partition the disk ====
We need the following partitions:
We need the following partitions:


Line 143: Line 143:
</syntaxhighlight>
</syntaxhighlight>


'''Let's use variables from now on for simplicity.
'''Let's use variables from now on for simplicity.''' Get the device ID in <code>/dev/disk/by-id/</code> (using {{ic|blkid}}), in our case here it is <code>nvme-SKHynix_HFS512GDE9X081N_FNB6N634510106K5O</code>
Get the device ID in <code>/dev/disk/by-id/</code> (using {{ic|blkid}}), in our case here it is <code>nvme-SKHynix_HFS512GDE9X081N_FNB6N634510106K5O</code>
 
'''
<syntaxhighlight lang=bash>
<syntaxhighlight lang=bash>
BOOT=/dev/disk/by-id/nvme-SKHynix_HFS512GDE9X081N_FNB6N634510106K5O-part1
BOOT=/dev/disk/by-id/nvme-SKHynix_HFS512GDE9X081N_FNB6N634510106K5O-part1
Line 154: Line 153:
{{note|It is often recommended to specify the drive using the device ID/UUID to prevent incorrect configuration, but it is also possible to use the device name (e.g. /dev/sda). See also: [[#Zpool created with bus-based disk names]], [https://wiki.archlinux.org/title/Persistent_block_device_naming Persistent block device naming - ArchWiki]}}
{{note|It is often recommended to specify the drive using the device ID/UUID to prevent incorrect configuration, but it is also possible to use the device name (e.g. /dev/sda). See also: [[#Zpool created with bus-based disk names]], [https://wiki.archlinux.org/title/Persistent_block_device_naming Persistent block device naming - ArchWiki]}}


'''Make a ZFS pool with encryption and mount points'''
==== Make a ZFS pool with encryption and mount points ====


'''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 ZFS tuning cheatsheet or ArchWiki is a good place to start.}}


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
Line 195: Line 194:
</syntaxhighlight>
</syntaxhighlight>


'''Format boot partition with FAT as filesystem'''
==== Format boot partition and enable swap ====
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
mkfs.fat -F 32 -n boot $BOOT
mkfs.fat -F 32 -n boot $BOOT
</syntaxhighlight>
</syntaxhighlight>


'''Enable swap'''
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
mkswap -L swap $SWAP
mkswap -L swap $SWAP
Line 206: Line 204:
</syntaxhighlight>
</syntaxhighlight>


'''Installation'''
==== Installation ====
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
# Mount boot
# Mount boot
Line 487: Line 484:
Then, configure an alias for root account. With this alias configured, all mails sent to root, such as cron job results and failed sudo login events, will be redirected to the configured email account.
Then, configure an alias for root account. With this alias configured, all mails sent to root, such as cron job results and failed sudo login events, will be redirected to the configured email account.


<syntaxhighlight lang="bash">
<syntaxhighlight lang="nix">
tee -a /etc/aliases <<EOF
{
root: user@example.com
  environment.etc.aliases.text = ''
EOF
    root: you@example.com
  '';
}
</syntaxhighlight>
</syntaxhighlight>