summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlassulus <lassulus@lassul.us>2022-12-08 21:03:11 +0100
committerlassulus <lassulus@lassul.us>2022-12-08 21:03:38 +0100
commit66add2cd9edab96f5e87477229772bf2b3ca513a (patch)
tree3488cf739ef87f7dc1a346d9921e3038de5ee31e
parente0ce5fb75f1197cf57b0a5c46434d69c14efc842 (diff)
zap: destroy all mdadm devices if mdadm is in PATH
-rw-r--r--README.md2
-rw-r--r--types.nix11
2 files changed, 8 insertions, 5 deletions
diff --git a/README.md b/README.md
index 333f2a6..845fcd6 100644
--- a/README.md
+++ b/README.md
@@ -114,7 +114,7 @@ $ nix-channel --update
``` nix
{
- imports = [ "${builtins.fetchTarball "https://github.com/nix-community/disko/archive/main.tar.gz"}/modules/disko.nix" ];
+ imports = [ "${builtins.fetchTarball "https://github.com/nix-community/disko/archive/master.tar.gz"}/module.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}