Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 283ef6bc6d07
Choose a base ref
...
head repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: d633ec9787a7
Choose a head ref
  • 5 commits
  • 2 files changed
  • 2 contributors

Commits on Oct 7, 2019

  1. nixos/zfs: only enable trim if zfs is enabled

    Also don't fail the service if there are no pools yet.
    This might happen on installation ISOs.
    Mic92 committed Oct 7, 2019
    1
    Copy the full SHA
    a412d90 View commit details

Commits on Oct 8, 2019

  1. nixos/zfs: avoid script derivation for trim service

    Since we only have a single pipe we can save the overhead of building a derivation
    when creating the zfs trim service file when building the system.
    Mic92 committed Oct 8, 2019
    Copy the full SHA
    692656d View commit details

Commits on Oct 14, 2019

  1. nixos/zfs: simplify logic for scrub/autosnapshot service

    This makes them consistent with the way zfs.trim is enabled
    and allow to enable them by default in future.
    Mic92 committed Oct 14, 2019
    2
    Copy the full SHA
    9a89467 View commit details
  2. Copy the full SHA
    12880e5 View commit details
  3. Merge pull request #70601 from Mic92/zfs-trim

    nixos/zfs: only enable trim if zfs is enabled
    Mic92 authored Oct 14, 2019
    Copy the full SHA
    d633ec9 View commit details
Showing with 19 additions and 10 deletions.
  1. +13 −0 nixos/doc/manual/release-notes/rl-2003.xml
  2. +6 −10 nixos/modules/tasks/filesystems/zfs.nix
13 changes: 13 additions & 0 deletions nixos/doc/manual/release-notes/rl-2003.xml
Original file line number Diff line number Diff line change
@@ -36,6 +36,19 @@
quirk in the boot menu.
</para>
</listitem>
<listitem>
<para>
By default zfs pools will now be trimmed on a weekly basis.
Trimming is only done on supported devices (i.e. NVME or SSDs)
and should improve throughput and lifetime of these devices.
It is controlled by the <varname>services.zfs.trim.enable</varname> varname.
The zfs scrub service (<varname>services.zfs.autoScrub.enable</varname>)
and the zfs autosnapshot service (<varname>services.zfs.autoSnapshot.enable</varname>)
are now only enabled if zfs is set in <varname>config.boot.initrd.supportedFilesystems</varname> or
<varname>config.boot.supportedFilesystems</varname>. These lists will automatically contain
zfs as soon as any zfs mountpoint is configured in <varname>fileSystems</varname>.
</para>
</listitem>
</itemizedlist>
</section>

16 changes: 6 additions & 10 deletions nixos/modules/tasks/filesystems/zfs.nix
Original file line number Diff line number Diff line change
@@ -16,9 +16,7 @@ let
inInitrd = any (fs: fs == "zfs") config.boot.initrd.supportedFilesystems;
inSystem = any (fs: fs == "zfs") config.boot.supportedFilesystems;

enableAutoSnapshots = cfgSnapshots.enable;
enableAutoScrub = cfgScrub.enable;
enableZfs = inInitrd || inSystem || enableAutoSnapshots || enableAutoScrub;
enableZfs = inInitrd || inSystem;

kernel = config.boot.kernelPackages;

@@ -395,7 +393,7 @@ in

system.fsPackages = [ packages.zfsUser ]; # XXX: needed? zfs doesn't have (need) a fsck
environment.systemPackages = [ packages.zfsUser ]
++ optional enableAutoSnapshots autosnapPkg; # so the user can run the command to see flags
++ optional cfgSnapshots.enable autosnapPkg; # so the user can run the command to see flags

services.udev.packages = [ packages.zfsUser ]; # to hook zvol naming, etc.
systemd.packages = [ packages.zfsUser ];
@@ -487,7 +485,7 @@ in
systemd.targets.zfs.wantedBy = [ "multi-user.target" ];
})

(mkIf enableAutoSnapshots {
(mkIf (enableZfs && cfgSnapshots.enable) {
systemd.services = let
descr = name: if name == "frequent" then "15 mins"
else if name == "hourly" then "hour"
@@ -525,7 +523,7 @@ in
}) snapshotNames);
})

(mkIf enableAutoScrub {
(mkIf (enableZfs && cfgScrub.enable) {
systemd.services.zfs-scrub = {
description = "ZFS pools scrubbing";
after = [ "zfs-import.target" ];
@@ -552,15 +550,13 @@ in
};
})

(mkIf cfgTrim.enable {
(mkIf (enableZfs && cfgTrim.enable) {
systemd.services.zpool-trim = {
description = "ZFS pools trim";
after = [ "zfs-import.target" ];
path = [ packages.zfsUser ];
startAt = cfgTrim.interval;
script = ''
zpool list -H -o name | xargs -n1 zpool trim
'';
serviceConfig.ExecStart = "${pkgs.runtimeShell} -c 'zpool list -H -o name | xargs --no-run-if-empty -n1 zpool trim'";
};
})
];