ZFS: Difference between revisions
imported>Vater m some people are prefering 'console' for syntax highlighting :-/ :-) |
imported>Vater mNo edit summary |
||
| Line 18: | Line 18: | ||
Just add the following to your <code>configuration.nix</code> file: | Just add the following to your <code>configuration.nix</code> file: | ||
<syntaxhighlight lang= | <syntaxhighlight lang=nix> | ||
boot.supportedFilesystems = [ "zfs" ]; | boot.supportedFilesystems = [ "zfs" ]; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 53: | Line 53: | ||
The <code>nixos-generate-config</code> command regenerates your <code>/etc/nixos/hardware-configuration.nix</code> file, which includes the list of filesystems for NixOS to mount during boot, e.g.: | The <code>nixos-generate-config</code> command regenerates your <code>/etc/nixos/hardware-configuration.nix</code> file, which includes the list of filesystems for NixOS to mount during boot, e.g.: | ||
<syntaxhighlight lang= | <syntaxhighlight lang=nix> | ||
fileSystems."/home" = | fileSystems."/home" = | ||
{ device = "rpool/home"; | { device = "rpool/home"; | ||
| Line 72: | Line 72: | ||
To change the maximum size of the ARC cache to (for example) 12 GB, add this to your NixOS configuration: | To change the maximum size of the ARC cache to (for example) 12 GB, add this to your NixOS configuration: | ||
<syntaxhighlight lang= | <syntaxhighlight lang=nix> | ||
boot.kernelParams = ["zfs.zfs_arc_max=12884901888"]; | boot.kernelParams = ["zfs.zfs_arc_max=12884901888"]; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 81: | Line 81: | ||
Regular scrubbing of ZFS pools is recommended and can be enabled in your NixOS configuration via: | Regular scrubbing of ZFS pools is recommended and can be enabled in your NixOS configuration via: | ||
<syntaxhighlight lang= | <syntaxhighlight lang=nix> | ||
services.zfs.autoScrub.enable = true; | services.zfs.autoScrub.enable = true; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 110: | Line 110: | ||
Then, to enable the auto-snapshot service, add this to your <code>configuration.nix</code>: | Then, to enable the auto-snapshot service, add this to your <code>configuration.nix</code>: | ||
<syntaxhighlight lang= | <syntaxhighlight lang=nix> | ||
services.zfs.autoSnapshot.enable = true; | services.zfs.autoSnapshot.enable = true; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 119: | Line 119: | ||
You can globally override this configuration by setting the desired number of snapshots in your <code>configuration.nix</code>, like this: | You can globally override this configuration by setting the desired number of snapshots in your <code>configuration.nix</code>, like this: | ||
<syntaxhighlight lang= | <syntaxhighlight lang=nix> | ||
services.zfs.autoSnapshot = { | services.zfs.autoSnapshot = { | ||
enable = true; | enable = true; | ||
| Line 358: | Line 358: | ||
In case you want unlock a machine remotely (after an update), having a dropbear ssh service in initrd for the password prompt is handy: | In case you want unlock a machine remotely (after an update), having a dropbear ssh service in initrd for the password prompt is handy: | ||
<syntaxhighlight lang= | <syntaxhighlight lang=nix> | ||
boot = { | boot = { | ||
initrd.network = { | initrd.network = { | ||
| Line 397: | Line 397: | ||
The following example follows the remote unlocking with dropbear, but imports another pool also and prompts for unlocking (either when at the machine itself or when logging in remotely: | The following example follows the remote unlocking with dropbear, but imports another pool also and prompts for unlocking (either when at the machine itself or when logging in remotely: | ||
<syntaxhighlight lang= | <syntaxhighlight lang=nix> | ||
boot = { | boot = { | ||
initrd.network = { | initrd.network = { | ||
| Line 422: | Line 422: | ||
* For older versions it is still possible to enable it in the existing ISO at runtime adding: | * For older versions it is still possible to enable it in the existing ISO at runtime adding: | ||
<syntaxhighlight lang= | <syntaxhighlight lang=nix> | ||
{ | { | ||
boot.supportedFilesystems = [ "zfs" ]; | boot.supportedFilesystems = [ "zfs" ]; | ||