summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJörg Thalheim <joerg@thalheim.io>2022-11-25 12:52:40 +0100
committerlassulus <lassulus@lassul.us>2022-11-25 17:36:40 +0100
commit6bbdafce48bbd8a076e7f27bff17ea8fe6f531d4 (patch)
treebca74ed2cce440c937666de9938b646427afe64b
parent7a4c85b53e151f8a189a88336adbadc9305b4873 (diff)
zapCreateMount: stop mdraids
-rw-r--r--module.nix2
-rw-r--r--types.nix7
2 files changed, 8 insertions, 1 deletions
diff --git a/module.nix b/module.nix
index 958e006..dbb9d88 100644
--- a/module.nix
+++ b/module.nix
@@ -46,7 +46,7 @@ in {
${types.diskoLib.mount cfg.devices}
'';
- system.build.disko = pkgs.writers.writeDash "disko" ''
+ system.build.disko = pkgs.writers.writeBash "disko" ''
export PATH=${lib.makeBinPath (types.diskoLib.packages cfg.devices pkgs)}
${types.diskoLib.zapCreateMount cfg.devices}
'';
diff --git a/types.nix b/types.nix
index 92f11fb..2ed3ccc 100644
--- a/types.nix
+++ b/types.nix
@@ -152,6 +152,7 @@ rec {
*/
zapCreateMount = devices: ''
set -efux
+ shopt -s nullglob
# print existing disks
lsblk
@@ -161,6 +162,12 @@ rec {
umount -Rlv /mnt
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
+
echo 'creating partitions...'
${diskoLib.create devices}
echo 'mounting partitions...'