Modification : vm_{host,hosted,remote} -> {host,local,remote}/ .
[lhc/ateliers.git] / host / part-luks-format
diff --git a/host/part-luks-format b/host/part-luks-format
new file mode 100755 (executable)
index 0000000..3ed5ebd
--- /dev/null
@@ -0,0 +1,12 @@
+#!/bin/sh -eu
+tool=$(readlink -e "${0%/*}/..")
+. "$tool"/host/lib.sh
+
+# NOTE: la clef de chiffrement est dérivée de celle de /,
+#       / doit être déchiffrée pour que cela fonctionne.
+part="$1"
+eval "dev=\"\$vm_dev_disk_$part\""
+test ! -e /dev/mapper/${vm_lvm_lv}_root_deciphered ||
+sudo /bin/sh -c "/lib/cryptsetup/scripts/decrypt_derived ${vm_lvm_lv}_root_deciphered |
+cryptsetup luksFormat --hash=sha512 --key-size=512 \
+ --cipher=aes-xts-essiv:sha256 --key-file=- --align-payload=8 $dev"