From 66add2cd9edab96f5e87477229772bf2b3ca513a Mon Sep 17 00:00:00 2001 From: lassulus Date: Thu, 8 Dec 2022 21:03:11 +0100 Subject: zap: destroy all mdadm devices if mdadm is in PATH --- types.nix | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'types.nix') diff --git a/types.nix b/types.nix index fa24607..fa6bc44 100644 --- a/types.nix +++ b/types.nix @@ -147,6 +147,7 @@ rec { # ensures that "/" is processed before "/foo" etc. ${concatStrings (attrValues fsMounts)} ''; + /* takes a disko device specification and returns a string which unmounts, destroys all disks and then runs create and mount zapCreateMount :: types.devices -> str @@ -164,10 +165,12 @@ rec { fi # stop all existing raids - for r in /dev/md/* /dev/md[0-9]*; do - # might fail if the device was already closed in the loop - mdadm --stop "$r" || true - done + if command -v mdadm; then + for r in /dev/md/* /dev/md[0-9]*; do + # might fail if the device was already closed in the loop + mdadm --stop "$r" || true + done + fi echo 'creating partitions...' ${diskoLib.create devices} -- cgit v1.2.3