From 2a2a625ebf5c8579a7f4b0353e3521ff0f403150 Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Thu, 3 Sep 2026 06:46:58 +0000 Subject: [PATCH] Hardcode "crytolvm" as NAME_LUKSVG. --- _lib.sh | 17 +++++++---------- chrooted_command.sh | 7 +++---- install_debian.sh | 10 ++++------ setup_luksvg.sh | 11 ++++------- 4 files changed, 18 insertions(+), 27 deletions(-) diff --git a/_lib.sh b/_lib.sh index 0e8c1ca..f6293cd 100644 --- a/_lib.sh +++ b/_lib.sh @@ -9,6 +9,7 @@ TO_RBIND="${NAME_DEV} proc sys" # constants we might want to change at some point NAME_DATA=data +NAME_LUKSVG=cryptolvm NAME_SWAP=swap PATH_MNT_ROOT="${PATH_MNT}/root" @@ -62,8 +63,7 @@ check_input_partition_mountable() { && error "${PARTITION} is already mounted" true } -check_input_new_luksvg() { - local NAME_LUKSVG=$1 +check_new_luksvg() { local PATH_LUKS_MAPPER PATH_LUKS_MAPPER=$(path_luks_mapper "${NAME_LUKSVG}") check_chars_legality "${NAME_LUKSVG}" "volume group name" @@ -75,8 +75,7 @@ check_input_new_luksvg() { } check_input_openable_luksvg() { local PARTITION=$1 - local NAME_LUKSVG=$2 - check_input_new_luksvg "${NAME_LUKSVG}" + check_input_new_luksvg try_quiet cryptsetup isLuks "${PARTITION}"\ || error "${PARTITION} not a LUKS container" } @@ -84,15 +83,13 @@ check_input_openable_luksvg() { # helpers: luks open/close open_luksvg () { local PARTITION=$1 - local LUKSVG=$2 - msg 'Opening LUKS container as "%s" …' "${LUKSVG}" - cryptsetup luksOpen "${PARTITION}" "${LUKSVG}" + msg 'Opening LUKS container as "%s" …' "${NAME_LUKSVG}" + cryptsetup luksOpen "${PARTITION}" "${NAME_LUKSVG}" } close_luksvg () { - local LUKSVG=$1 msg 'Deactivating volume group and closing LUKS container …' - vgchange -an "${LUKSVG}" - cryptsetup luksClose "${LUKSVG}" + vgchange -an "${NAME_LUKSVG}" + cryptsetup luksClose "${NAME_LUKSVG}" } # helpers: mount/unmount root diff --git a/chrooted_command.sh b/chrooted_command.sh index bcee658..9b73d46 100755 --- a/chrooted_command.sh +++ b/chrooted_command.sh @@ -4,7 +4,6 @@ # inputs to confirm usage $# "partition" "volume-group-name" "root-name" "command" PARTITION=$1 -NAME_LUKSVG=$2 NAME_ROOT=$3 COMMAND=$4 @@ -14,10 +13,10 @@ PATH_VG_ROOT=$(path_vg "${NAME_LUKSVG}")/${NAME_ROOT} # sanity checks check_tools cryptsetup vgs check_input_partition_mountable "${PARTITION}" -check_input_openable_luksvg "${PARTITION}" "${NAME_LUKSVG}" +check_input_openable_luksvg "${PARTITION}" # mount -open_luksvg "${PARTITION}" "${NAME_LUKSVG}" +open_luksvg "${PARTITION}" await_path "${PATH_VG_ROOT}" mount_privately "${PATH_VG_ROOT}" "${PATH_MNT_ROOT}" rbind_mnt @@ -28,6 +27,6 @@ chroot_sh "${COMMAND}" || RC=$? # clean up mounts unmount_unrbind -close_luksvg "${NAME_LUKSVG}" +close_luksvg msg 'Finished! (command exit status: %s)' "${RC}" exit "${RC}" diff --git a/install_debian.sh b/install_debian.sh index e723d3a..040ddc2 100755 --- a/install_debian.sh +++ b/install_debian.sh @@ -19,8 +19,7 @@ PATH_BOOT_DEVICE="${PATH_DEV}/nvme0n1" # inputs to confirm usage $# "partition" "volume-group-name" "boot-name" PARTITION=$1 -NAME_LUKSVG=$2 -NAME_BOOT=$3 +NAME_BOOT=$2 NAME_ROOT="${NAME_BOOT}" # constants derived from changeables @@ -38,7 +37,7 @@ PATH_VG_SWAP=${PATH_VG}/${NAME_SWAP} # sanity checks check_tools cryptsetup debootstrap efibootmgr lvcreate mkfs.ext4 vgs check_input_partition_mountable "${PARTITION}" -check_input_openable_luksvg "${PARTITION}" "${NAME_LUKSVG}" +check_input_openable_luksvg "${PARTITION}" check_chars_legality "${NAME_BOOT}" "boot label" [ -e "${PATH_EFI}/${NAME_BOOT}" ]\ && error "${PATH_EFI}/${NAME_BOOT} already exists" @@ -51,11 +50,10 @@ efibootmgr \ # run inputs by user and ask for confirmation msg 'Your installation choices:' msg '- target partition: [ %s ]' "${PARTITION}" -msg '- target volume group: [ %s ]' "${NAME_LUKSVG}" msg '- name for new boot option: [ %s ]' "${NAME_BOOT}" # set up logival volume and filesystem -open_luksvg "${PARTITION}" "${NAME_LUKSVG}" +open_luksvg "${PARTITION}" create_lv "${NAME_LUKSVG}" "${NAME_ROOT}" 10G await_path "${PATH_VG_ROOT}" msg 'Creating EXT4 filesystem …' @@ -152,5 +150,5 @@ chroot_sh "passwd" # clean up mounts unmount_unrbind -close_luksvg "${NAME_LUKSVG}" +close_luksvg msg 'Finished!' diff --git a/setup_luksvg.sh b/setup_luksvg.sh index 432c87e..5071f67 100755 --- a/setup_luksvg.sh +++ b/setup_luksvg.sh @@ -4,7 +4,6 @@ # inputs to confirm usage $# "partition" "volume-group-name" PARTITION=$1 -NAME_LUKSVG=$2 # constants we might want to change at some point CONFIG_FILES_TO_COPY="start_root.sh start_home.sh _lib.sh" @@ -20,14 +19,12 @@ PATH_VG_SWAP=${PATH_VG}/${NAME_SWAP} # sanity checks check_tools cryptsetup lvcreate mkfs.ext4 mkswap pvcreate vgcreate vgs check_input_partition_mountable "${PARTITION}" -check_input_new_luksvg "${NAME_LUKSVG}" +check_new_luksvg try_quiet cryptsetup isLuks "${PARTITION}"\ && error "${PARTITION} is already a LUKS container" # run inputs by user and ask for confirmation -msg 'Your formatting choices:' -msg '- target partition (WILL BE ERASED!): [ %s ]' "${PARTITION}" -msg '- name for new volume group and its LUKS mapper: [ %s ]' "${NAME_LUKSVG}" +msg 'Your target partition (WILL BE ERASED!): [ %s ]' "${PARTITION}" msg_nonl 'To continue, type "YES!" (all caps, exclamation mark, no quotes): ' read -r CONFIRM; [ "${CONFIRM}" = 'YES!' ]\ || die 'ABORTED: expected confirmation not given.' @@ -35,7 +32,7 @@ read -r CONFIRM; [ "${CONFIRM}" = 'YES!' ]\ # encrypt partition msg 'Formatting %s as LUKS container …' "${PARTITION}" cryptsetup luksFormat --batch-mode "${PARTITION}" -open_luksvg "${PARTITION}" "${NAME_LUKSVG}" +open_luksvg "${PARTITION}" # set up LVM and filesystems msg 'Creating volume group "%s" inside LUKS container …' "${NAME_LUKSVG}" @@ -58,5 +55,5 @@ msg 'Unmounting …' umount "${PATH_MNT_DATA}" # clean-up -close_luksvg "${NAME_LUKSVG}" +close_luksvg msg 'Finished!' -- 2.30.2