From b4319a49217e69ad9c2e31199ba52c25b4d1bb7a Mon Sep 17 00:00:00 2001 From: xengineering Date: Sat, 21 Mar 2020 14:58:48 +0100 Subject: Implement Formatting and Mounting for LUKS --- stages/first_stage.sh | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) (limited to 'stages/first_stage.sh') diff --git a/stages/first_stage.sh b/stages/first_stage.sh index b7a45b1..302192b 100644 --- a/stages/first_stage.sh +++ b/stages/first_stage.sh @@ -44,7 +44,6 @@ fi if [ "$path_to_disk" == "/dev/null" ]; then # check if a disk is selected print_failed "path_to_disk variable has still default value '/dev/null'" - exit 1 fi if [ "$boot_mode" == "uefi" ]; then @@ -142,15 +141,41 @@ elif [ "$luks_encryption" == "yes" ];then print_ok "Formatting for disk encryption and bios/mbr ..." - print_failed "Sorry, encryption is not ready to use" - exit 1 ### + # root partition + echo -n "$DEFAULT_PASSWORD" | cryptsetup luksFormat ${path_to_disk}2 - + echo -n "$DEFAULT_PASSWORD" | cryptsetup open ${path_to_disk}2 main - + mkfs.ext4 /dev/mapper/main + e2label /dev/mapper/main "root" + mount /dev/mapper/main /mnt + + # boot partition + mkfs.ext4 ${path_to_disk}1 + e2label ${path_to_disk}1 "boot" + mkdir /mnt/boot + mount ${path_to_disk}1 /mnt/boot elif [ "$boot_mode" == "uefi" ];then print_ok "Formatting for disk encryption and uefi/gpt ..." - print_failed "Sorry, encryption is not ready to use" - exit 1 ### + # root partition + echo -n "$DEFAULT_PASSWORD" | cryptsetup luksFormat ${path_to_disk}3 - + echo -n "$DEFAULT_PASSWORD" | cryptsetup open ${path_to_disk}3 main - + mkfs.ext4 /dev/mapper/main + e2label /dev/mapper/main "root" + mount /dev/mapper/main /mnt + + # boot partition + mkfs.ext4 ${path_to_disk}2 + e2label ${path_to_disk}2 "boot" + mkdir /mnt/boot + mount ${path_to_disk}2 /mnt/boot + + # efi partition + mkfs.fat -F32 ${path_to_disk}1 + fatlabel ${path_to_disk}1 "efi" + mkdir /mnt/mnt + mount ${path_to_disk}1 /mnt/mnt fi -- cgit v1.2.3-70-g09d2