diff options
author | Graham Christensen <graham@grahamc.com> | 2022-03-08 09:28:41 -0500 |
---|---|---|
committer | Graham Christensen <graham@grahamc.com> | 2022-04-07 13:06:57 -0400 |
commit | bd3e9c3d051f77338b38ea44cc28cfc465923f41 (patch) | |
tree | e2f7c9cdb27ca305764e7f9bffb0c074d84b5847 /nixos/modules/tasks/filesystems | |
parent | 16543b630a58e4b4c0100d130d72a8c5b25fac8f (diff) | |
download | nixlib-bd3e9c3d051f77338b38ea44cc28cfc465923f41.tar nixlib-bd3e9c3d051f77338b38ea44cc28cfc465923f41.tar.gz nixlib-bd3e9c3d051f77338b38ea44cc28cfc465923f41.tar.bz2 nixlib-bd3e9c3d051f77338b38ea44cc28cfc465923f41.tar.lz nixlib-bd3e9c3d051f77338b38ea44cc28cfc465923f41.tar.xz nixlib-bd3e9c3d051f77338b38ea44cc28cfc465923f41.tar.zst nixlib-bd3e9c3d051f77338b38ea44cc28cfc465923f41.zip |
nixos/zfs: better support auto-expanding partitioned disks
Diffstat (limited to 'nixos/modules/tasks/filesystems')
-rw-r--r-- | nixos/modules/tasks/filesystems/zfs.nix | 37 |
1 files changed, 4 insertions, 33 deletions
diff --git a/nixos/modules/tasks/filesystems/zfs.nix b/nixos/modules/tasks/filesystems/zfs.nix index 3bc0dedec00e..fbfc61177d38 100644 --- a/nixos/modules/tasks/filesystems/zfs.nix +++ b/nixos/modules/tasks/filesystems/zfs.nix @@ -642,41 +642,14 @@ in }; scriptArgs = "%i"; - path = [ pkgs.gawk cfgZfs.package ]; - - # ZFS has no way of enumerating just devices in a pool in a way - # that 'zpool online -e' supports. Thus, we've implemented a - # bit of a strange approach of highlighting just devices. - # See: https://github.com/openzfs/zfs/issues/12505 - script = let - # This UUID has been chosen at random and is to provide a - # collision-proof, predictable token to search for - magicIdentifier = "NIXOS-ZFS-ZPOOL-DEVICE-IDENTIFIER-37108bec-aff6-4b58-9e5e-53c7c9766f05"; - zpoolScripts = pkgs.writeShellScriptBin "device-highlighter" '' - echo "${magicIdentifier}" - ''; - in '' + path = [ cfgZfs.package ]; + + script = '' pool=$1 echo "Expanding all devices for $pool." - # Put our device-highlighter script it to the PATH - export ZPOOL_SCRIPTS_PATH=${zpoolScripts}/bin - - # Enable running our precisely specified zpool script as root - export ZPOOL_SCRIPTS_AS_ROOT=1 - - devices() ( - zpool status -c device-highlighter "$pool" \ - | awk '($2 == "ONLINE" && $6 == "${magicIdentifier}") { print $1; }' - ) - - for device in $(devices); do - echo "Attempting to expand $device of $pool..." - if ! zpool online -e "$pool" "$device"; then - echo "Failed to expand '$device' of '$pool'." - fi - done + ${pkgs.zpool-auto-expand-partitions}/bin/zpool_part_disks --automatically-grow "$pool" ''; }; @@ -701,8 +674,6 @@ in RemainAfterExit = true; }; - path = [ pkgs.gawk cfgZfs.package ]; - script = '' for pool in ${poolListProvider}; do systemctl start --no-block "zpool-expand@$pool" |