summaryrefslogtreecommitdiff
path: root/alis-recovery.sh
diff options
context:
space:
mode:
authorpico.dev <pico.dev@gmail.com>2020-04-15 22:14:57 +0200
committerpico.dev <pico.dev@gmail.com>2020-04-15 22:14:57 +0200
commitc5bca8f8439d6f4a6492ee08cf1efc793aa55a42 (patch)
tree345a0963e9caf5a00723b02881392b1c1c0508ce /alis-recovery.sh
parent5236852c9267ebee6930451f927f10e9069c6dd8 (diff)
Update LUKS and LVM logic
Fixes #86
Diffstat (limited to 'alis-recovery.sh')
-rw-r--r--alis-recovery.sh28
1 files changed, 16 insertions, 12 deletions
diff --git a/alis-recovery.sh b/alis-recovery.sh
index 65622bc..99ed8eb 100644
--- a/alis-recovery.sh
+++ b/alis-recovery.sh
@@ -50,7 +50,8 @@ PARTITION_BIOS=""
PARTITION_BOOT=""
PARTITION_ROOT=""
DEVICE_ROOT=""
-LVM_VOLUME_PHISICAL="lvm"
+DEVICE_LVM=""
+LUKS_DEVICE_NAME="cryptroot"
LVM_VOLUME_GROUP="vg"
LVM_VOLUME_LOGICAL="root"
BOOT_DIRECTORY=""
@@ -222,16 +223,17 @@ function prepare_partition() {
umount /mnt/boot
umount /mnt
fi
- if [ -e "/dev/mapper/$LVM_VOLUME_LOGICAL" ]; then
- if [ -n "$PARTITION_ROOT_ENCRYPTION_PASSWORD" ]; then
- cryptsetup close $LVM_VOLUME_LOGICAL
- fi
+ if [ -e "/dev/mapper/$LVM_VOLUME_GROUP-$LVM_VOLUME_LOGICAL" ]; then
+ lvremove --force "$LVM_VOLUME_GROUP-$LVM_VOLUME_LOGICAL"
fi
- if [ -e "/dev/mapper/$LVM_VOLUME_PHISICAL" ]; then
- if [ -n "$PARTITION_ROOT_ENCRYPTION_PASSWORD" ]; then
- cryptsetup close $LVM_VOLUME_PHISICAL
- fi
+ if [ -e "/dev/mapper/$LVM_VOLUME_GROUP" ]; then
+ vgremove --force "/dev/mapper/$LVM_VOLUME_GROUP"
+ pvremove "/dev/mapper/$LUKS_DEVICE_NAME"
+ fi
+ if [ -e "/dev/mapper/$LUKS_DEVICE_NAME" ]; then
+ cryptsetup close $LUKS_DEVICE_NAME
fi
+ partprobe $DEVICE
}
function configure_network() {
@@ -313,13 +315,15 @@ function partition() {
# luks and lvm
if [ -n "$PARTITION_ROOT_ENCRYPTION_PASSWORD" ]; then
- echo -n "$PARTITION_ROOT_ENCRYPTION_PASSWORD" | cryptsetup --key-file=- open $PARTITION_ROOT $LVM_VOLUME_PHISICAL
+ echo -n "$PARTITION_ROOT_ENCRYPTION_PASSWORD" | cryptsetup --key-file=- open $PARTITION_ROOT $LUKS_DEVICE_NAME
sleep 5
fi
+ if [ -n "$PARTITION_ROOT_ENCRYPTION_PASSWORD" ]; then
+ DEVICE_ROOT="/dev/mapper/$LUKS_DEVICE_NAME"
+ fi
if [ "$LVM" == "true" ]; then
- DEVICE_ROOT_MAPPER="$LVM_VOLUME_GROUP-$LVM_VOLUME_LOGICAL"
- DEVICE_ROOT="/dev/mapper/$DEVICE_ROOT_MAPPER"
+ DEVICE_ROOT="/dev/mapper/$LVM_VOLUME_GROUP-$LVM_VOLUME_LOGICAL"
fi
PARTITION_OPTIONS="defaults"