home · contact · privacy
Hardcode "crytolvm" as NAME_LUKSVG.
authorChristian Heller <c.heller@plomlompom.de>
Thu, 3 Sep 2026 06:46:58 +0000 (06:46 +0000)
committerChristian Heller <c.heller@plomlompom.de>
Thu, 3 Sep 2026 06:46:58 +0000 (06:46 +0000)
_lib.sh
chrooted_command.sh
install_debian.sh
setup_luksvg.sh

diff --git a/_lib.sh b/_lib.sh
index 0e8c1ca88a5bfe62d0bc5dadab370c5d66bbd385..f6293cdc22c1ebc679f758bfd4a03db3f6020791 100644 (file)
--- 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 
index bcee658f5f79eb433eda70cd9cab743ff8f15661..9b73d46b9bcf9cffac4e4a8a1d11c8f468559cde 100755 (executable)
@@ -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}"
index e723d3a8b72d19b43f162af87d907d6ab6eadfe1..040ddc209b9399c015a6c6d1a25431fcc3085757 100755 (executable)
@@ -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!'
index 432c87e53f2572ee9ea561630ec64f04d9ca8013..5071f6799d92950ef991a3ffa0f7f11f19e5a5be 100755 (executable)
@@ -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!'