From 1ca9e3465fad33971a1896e5610248a42862133d Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sun, 4 Jul 2021 15:08:59 +0900 Subject: [PATCH 01/48] Overwrite install is implemented Issue #5 OVERWRITEINSTALL confirmation is missing --- script/lib.sh | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/script/lib.sh b/script/lib.sh index 7c874a6..18a412a 100644 --- a/script/lib.sh +++ b/script/lib.sh @@ -70,7 +70,7 @@ function confirmation(){ return 1 # with error status fi # if YES - # For sure ask to be sure to erase. + # For sure ask to erase. if [ "${ERASEALL}" -ne 0 ] ; then echo "Are you sure you want to erase entire ${DEV}? [Y/N]" read -r YESNO @@ -78,6 +78,19 @@ function confirmation(){ cat <<-HEREDOC ...Check your config.sh. The variable ERASEALL is ${ERASEALL}. + ...Installation process terminated.. + HEREDOC + return 1 # with error status + fi # if YES + + # For sure ask to overwrite. + if [ "${OVERWRITEINSTALL}" -ne 0 ] ; then + echo "Are you sure you want to overwrite ${LVROOTNAME} in ${VGNAME}? [Y/N]" + read -r YESNO + if [ "${YESNO}" != "Y" ] && [ "${YESNO}" != "y" ] ; then + cat <<-HEREDOC + ...Check your config.sh. The variable OVERWRITEINSTALL is ${OVERWRITEINSTALL}. + ...Installation process terminated.. HEREDOC return 1 # with error status From c504de3d9b68efe663a746debee08bb00044275e Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sun, 4 Jul 2021 15:15:06 +0900 Subject: [PATCH 02/48] Fix unbalance if - fi --- script/lib.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/script/lib.sh b/script/lib.sh index 18a412a..06ca086 100644 --- a/script/lib.sh +++ b/script/lib.sh @@ -82,6 +82,7 @@ function confirmation(){ HEREDOC return 1 # with error status fi # if YES + fi # if erase all # For sure ask to overwrite. if [ "${OVERWRITEINSTALL}" -ne 0 ] ; then @@ -95,7 +96,7 @@ function confirmation(){ HEREDOC return 1 # with error status fi # if YES - fi # if erase all + fi # if overwrite # ----- Set Passphrase ----- # Input passphrase From 91db393dd2bd0d75e7038ad2700b67e6cb54a8d5 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sun, 4 Jul 2021 15:18:14 +0900 Subject: [PATCH 03/48] Add double quote for ease-of-read --- script/lib.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/script/lib.sh b/script/lib.sh index 06ca086..d68bf77 100644 --- a/script/lib.sh +++ b/script/lib.sh @@ -72,7 +72,7 @@ function confirmation(){ # For sure ask to erase. if [ "${ERASEALL}" -ne 0 ] ; then - echo "Are you sure you want to erase entire ${DEV}? [Y/N]" + echo "Are you sure you want to erase entire \"${DEV}\"? [Y/N]" read -r YESNO if [ "${YESNO}" != "Y" ] && [ "${YESNO}" != "y" ] ; then cat <<-HEREDOC @@ -86,7 +86,7 @@ function confirmation(){ # For sure ask to overwrite. if [ "${OVERWRITEINSTALL}" -ne 0 ] ; then - echo "Are you sure you want to overwrite ${LVROOTNAME} in ${VGNAME}? [Y/N]" + echo "Are you sure you want to overwrite \"${LVROOTNAME}\" in \"${VGNAME}\"? [Y/N]" read -r YESNO if [ "${YESNO}" != "Y" ] && [ "${YESNO}" != "y" ] ; then cat <<-HEREDOC From 70ae04d1e143e9f58159992cb22f51ad5b8480da Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sun, 4 Jul 2021 15:33:36 +0900 Subject: [PATCH 04/48] Update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c80ecd..1eb39aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ Record of the modification in project development. ### Added ### Changed +- [Issue 5 : OVERWRITEINSTALL confirmation is missing](https://github.com/suikan4github/kaiten-yaki/issues/5) + ### Deprecated ### Removed ### Fixed From 717fe7687a107579ab0b35999acb8c0dbd523974 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sun, 4 Jul 2021 15:50:36 +0900 Subject: [PATCH 05/48] Removed sed dependency Issue #6 Remove loglevel dependency from the void-kaiten-yaki.sh --- script/void-kaiten-yaki.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/script/void-kaiten-yaki.sh b/script/void-kaiten-yaki.sh index d2c1332..6dd8da4 100644 --- a/script/void-kaiten-yaki.sh +++ b/script/void-kaiten-yaki.sh @@ -50,14 +50,14 @@ function main() { else # Not yet. Let's add. echo "...Modify /etc/default/grub." - sed -i "s#loglevel=4#loglevel=4 ${GRUB_ADDITIONAL_PARAMETERS}#" /etc/default/grub - + sed -i -e "/GRUB_CMDLINE_LINUX_DEFAULT/{s#\"# ${GRUB_ADDITIONAL_PARAMETERS}\"#2}" /etc/default/grub fi # Common part of the pre-install stage if ! pre_install ; then + # If error, restore the modification. echo "...restoring modified /etc/default/grub." - sed -i "s#loglevel=4 ${GRUB_ADDITIONAL_PARAMETERS}#loglevel=4#" /etc/default/grub + sed -i -e "s#loglevel=4 ${GRUB_ADDITIONAL_PARAMETERS}#loglevel=4#" /etc/default/grub return 1 # with error status fi From 2554ed823a42d532e6be8bbc24dc963d74e2e8ab Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sun, 4 Jul 2021 16:19:47 +0900 Subject: [PATCH 06/48] Update changelog. --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1eb39aa..b654921 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,11 +6,12 @@ Record of the modification in project development. ### Added ### Changed - [Issue 5 : OVERWRITEINSTALL confirmation is missing](https://github.com/suikan4github/kaiten-yaki/issues/5) +- [Issue 6 : Remove loglevel dependency from the void-kaiten-yaki.sh ](https://github.com/suikan4github/kaiten-yaki/6) ### Deprecated ### Removed ### Fixed -### Security + ### Known Issue ## [1.0.0] - 2021-07-03 From fb47c71a02cc48f507e2055789d390d604889e21 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sun, 4 Jul 2021 16:28:19 +0900 Subject: [PATCH 07/48] Cancelation message corrected. Wrong message after cancallation Issue : #8 --- script/lib.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/script/lib.sh b/script/lib.sh index d68bf77..0d03ad7 100644 --- a/script/lib.sh +++ b/script/lib.sh @@ -294,13 +294,15 @@ function deactivate_and_close(){ # ******************************************************************************* function on_unexpected_installer_quit(){ echo "***** ERROR : The GUI/TUI installer terminated unexpectedly. *****" - if [ "${OVERWRITEINSTALL}" -eq 0 ] ; then # If not over install, volume is new. So delete it + if [ "${OVERWRITEINSTALL}" -ne 0 ] ; then # If overwrite install, keep the volume + echo "...Keep logical volume \"${VGNAME}-${LVROOTNAME}\" untouched." + else # if not overwrite istall, delete the new volume echo "...Deleting the new logical volume \"${VGNAME}-${LVROOTNAME}\"." lvremove -f /dev/mapper/"${VGNAME}"-"${LVROOTNAME}" fi # Deactivate all lg and close the LUKS volume deactivate_and_close - echo "...The new logical volume has been deleted. You can retry Kaiten-yaki again." + echo "...You can retry Kaiten-yaki again." } From 989ca530ceaefa75f391e626038d173b9d249f8d Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sun, 4 Jul 2021 16:35:05 +0900 Subject: [PATCH 08/48] Changelog updated --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b654921..557e539 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ Record of the modification in project development. ### Deprecated ### Removed ### Fixed +- [Issue 8 : Wrong message after cancellation ](https://github.com/suikan4github/kaiten-yaki/8) ### Known Issue From 6810e4414a1e0ba1804e7e41e6eed720af10843d Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sun, 4 Jul 2021 21:41:49 +0900 Subject: [PATCH 09/48] Added error handling Add the return status validation Issue #7 --- script/lib.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/script/lib.sh b/script/lib.sh index 0d03ad7..895f331 100644 --- a/script/lib.sh +++ b/script/lib.sh @@ -138,16 +138,20 @@ function pre_install() { # Zap existing partition table and create new GPT echo "...Initializing \"${DEV}\" with GPT." sgdisk --zap-all "${DEV}" + if is_error ; then return 1 ; fi; # If error, terminate # Create EFI partition and format it echo "...Creating an EFI partition on \"${DEV}\"." # shellcheck disable=SC2140 sgdisk --new="${EFIPARTITION}":0:+"${EFISIZE}" --change-name="${EFIPARTITION}":"EFI System" --typecode="${EFIPARTITION}":ef00 "${DEV}" + if is_error ; then return 1 ; fi; # If error, terminate echo "...Formatting the EFI parttion." mkfs.vfat -F 32 -n EFI-SP "${DEV}${EFIPARTITION}" + if is_error ; then return 1 ; fi; # If error, terminate # Create Linux partition echo "...Creating a Linux partition on ${DEV}." # shellcheck disable=SC2140 sgdisk --new="${CRYPTPARTITION}":0:0 --change-name="${CRYPTPARTITION}":"Linux LUKS" --typecode="${CRYPTPARTITION}":8309 "${DEV}" + if is_error ; then return 1 ; fi; # If error, terminate # Then print them sgdisk --print "${DEV}" else # BIOS @@ -159,6 +163,7 @@ function pre_install() { sfdisk "${DEV}" <<- HEREDOC 2M,,L HEREDOC + if is_error ; then return 1 ; fi; # If error, terminate fi # if EFI firmware # Encrypt the partition to install Linux @@ -194,8 +199,10 @@ function pre_install() { else echo "...Initializing a physical volume on \"${CRYPTPARTNAME}\"" pvcreate /dev/mapper/"${CRYPTPARTNAME}" + if [ $? -ne 0 ] ; then deactivate_and_close; return 1 ; fi; echo "...And then creating Volume group \"${VGNAME}\"." vgcreate "${VGNAME}" /dev/mapper/"${CRYPTPARTNAME}" + if [ $? -ne 0 ] ; then deactivate_and_close; return 1 ; fi; fi # if /dev/volume-groupt exist # Create a SWAP Logical Volume on VG, if it doesn't exist @@ -204,6 +211,7 @@ function pre_install() { else echo "...Creating logical volume \"${LVSWAPNAME}\" on \"${VGNAME}\"." lvcreate -L "${LVSWAPSIZE}" -n "${LVSWAPNAME}" "${VGNAME}" + if [ $? -ne 0 ] ; then deactivate_and_close; return 1 ; fi; fi # if /dev/mapper/swap volume already exit. # Create a ROOT Logical Volume on VG. @@ -331,4 +339,21 @@ function distribution_check(){ # no error return 0 +} + + +# ******************************************************************************* +# Error report and return revsers status. +# ******************************************************************************* +function is_error() { + if [ $? -eq 0 ] ; then # Is previous job OK? + return 1 # If OK, return error ( because it was not error ) + else + cat <<- HEREDOC + **** ERROR ! **** + + Installation process terminated. + HEREDOC + return 0 # If error, return OK ( because it was error ) + fi; } \ No newline at end of file From 95d8c6f62cfc1281194364647975af2f068ba15f Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sun, 4 Jul 2021 21:54:29 +0900 Subject: [PATCH 10/48] Add and adjust erro rhanding. Add error handling afer dd. Error message of pre-install is now conditional. --- script/lib.sh | 1 + script/void-kaiten-yaki.sh | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/script/lib.sh b/script/lib.sh index 895f331..c9c207e 100644 --- a/script/lib.sh +++ b/script/lib.sh @@ -158,6 +158,7 @@ function pre_install() { # Zap existing partition table echo "...Erasing partition table of \"${DEV}\"." dd if=/dev/zero of="${DEV}" bs=512 count=1 + if is_error ; then return 1 ; fi; # If error, terminate # Create MBR and allocate max storage for Linux partition echo "...Creating a Linux partition on ${DEV} with MBR." sfdisk "${DEV}" <<- HEREDOC diff --git a/script/void-kaiten-yaki.sh b/script/void-kaiten-yaki.sh index 6dd8da4..87cfcd4 100644 --- a/script/void-kaiten-yaki.sh +++ b/script/void-kaiten-yaki.sh @@ -56,8 +56,8 @@ function main() { # Common part of the pre-install stage if ! pre_install ; then # If error, restore the modification. - echo "...restoring modified /etc/default/grub." - sed -i -e "s#loglevel=4 ${GRUB_ADDITIONAL_PARAMETERS}#loglevel=4#" /etc/default/grub + echo "...restoring /etc/default/grub, if needed" + sed -i -e "s#${GRUB_ADDITIONAL_PARAMETERS}##" /etc/default/grub return 1 # with error status fi From e3e35995611120680650e998c8bba16e88ba77d3 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sun, 4 Jul 2021 22:00:55 +0900 Subject: [PATCH 11/48] Add error handling on lvcreate root --- script/lib.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/script/lib.sh b/script/lib.sh index c9c207e..82b0ffc 100644 --- a/script/lib.sh +++ b/script/lib.sh @@ -240,6 +240,7 @@ function pre_install() { else # not exist and not overwrite install echo "...Creating logical volume \"${LVROOTNAME}\" on \"${VGNAME}\"." lvcreate -l "${LVROOTSIZE}" -n "${LVROOTNAME}" "${VGNAME}" + if [ $? -ne 0 ] ; then deactivate_and_close; return 1 ; fi; fi fi From 98ad669b1338ea6c827489c2f7e39f9577270604 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sun, 4 Jul 2021 22:09:22 +0900 Subject: [PATCH 12/48] Update changelog Add the return status validation Issue #7 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 557e539..ec8b588 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ Record of the modification in project development. ### Changed - [Issue 5 : OVERWRITEINSTALL confirmation is missing](https://github.com/suikan4github/kaiten-yaki/issues/5) - [Issue 6 : Remove loglevel dependency from the void-kaiten-yaki.sh ](https://github.com/suikan4github/kaiten-yaki/6) +- [Issue 7 : Add the return status validation ](https://github.com/suikan4github/kaiten-yaki/7) ### Deprecated ### Removed From 3ce805c5cabfba3f09780d4f74ad721b41ba7cad Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Tue, 6 Jul 2021 07:41:34 +0900 Subject: [PATCH 13/48] Make chroot'ed job independent script file Issue #11 --- script/lib/common.sh | 408 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 408 insertions(+) create mode 100644 script/lib/common.sh diff --git a/script/lib/common.sh b/script/lib/common.sh new file mode 100644 index 0000000..cff0f92 --- /dev/null +++ b/script/lib/common.sh @@ -0,0 +1,408 @@ +#!/bin/bash -u +# ******************************************************************************* +# Confirmation and Passphrase setting +# ******************************************************************************* + +function confirmation(){ + + # Consistency check for the OVERWRITEINSTALL and ERASEALL + if [ "${ERASEALL}" -ne 0 ] && [ "${OVERWRITEINSTALL}" -ne 0 ] ; then + cat <<- HEREDOC + ***** ERROR : Confliction between ERASEALL and OVERWRITEINSTALL ***** + ...ERASEALL = ${ERASEALL} + ...OVERWRITEINSTALL = ${OVERWRITEINSTALL} + ...Check configuration in your config.sh + + ...Installation process terminated.. + HEREDOC + return 1 # with error status + fi + + # Sanity check for volume group name + if echo "${VGNAME}" | grep "-" -i > /dev/null ; then # "-" is found in the volume group name. + cat <<- HEREDOC + ***** ERROR : VGNAME is "${VGNAME}" ***** + ..."-" is not allowed in the volume name. + ...Check configuration in your config.sh + + ...Installation process terminated.. + HEREDOC + return 1 # with error status + fi # "-" is found in the volume group name. + + # Sanity check for root volume name + if echo "${LVROOTNAME}" | grep "-" -i > /dev/null ; then # "-" is found in the volume name. + cat <<- HEREDOC + ***** ERROR : LVROOTNAME is "${LVROOTNAME}" ***** + ..."-" is not allowed in the volume name. + ...Check configuration in your config.sh + + ...Installation process terminated.. + HEREDOC + return 1 # with error status + fi # "-" is found in the volume name. + + # Sanity check for swap volume name + if echo "${LVSWAPNAME}" | grep "-" -i > /dev/null ; then # "-" is found in the volume name. + cat <<- HEREDOC + ***** ERROR : LVSWAPNAME is "${LVSWAPNAME}" ***** + ..."-" is not allowed in the volume name. + ...Check configuration in your config.sh + + ...Installation process terminated.. + HEREDOC + return 1 # with error status + fi # "-" is found in the volume name. + + # For surre ask the your config.sh is edited + cat <<- HEREDOC + + The destination logical volume label is "${LVROOTNAME}" + "${LVROOTNAME}" uses ${LVROOTSIZE} of the LVM volume group. + Are you sure to install? [Y/N] + HEREDOC + read -r YESNO + if [ "${YESNO}" != "Y" ] && [ "${YESNO}" != "y" ] ; then + cat <<- HEREDOC + + ...Installation process terminated.. + HEREDOC + return 1 # with error status + fi # if YES + + # For sure ask to erase. + if [ "${ERASEALL}" -ne 0 ] ; then + echo "Are you sure you want to erase entire \"${DEV}\"? [Y/N]" + read -r YESNO + if [ "${YESNO}" != "Y" ] && [ "${YESNO}" != "y" ] ; then + cat <<-HEREDOC + ...Check your config.sh. The variable ERASEALL is ${ERASEALL}. + + ...Installation process terminated.. + HEREDOC + return 1 # with error status + fi # if YES + fi # if erase all + + # For sure ask to overwrite. + if [ "${OVERWRITEINSTALL}" -ne 0 ] ; then + echo "Are you sure you want to overwrite \"${LVROOTNAME}\" in \"${VGNAME}\"? [Y/N]" + read -r YESNO + if [ "${YESNO}" != "Y" ] && [ "${YESNO}" != "y" ] ; then + cat <<-HEREDOC + ...Check your config.sh. The variable OVERWRITEINSTALL is ${OVERWRITEINSTALL}. + + ...Installation process terminated.. + HEREDOC + return 1 # with error status + fi # if YES + fi # if overwrite + + # ----- Set Passphrase ----- + # Input passphrase + echo "" + echo "Type passphrase for the disk encryption." + read -sr PASSPHRASE + export PASSPHRASE + + echo "Type passphrase again, to confirm." + read -sr PASSPHRASE_C + + # Validate whether both are indentical or not + if [ "${PASSPHRASE}" != "${PASSPHRASE_C}" ] ; then + cat <<-HEREDOC + ***** ERROR : Passphrase doesn't match ***** + + ...Installation process terminated.. + HEREDOC + return 1 # with error status + fi # passphrase validation + + # succesfull return + return 0 +} + + +# ******************************************************************************* +# Common Pre-install stage +# ******************************************************************************* + +function pre_install() { + + + # ----- Erase entire disk, create partitions, format them and encrypt the LUKS partition ----- + if [ "${ERASEALL}" -ne 0 ] ; then + + # Assign specified space and rest of disk to the EFI and LUKS partition, respectively. + if [ "${ISEFI}" -ne 0 ] ; then # EFI + # Zap existing partition table and create new GPT + echo "...Initializing \"${DEV}\" with GPT." + sgdisk --zap-all "${DEV}" + if is_error ; then return 1 ; fi; # If error, terminate + # Create EFI partition and format it + echo "...Creating an EFI partition on \"${DEV}\"." + # shellcheck disable=SC2140 + sgdisk --new="${EFIPARTITION}":0:+"${EFISIZE}" --change-name="${EFIPARTITION}":"EFI System" --typecode="${EFIPARTITION}":ef00 "${DEV}" + if is_error ; then return 1 ; fi; # If error, terminate + echo "...Formatting the EFI parttion." + mkfs.vfat -F 32 -n EFI-SP "${DEV}${EFIPARTITION}" + if is_error ; then return 1 ; fi; # If error, terminate + # Create Linux partition + echo "...Creating a Linux partition on ${DEV}." + # shellcheck disable=SC2140 + sgdisk --new="${CRYPTPARTITION}":0:0 --change-name="${CRYPTPARTITION}":"Linux LUKS" --typecode="${CRYPTPARTITION}":8309 "${DEV}" + if is_error ; then return 1 ; fi; # If error, terminate + # Then print them + sgdisk --print "${DEV}" + else # BIOS + # Zap existing partition table + echo "...Erasing partition table of \"${DEV}\"." + dd if=/dev/zero of="${DEV}" bs=512 count=1 + if is_error ; then return 1 ; fi; # If error, terminate + # Create MBR and allocate max storage for Linux partition + echo "...Creating a Linux partition on ${DEV} with MBR." + sfdisk "${DEV}" <<- HEREDOC + 2M,,L + HEREDOC + if is_error ; then return 1 ; fi; # If error, terminate + fi # if EFI firmware + + # Encrypt the partition to install Linux + echo "...Initializing \"${DEV}${CRYPTPARTITION}\" as crypt partition" + printf %s "${PASSPHRASE}" | cryptsetup luksFormat --type=luks1 --key-file - --batch-mode "${DEV}${CRYPTPARTITION}" + + fi # if erase all + + # ----- Open the LUKS partition ----- + # Open the crypt partition. + echo "...Opening a crypt partition \"${DEV}${CRYPTPARTITION}\" as \"${CRYPTPARTNAME}\"" + printf %s "${PASSPHRASE}" | cryptsetup open -d - "${DEV}${CRYPTPARTITION}" "${CRYPTPARTNAME}" + + # Check whether successful open. If mapped, it is successful. + if [ ! -e /dev/mapper/"${CRYPTPARTNAME}" ] ; then + cat <<- HEREDOC + ***** ERROR : Cannot open LUKS volume "${CRYPTPARTNAME}" on "${DEV}${CRYPTPARTITION}". ***** + ...Check passphrase and your config.txt + + ...Installation process terminated.. + HEREDOC + return 1 # with error status + fi # if crypt volume is unable to open + + # ----- Configure the LVM in LUKS volume ----- + # Check volume group ${VGNAME} exist or not + if vgdisplay -s "${VGNAME}" &> /dev/null ; then # if exist + echo "...Volume group \"${VGNAME}\" already exist. Skipped to create. No problem." + echo "...Activating all logical volumes in volume group \"${VGNAME}\"." + vgchange -ay + echo "...Scanning all logical volumes." + lvscan + else + echo "...Initializing a physical volume on \"${CRYPTPARTNAME}\"" + pvcreate /dev/mapper/"${CRYPTPARTNAME}" + if [ $? -ne 0 ] ; then deactivate_and_close; return 1 ; fi; + echo "...And then creating Volume group \"${VGNAME}\"." + vgcreate "${VGNAME}" /dev/mapper/"${CRYPTPARTNAME}" + if [ $? -ne 0 ] ; then deactivate_and_close; return 1 ; fi; + fi # if /dev/volume-groupt exist + + # Create a SWAP Logical Volume on VG, if it doesn't exist + if [ -e /dev/mapper/"${VGNAME}"-"${LVSWAPNAME}" ] ; then + echo "...Swap volume already exist. Skipped to create. No problem." + else + echo "...Creating logical volume \"${LVSWAPNAME}\" on \"${VGNAME}\"." + lvcreate -L "${LVSWAPSIZE}" -n "${LVSWAPNAME}" "${VGNAME}" + if [ $? -ne 0 ] ; then deactivate_and_close; return 1 ; fi; + fi # if /dev/mapper/swap volume already exit. + + # Create a ROOT Logical Volume on VG. + if [ -e /dev/mapper/"${VGNAME}"-"${LVROOTNAME}" ] ; then # exist + if [ "${OVERWRITEINSTALL}" -ne 0 ] ; then # exist and overwrite install + echo "...Logical volume \"${VGNAME}-${LVROOTNAME}\" already exists. OK." + else # exist and not overwriteinstall + cat <<- HEREDOC + ***** ERROR : Logical volume "${VGNAME}-${LVROOTNAME}" already exists. ***** + ...Check LVROOTNAME environment variable in your config.txt. + HEREDOC + # Deactivate all lg and close the LUKS volume + deactivate_and_close + return 1 # with error status + fi + else # not exsit + if [ "${OVERWRITEINSTALL}" -ne 0 ] ; then + cat <<- HEREDOC + ***** ERROR : Logical volume "${VGNAME}-${LVROOTNAME}" doesn't exist while overwrite install. ***** + ...Check consistency of your config.txt. + HEREDOC + # Deactivate all lg and close the LUKS volume + deactivate_and_close + return 1 # with error status + else # not exist and not overwrite install + echo "...Creating logical volume \"${LVROOTNAME}\" on \"${VGNAME}\"." + lvcreate -l "${LVROOTSIZE}" -n "${LVROOTNAME}" "${VGNAME}" + if [ $? -ne 0 ] ; then deactivate_and_close; return 1 ; fi; + fi + fi + + + # successful return + return 0 +} + + +# ******************************************************************************* +# Common message in para-install stage +# ******************************************************************************* + +function para_install_msg() { + + cat <<- HEREDOC + ****************************************************************************** + The pre-install process is done. We are ready to install the Linux to the + target storage device. By pressing return key, GUI/TUI installer starts. + + Please pay attention to the partition/logical volume mapping configuration. + In this installation, you have to map the previously created partitions/logical + volumes to the appropriate directories of the target system as followings : + + HEREDOC + + # In the EFI system, add this mapping + if [ "${ISEFI}" -ne 0 ] ; then + echo "/boot/efi : ${DEV}${EFIPARTITION}" + fi + + # Root volume mapping + echo "/ : /dev/mapper/${VGNAME}-${LVROOTNAME}" + + # In case of erased storage, add this mapping + if [ "${ERASEALL}" -ne 0 ] ; then + echo "swap : /dev/mapper/${VGNAME}-${LVSWAPNAME}" + fi + + return 0 +} + + +# ******************************************************************************* +# Common post-install stage +# ******************************************************************************* +# In side this script, the chrooted job is parameterrized as by evn variable TARGETCHROOTEDJOB +function post_install_local() { + ## Mount the target file system + # ${TARGETMOUNTPOINT} is created by the GUI/TUI installer + echo "...Mounting /dev/mapper/${VGNAME}-${LVROOTNAME} on ${TARGETMOUNTPOINT}." + mount /dev/mapper/"${VGNAME}"-"${LVROOTNAME}" "${TARGETMOUNTPOINT}" + + # And mount other directories + echo "...Mounting all other dirs." + for n in proc sys dev tmp etc/resolv.conf; do mount --rbind "/$n" "${TARGETMOUNTPOINT}/$n"; done + + # Copy all scripts to the target /tmp + echo "...Copy files in current dir to ${TARGETMOUNTPOINT}/tmp." + mkdir "${TARGETMOUNTPOINT}/tmp/kaiten-yaki" + cp -R ./*.sh "${TARGETMOUNTPOINT}/tmp/kaiten-yaki" + + # Change root and create the keyfile and ramfs image for Linux kernel. + # The here document is script executed under chroot. And here we call + # the distribution dependent script "lib/chrooted_job_${DISTRIBUTIONSIGNATURE}.sh". + echo "...Chroot to ${TARGETMOUNTPOINT}." + # shellcheck disable=SC2086 + cat <<- HEREDOC | chroot "${TARGETMOUNTPOINT}" /bin/bash + cd /tmp/kaiten-yaki + # Execute copied script + source "lib/chrooted_job_${DISTRIBUTIONSIGNATURE}.sh" + HEREDOC + + # Unmount all + echo "...Unmounting all." + umount -R "${TARGETMOUNTPOINT}" + + # Finishing message + cat <<- HEREDOC + ****************** Post-install process finished ****************** + + ...Ready to reboot. + HEREDOC + + return 0 + +} # End of post_install_local() + + +# ******************************************************************************* +# Deactivate all LV in the VG and close LUKS volume +# ******************************************************************************* + +function deactivate_and_close(){ + echo "...Deactivating all logical volumes in volume group \"${VGNAME}\"." + vgchange -a n "${VGNAME}" + echo "...Closing LUKS volume \"${CRYPTPARTNAME}\"." + cryptsetup close "${CRYPTPARTNAME}" + cat <<- HEREDOC + + ...Installation process terminated.. + HEREDOC + +} + +# ******************************************************************************* +# Delete the nwe volume if overwrite install, and close all +# ******************************************************************************* +function on_unexpected_installer_quit(){ + echo "***** ERROR : The GUI/TUI installer terminated unexpectedly. *****" + if [ "${OVERWRITEINSTALL}" -ne 0 ] ; then # If overwrite install, keep the volume + echo "...Keep logical volume \"${VGNAME}-${LVROOTNAME}\" untouched." + else # if not overwrite istall, delete the new volume + echo "...Deleting the new logical volume \"${VGNAME}-${LVROOTNAME}\"." + lvremove -f /dev/mapper/"${VGNAME}"-"${LVROOTNAME}" + fi + # Deactivate all lg and close the LUKS volume + deactivate_and_close + echo "...You can retry Kaiten-yaki again." +} + + +# ******************************************************************************* +# Check whether given signaure is in the system information +# ******************************************************************************* +function distribution_check(){ + if ! uname -a | grep "${DISTRIBUTIONSIGNATURE}" -i > /dev/null ; then # Signature is not found in the OS name. + echo "*******************************************************************************" + uname -a + cat <<- HEREDOC + ******************************************************************************* + This system seems to be not $DISTRIBUTIONNAME, while this script is dediated to the $DISTRIBUTIONNAME. + Are you sure you want to run this script? [Y/N] + HEREDOC + read -r YESNO + if [ "${YESNO}" != "Y" ] && [ "${YESNO}" != "y" ] ; then + cat <<- HEREDOC + + ...Installation process terminated.. + HEREDOC + return 1 # with error status + fi # if YES + + fi # Distribution check + + # no error + return 0 +} + + +# ******************************************************************************* +# Error report and return revsers status. +# ******************************************************************************* +function is_error() { + if [ $? -eq 0 ] ; then # Is previous job OK? + return 1 # If OK, return error ( because it was not error ) + else + cat <<- HEREDOC + **** ERROR ! **** + + Installation process terminated. + HEREDOC + return 0 # If error, return OK ( because it was error ) + fi; +} \ No newline at end of file From 7b91fbd9f4bf38bf2dadc54bd23ad8b4e922bb9c Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Tue, 6 Jul 2021 07:41:56 +0900 Subject: [PATCH 14/48] Additional changes --- script/lib.sh | 361 ------------------------------ script/lib/chrooted_job_ubuntu.sh | 44 ++++ script/lib/chrooted_job_void.sh | 45 ++++ script/ubuntu-kaiten-yaki.sh | 72 +----- script/void-kaiten-yaki.sh | 71 +----- 5 files changed, 96 insertions(+), 497 deletions(-) delete mode 100644 script/lib.sh create mode 100644 script/lib/chrooted_job_ubuntu.sh create mode 100644 script/lib/chrooted_job_void.sh diff --git a/script/lib.sh b/script/lib.sh deleted file mode 100644 index 82b0ffc..0000000 --- a/script/lib.sh +++ /dev/null @@ -1,361 +0,0 @@ -#!/bin/bash -u -# ******************************************************************************* -# Confirmation and Passphrase setting -# ******************************************************************************* - -function confirmation(){ - - # Consistency check for the OVERWRITEINSTALL and ERASEALL - if [ "${ERASEALL}" -ne 0 ] && [ "${OVERWRITEINSTALL}" -ne 0 ] ; then - cat <<- HEREDOC - ***** ERROR : Confliction between ERASEALL and OVERWRITEINSTALL ***** - ...ERASEALL = ${ERASEALL} - ...OVERWRITEINSTALL = ${OVERWRITEINSTALL} - ...Check configuration in your config.sh - - ...Installation process terminated.. - HEREDOC - return 1 # with error status - fi - - # Sanity check for volume group name - if echo "${VGNAME}" | grep "-" -i > /dev/null ; then # "-" is found in the volume group name. - cat <<- HEREDOC - ***** ERROR : VGNAME is "${VGNAME}" ***** - ..."-" is not allowed in the volume name. - ...Check configuration in your config.sh - - ...Installation process terminated.. - HEREDOC - return 1 # with error status - fi # "-" is found in the volume group name. - - # Sanity check for root volume name - if echo "${LVROOTNAME}" | grep "-" -i > /dev/null ; then # "-" is found in the volume name. - cat <<- HEREDOC - ***** ERROR : LVROOTNAME is "${LVROOTNAME}" ***** - ..."-" is not allowed in the volume name. - ...Check configuration in your config.sh - - ...Installation process terminated.. - HEREDOC - return 1 # with error status - fi # "-" is found in the volume name. - - # Sanity check for swap volume name - if echo "${LVSWAPNAME}" | grep "-" -i > /dev/null ; then # "-" is found in the volume name. - cat <<- HEREDOC - ***** ERROR : LVSWAPNAME is "${LVSWAPNAME}" ***** - ..."-" is not allowed in the volume name. - ...Check configuration in your config.sh - - ...Installation process terminated.. - HEREDOC - return 1 # with error status - fi # "-" is found in the volume name. - - # For surre ask the your config.sh is edited - cat <<- HEREDOC - - The destination logical volume label is "${LVROOTNAME}" - "${LVROOTNAME}" uses ${LVROOTSIZE} of the LVM volume group. - Are you sure to install? [Y/N] - HEREDOC - read -r YESNO - if [ "${YESNO}" != "Y" ] && [ "${YESNO}" != "y" ] ; then - cat <<- HEREDOC - - ...Installation process terminated.. - HEREDOC - return 1 # with error status - fi # if YES - - # For sure ask to erase. - if [ "${ERASEALL}" -ne 0 ] ; then - echo "Are you sure you want to erase entire \"${DEV}\"? [Y/N]" - read -r YESNO - if [ "${YESNO}" != "Y" ] && [ "${YESNO}" != "y" ] ; then - cat <<-HEREDOC - ...Check your config.sh. The variable ERASEALL is ${ERASEALL}. - - ...Installation process terminated.. - HEREDOC - return 1 # with error status - fi # if YES - fi # if erase all - - # For sure ask to overwrite. - if [ "${OVERWRITEINSTALL}" -ne 0 ] ; then - echo "Are you sure you want to overwrite \"${LVROOTNAME}\" in \"${VGNAME}\"? [Y/N]" - read -r YESNO - if [ "${YESNO}" != "Y" ] && [ "${YESNO}" != "y" ] ; then - cat <<-HEREDOC - ...Check your config.sh. The variable OVERWRITEINSTALL is ${OVERWRITEINSTALL}. - - ...Installation process terminated.. - HEREDOC - return 1 # with error status - fi # if YES - fi # if overwrite - - # ----- Set Passphrase ----- - # Input passphrase - echo "" - echo "Type passphrase for the disk encryption." - read -sr PASSPHRASE - export PASSPHRASE - - echo "Type passphrase again, to confirm." - read -sr PASSPHRASE_C - - # Validate whether both are indentical or not - if [ "${PASSPHRASE}" != "${PASSPHRASE_C}" ] ; then - cat <<-HEREDOC - ***** ERROR : Passphrase doesn't match ***** - - ...Installation process terminated.. - HEREDOC - return 1 # with error status - fi # passphrase validation - - # succesfull return - return 0 -} - - -# ******************************************************************************* -# Pre-install stage -# ******************************************************************************* - -function pre_install() { - - - # ----- Erase entire disk, create partitions, format them and encrypt the LUKS partition ----- - if [ "${ERASEALL}" -ne 0 ] ; then - - # Assign specified space and rest of disk to the EFI and LUKS partition, respectively. - if [ "${ISEFI}" -ne 0 ] ; then # EFI - # Zap existing partition table and create new GPT - echo "...Initializing \"${DEV}\" with GPT." - sgdisk --zap-all "${DEV}" - if is_error ; then return 1 ; fi; # If error, terminate - # Create EFI partition and format it - echo "...Creating an EFI partition on \"${DEV}\"." - # shellcheck disable=SC2140 - sgdisk --new="${EFIPARTITION}":0:+"${EFISIZE}" --change-name="${EFIPARTITION}":"EFI System" --typecode="${EFIPARTITION}":ef00 "${DEV}" - if is_error ; then return 1 ; fi; # If error, terminate - echo "...Formatting the EFI parttion." - mkfs.vfat -F 32 -n EFI-SP "${DEV}${EFIPARTITION}" - if is_error ; then return 1 ; fi; # If error, terminate - # Create Linux partition - echo "...Creating a Linux partition on ${DEV}." - # shellcheck disable=SC2140 - sgdisk --new="${CRYPTPARTITION}":0:0 --change-name="${CRYPTPARTITION}":"Linux LUKS" --typecode="${CRYPTPARTITION}":8309 "${DEV}" - if is_error ; then return 1 ; fi; # If error, terminate - # Then print them - sgdisk --print "${DEV}" - else # BIOS - # Zap existing partition table - echo "...Erasing partition table of \"${DEV}\"." - dd if=/dev/zero of="${DEV}" bs=512 count=1 - if is_error ; then return 1 ; fi; # If error, terminate - # Create MBR and allocate max storage for Linux partition - echo "...Creating a Linux partition on ${DEV} with MBR." - sfdisk "${DEV}" <<- HEREDOC - 2M,,L - HEREDOC - if is_error ; then return 1 ; fi; # If error, terminate - fi # if EFI firmware - - # Encrypt the partition to install Linux - echo "...Initializing \"${DEV}${CRYPTPARTITION}\" as crypt partition" - printf %s "${PASSPHRASE}" | cryptsetup luksFormat --type=luks1 --key-file - --batch-mode "${DEV}${CRYPTPARTITION}" - - fi # if erase all - - # ----- Open the LUKS partition ----- - # Open the crypt partition. - echo "...Opening a crypt partition \"${DEV}${CRYPTPARTITION}\" as \"${CRYPTPARTNAME}\"" - printf %s "${PASSPHRASE}" | cryptsetup open -d - "${DEV}${CRYPTPARTITION}" "${CRYPTPARTNAME}" - - # Check whether successful open. If mapped, it is successful. - if [ ! -e /dev/mapper/"${CRYPTPARTNAME}" ] ; then - cat <<- HEREDOC - ***** ERROR : Cannot open LUKS volume "${CRYPTPARTNAME}" on "${DEV}${CRYPTPARTITION}". ***** - ...Check passphrase and your config.txt - - ...Installation process terminated.. - HEREDOC - return 1 # with error status - fi # if crypt volume is unable to open - - # ----- Configure the LVM in LUKS volume ----- - # Check volume group ${VGNAME} exist or not - if vgdisplay -s "${VGNAME}" &> /dev/null ; then # if exist - echo "...Volume group \"${VGNAME}\" already exist. Skipped to create. No problem." - echo "...Activating all logical volumes in volume group \"${VGNAME}\"." - vgchange -ay - echo "...Scanning all logical volumes." - lvscan - else - echo "...Initializing a physical volume on \"${CRYPTPARTNAME}\"" - pvcreate /dev/mapper/"${CRYPTPARTNAME}" - if [ $? -ne 0 ] ; then deactivate_and_close; return 1 ; fi; - echo "...And then creating Volume group \"${VGNAME}\"." - vgcreate "${VGNAME}" /dev/mapper/"${CRYPTPARTNAME}" - if [ $? -ne 0 ] ; then deactivate_and_close; return 1 ; fi; - fi # if /dev/volume-groupt exist - - # Create a SWAP Logical Volume on VG, if it doesn't exist - if [ -e /dev/mapper/"${VGNAME}"-"${LVSWAPNAME}" ] ; then - echo "...Swap volume already exist. Skipped to create. No problem." - else - echo "...Creating logical volume \"${LVSWAPNAME}\" on \"${VGNAME}\"." - lvcreate -L "${LVSWAPSIZE}" -n "${LVSWAPNAME}" "${VGNAME}" - if [ $? -ne 0 ] ; then deactivate_and_close; return 1 ; fi; - fi # if /dev/mapper/swap volume already exit. - - # Create a ROOT Logical Volume on VG. - if [ -e /dev/mapper/"${VGNAME}"-"${LVROOTNAME}" ] ; then # exist - if [ "${OVERWRITEINSTALL}" -ne 0 ] ; then # exist and overwrite install - echo "...Logical volume \"${VGNAME}-${LVROOTNAME}\" already exists. OK." - else # exist and not overwriteinstall - cat <<- HEREDOC - ***** ERROR : Logical volume "${VGNAME}-${LVROOTNAME}" already exists. ***** - ...Check LVROOTNAME environment variable in your config.txt. - HEREDOC - # Deactivate all lg and close the LUKS volume - deactivate_and_close - return 1 # with error status - fi - else # not exsit - if [ "${OVERWRITEINSTALL}" -ne 0 ] ; then - cat <<- HEREDOC - ***** ERROR : Logical volume "${VGNAME}-${LVROOTNAME}" doesn't exist while overwrite install. ***** - ...Check consistency of your config.txt. - HEREDOC - # Deactivate all lg and close the LUKS volume - deactivate_and_close - return 1 # with error status - else # not exist and not overwrite install - echo "...Creating logical volume \"${LVROOTNAME}\" on \"${VGNAME}\"." - lvcreate -l "${LVROOTSIZE}" -n "${LVROOTNAME}" "${VGNAME}" - if [ $? -ne 0 ] ; then deactivate_and_close; return 1 ; fi; - fi - fi - - - # successful return - return 0 -} - - -# ******************************************************************************* -# Common message in para-install stage -# ******************************************************************************* - -function para_install_msg() { - - cat <<- HEREDOC - ****************************************************************************** - The pre-install process is done. We are ready to install the Linux to the - target storage device. By pressing return key, GUI/TUI installer starts. - - Please pay attention to the partition/logical volume mapping configuration. - In this installation, you have to map the previously created partitions/logical - volumes to the appropriate directories of the target system as followings : - - HEREDOC - - # In the EFI system, add this mapping - if [ "${ISEFI}" -ne 0 ] ; then - echo "/boot/efi : ${DEV}${EFIPARTITION}" - fi - - # Root volume mapping - echo "/ : /dev/mapper/${VGNAME}-${LVROOTNAME}" - - # In case of erased storage, add this mapping - if [ "${ERASEALL}" -ne 0 ] ; then - echo "swap : /dev/mapper/${VGNAME}-${LVSWAPNAME}" - fi - - return 0 -} - -# ******************************************************************************* -# Deactivate all LV in the VG and close LUKS volume -# ******************************************************************************* - -function deactivate_and_close(){ - echo "...Deactivating all logical volumes in volume group \"${VGNAME}\"." - vgchange -a n "${VGNAME}" - echo "...Closing LUKS volume \"${CRYPTPARTNAME}\"." - cryptsetup close "${CRYPTPARTNAME}" - cat <<- HEREDOC - - ...Installation process terminated.. - HEREDOC - -} - -# ******************************************************************************* -# Delete the nwe volume if overwrite install, and close all -# ******************************************************************************* -function on_unexpected_installer_quit(){ - echo "***** ERROR : The GUI/TUI installer terminated unexpectedly. *****" - if [ "${OVERWRITEINSTALL}" -ne 0 ] ; then # If overwrite install, keep the volume - echo "...Keep logical volume \"${VGNAME}-${LVROOTNAME}\" untouched." - else # if not overwrite istall, delete the new volume - echo "...Deleting the new logical volume \"${VGNAME}-${LVROOTNAME}\"." - lvremove -f /dev/mapper/"${VGNAME}"-"${LVROOTNAME}" - fi - # Deactivate all lg and close the LUKS volume - deactivate_and_close - echo "...You can retry Kaiten-yaki again." -} - - -# ******************************************************************************* -# Check whether given signaure is in the system information -# ******************************************************************************* -function distribution_check(){ - if ! uname -a | grep "${DISTRIBUTIONSIGNATURE}" -i > /dev/null ; then # Signature is not found in the OS name. - echo "*******************************************************************************" - uname -a - cat <<- HEREDOC - ******************************************************************************* - This system seems to be not $DISTRIBUTIONNAME, while this script is dediated to the $DISTRIBUTIONNAME. - Are you sure you want to run this script? [Y/N] - HEREDOC - read -r YESNO - if [ "${YESNO}" != "Y" ] && [ "${YESNO}" != "y" ] ; then - cat <<- HEREDOC - - ...Installation process terminated.. - HEREDOC - return 1 # with error status - fi # if YES - - fi # Distribution check - - # no error - return 0 -} - - -# ******************************************************************************* -# Error report and return revsers status. -# ******************************************************************************* -function is_error() { - if [ $? -eq 0 ] ; then # Is previous job OK? - return 1 # If OK, return error ( because it was not error ) - else - cat <<- HEREDOC - **** ERROR ! **** - - Installation process terminated. - HEREDOC - return 0 # If error, return OK ( because it was error ) - fi; -} \ No newline at end of file diff --git a/script/lib/chrooted_job_ubuntu.sh b/script/lib/chrooted_job_ubuntu.sh new file mode 100644 index 0000000..ed16912 --- /dev/null +++ b/script/lib/chrooted_job_ubuntu.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +# Include configuration. This sript file have to be executed at Kaiten-yaki/script dir +# shellcheck disable=SC1091 +source config.sh + +# Create a key file for LUKS and register it as contents of the initramfs image +function chrooted_job() { + # Mount the rest of partitions by target /etc/fstab + mount -a + + # Set up the kernel hook of encryption + echo "...Installing cryptsetup-initramfs package." + apt -qq install -y cryptsetup-initramfs + + # Prepare a key file to embed in to the ramfs. + echo "...Prepairing key file." + mkdir /etc/luks + dd if=/dev/urandom of=/etc/luks/boot_os.keyfile bs=4096 count=1 status=none + chmod u=rx,go-rwx /etc/luks + chmod u=r,go-rwx /etc/luks/boot_os.keyfile + + # Add a key to the key file. Use the passphrase in the environment variable. + echo "...Adding a key to the key file." + printf %s "${PASSPHRASE}" | cryptsetup luksAddKey -d - "${DEV}${CRYPTPARTITION}" /etc/luks/boot_os.keyfile + + # Add the LUKS volume information to /etc/crypttab to decrypt by kernel. + echo "...Adding LUKS volume info to /etc/crypttab." + echo "${CRYPTPARTNAME} UUID=$(blkid -s UUID -o value ${DEV}${CRYPTPARTITION}) /etc/luks/boot_os.keyfile luks,discard" >> /etc/crypttab + + # Putting key file into the ramfs initial image + echo "...Registering key file to the ramfs" + echo "KEYFILE_PATTERN=/etc/luks/*.keyfile" >> /etc/cryptsetup-initramfs/conf-hook + echo "UMASK=0077" >> /etc/initramfs-tools/initramfs.conf + + # Finally, update the ramfs initial image with the key file. + echo "...Upadting initramfs." + update-initramfs -uk all + + # Leave chroot +} + +# Execute job +chrooted_job diff --git a/script/lib/chrooted_job_void.sh b/script/lib/chrooted_job_void.sh new file mode 100644 index 0000000..ee58369 --- /dev/null +++ b/script/lib/chrooted_job_void.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +# Include configuration. This sript file have to be executed at Kaiten-yaki/script dir +# shellcheck disable=SC1091 +source config.sh + +# Create a key file for LUKS and register it as contents of the initramfs image +function chrooted_job() { + # Mount the rest of partitions by target /etc/fstab + mount -a + + # Set up the kernel hook of encryption + echo "...Installing cryptsetup-initramfs package." + xbps-install -y lvm2 cryptsetup + + # Prepare a key file to embed in to the ramfs. + echo "...Prepairing key file." + mkdir /etc/luks + dd if=/dev/urandom of=/etc/luks/boot_os.keyfile bs=4096 count=1 status=none + chmod u=rx,go-rwx /etc/luks + chmod u=r,go-rwx /etc/luks/boot_os.keyfile + + # Add a key to the key file. Use the passphrase in the environment variable. + echo "...Adding a key to the key file." + printf %s "${PASSPHRASE}" | cryptsetup luksAddKey -d - "${DEV}${CRYPTPARTITION}" /etc/luks/boot_os.keyfile + + # Add the LUKS volume information to /etc/crypttab to decrypt by kernel. + echo "...Adding LUKS volume info to /etc/crypttab." + echo "${CRYPTPARTNAME} UUID=$(blkid -s UUID -o value ${DEV}${CRYPTPARTITION}) /etc/luks/boot_os.keyfile luks,discard" >> /etc/crypttab + + # Putting key file into the ramfs initial image + echo "...Registering key file to the ramfs" + echo 'install_items+=" /etc/luks/boot_os.keyfile /etc/crypttab " ' > /etc/dracut.conf.d/10-crypt.conf + + # Finally, update the ramfs initial image with the key file. + echo "...Upadting initramfs." + xbps-reconfigure -fa + echo "...grub-mkconfig." + grub-mkconfig -o /boot/grub/grub.cfg + + # Leave chroot +} + +# Execute job +chrooted_job diff --git a/script/ubuntu-kaiten-yaki.sh b/script/ubuntu-kaiten-yaki.sh index a18aa8f..96ace9b 100644 --- a/script/ubuntu-kaiten-yaki.sh +++ b/script/ubuntu-kaiten-yaki.sh @@ -5,14 +5,13 @@ source ./config.sh # Load common functions - source ./lib.sh + source ./lib/common.sh function main() { # This is the mount point of the install target. export TARGETMOUNTPOINT="/target" - # ******************************************************************************* # Confirmation before installation # ******************************************************************************* @@ -54,8 +53,9 @@ function main() { # Post-install stage # ******************************************************************************* - # Distribution dependent finalizing. Embedd encryption key into the ramfs image. - post_install_local + # Distribution dependent finalizing. Embedd encryption key into the ramfs image. + # The script is parameterized by env-variable to fit to the distribution + post_install # Normal end return 0 @@ -100,70 +100,6 @@ function para_install_local() { return 0 } -# ******************************************************************************* -# Ubuntu dependent post-installation process -function post_install_local() { - ## Mount the target file system - # ${TARGETMOUNTPOINT} is created by the GUI/TUI installer - echo "...Mounting /dev/mapper/${VGNAME}-${LVROOTNAME} on ${TARGETMOUNTPOINT}." - mount /dev/mapper/"${VGNAME}"-"${LVROOTNAME}" ${TARGETMOUNTPOINT} - - # And mount other directories - echo "...Mounting all other dirs." - for n in proc sys dev etc/resolv.conf; do mount --rbind "/$n" "${TARGETMOUNTPOINT}/$n"; done - - # Change root and create the keyfile and ramfs image for Linux kernel. - echo "...Chroot to ${TARGETMOUNTPOINT}." - # shellcheck disable=SC2086 - cat <<- HEREDOC | chroot ${TARGETMOUNTPOINT} /bin/bash - # Mount the rest of partitions by target /etc/fstab - mount -a - - # Set up the kernel hook of encryption - echo "...Installing cryptsetup-initramfs package." - apt -qq install -y cryptsetup-initramfs - - # Prepare a key file to embed in to the ramfs. - echo "...Prepairing key file." - mkdir /etc/luks - dd if=/dev/urandom of=/etc/luks/boot_os.keyfile bs=4096 count=1 status=none - chmod u=rx,go-rwx /etc/luks - chmod u=r,go-rwx /etc/luks/boot_os.keyfile - - # Add a key to the key file. Use the passphrase in the environment variable. - echo "...Adding a key to the key file." - printf %s "${PASSPHRASE}" | cryptsetup luksAddKey -d - "${DEV}${CRYPTPARTITION}" /etc/luks/boot_os.keyfile - - # Add the LUKS volume information to /etc/crypttab to decrypt by kernel. - echo "...Adding LUKS volume info to /etc/crypttab." - echo "${CRYPTPARTNAME} UUID=$(blkid -s UUID -o value ${DEV}${CRYPTPARTITION}) /etc/luks/boot_os.keyfile luks,discard" >> /etc/crypttab - - # Putting key file into the ramfs initial image - echo "...Registering key file to the ramfs" - echo "KEYFILE_PATTERN=/etc/luks/*.keyfile" >> /etc/cryptsetup-initramfs/conf-hook - echo "UMASK=0077" >> /etc/initramfs-tools/initramfs.conf - - # Finally, update the ramfs initial image with the key file. - echo "...Upadting initramfs." - update-initramfs -uk all - - # Leave chroot - HEREDOC - - # Unmount all - echo "...Unmounting all." - umount -R ${TARGETMOUNTPOINT} - - # Finishing message - cat <<- HEREDOC - ****************** Post-install process finished ****************** - - ...Ready to reboot. - HEREDOC - - return 0 - -} # End of post_install_local() # ******************************************************************************* diff --git a/script/void-kaiten-yaki.sh b/script/void-kaiten-yaki.sh index 87cfcd4..5838747 100644 --- a/script/void-kaiten-yaki.sh +++ b/script/void-kaiten-yaki.sh @@ -5,14 +5,13 @@ source ./config.sh # Load common functions - source ./lib.sh + source ./lib/common.sh function main() { # This is the mount point of the install target. export TARGETMOUNTPOINT="/mnt/target" - # ******************************************************************************* # Confirmation before installation # ******************************************************************************* @@ -76,7 +75,8 @@ function main() { # ******************************************************************************* # Distribution dependent finalizing. Embedd encryption key into the ramfs image. - post_install_local + # The script is parameterized by env-variable to fit to the distribution + post_install # Normal end return 0 @@ -128,71 +128,6 @@ function para_install_local() { return 0 } -# ******************************************************************************* -# Void Linux dependent post-installation process -function post_install_local() { - ## Mount the target file system - # ${TARGETMOUNTPOINT} is created by the GUI/TUI installer - echo "...Mounting /dev/mapper/${VGNAME}-${LVROOTNAME} on ${TARGETMOUNTPOINT}." - mount /dev/mapper/"${VGNAME}"-"${LVROOTNAME}" ${TARGETMOUNTPOINT} - - # And mount other directories - echo "...Mounting all other dirs." - for n in proc sys dev etc/resolv.conf; do mount --rbind "/$n" "${TARGETMOUNTPOINT}/$n"; done - - # Change root and create the keyfile and ramfs image for Linux kernel. - echo "...Chroot to ${TARGETMOUNTPOINT}." - # shellcheck disable=SC2086 - cat <<- HEREDOC | chroot ${TARGETMOUNTPOINT} /bin/bash - # Mount the rest of partitions by target /etc/fstab - mount -a - - # Set up the kernel hook of encryption - echo "...Installing cryptsetup-initramfs package." - xbps-install -y lvm2 cryptsetup - - # Prepare a key file to embed in to the ramfs. - echo "...Prepairing key file." - mkdir /etc/luks - dd if=/dev/urandom of=/etc/luks/boot_os.keyfile bs=4096 count=1 status=none - chmod u=rx,go-rwx /etc/luks - chmod u=r,go-rwx /etc/luks/boot_os.keyfile - - # Add a key to the key file. Use the passphrase in the environment variable. - echo "...Adding a key to the key file." - printf %s "${PASSPHRASE}" | cryptsetup luksAddKey -d - "${DEV}${CRYPTPARTITION}" /etc/luks/boot_os.keyfile - - # Add the LUKS volume information to /etc/crypttab to decrypt by kernel. - echo "...Adding LUKS volume info to /etc/crypttab." - echo "${CRYPTPARTNAME} UUID=$(blkid -s UUID -o value ${DEV}${CRYPTPARTITION}) /etc/luks/boot_os.keyfile luks,discard" >> /etc/crypttab - - # Putting key file into the ramfs initial image - echo "...Registering key file to the ramfs" - echo 'install_items+=" /etc/luks/boot_os.keyfile /etc/crypttab " ' > /etc/dracut.conf.d/10-crypt.conf - - # Finally, update the ramfs initial image with the key file. - echo "...Upadting initramfs." - xbps-reconfigure -fa - echo "...grub-mkconfig." - grub-mkconfig -o /boot/grub/grub.cfg - - # Leave chroot - HEREDOC - - # Unmount all - echo "...Unmounting all." - umount -R ${TARGETMOUNTPOINT} - - # Finishing message - cat <<- HEREDOC - ****************** Post-install process finished ****************** - - ...Ready to reboot. - HEREDOC - - return 0 - -} # End of post_install_local() # ******************************************************************************* From d0200d88d80d4f1a2fc093265dc0bfad6c6387af Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Tue, 6 Jul 2021 08:06:15 +0900 Subject: [PATCH 15/48] Fix the name of funciton --- script/lib/common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/lib/common.sh b/script/lib/common.sh index cff0f92..00ca95e 100644 --- a/script/lib/common.sh +++ b/script/lib/common.sh @@ -288,7 +288,7 @@ function para_install_msg() { # Common post-install stage # ******************************************************************************* # In side this script, the chrooted job is parameterrized as by evn variable TARGETCHROOTEDJOB -function post_install_local() { +function post_install() { ## Mount the target file system # ${TARGETMOUNTPOINT} is created by the GUI/TUI installer echo "...Mounting /dev/mapper/${VGNAME}-${LVROOTNAME} on ${TARGETMOUNTPOINT}." From fd8e8f0af191f2cc21839fcdcedaf78c57fca001 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Tue, 6 Jul 2021 08:22:16 +0900 Subject: [PATCH 16/48] Fix the mistake of the copy pattern Now, even directiries are copied --- script/lib/common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/lib/common.sh b/script/lib/common.sh index 00ca95e..11c3fbd 100644 --- a/script/lib/common.sh +++ b/script/lib/common.sh @@ -301,7 +301,7 @@ function post_install() { # Copy all scripts to the target /tmp echo "...Copy files in current dir to ${TARGETMOUNTPOINT}/tmp." mkdir "${TARGETMOUNTPOINT}/tmp/kaiten-yaki" - cp -R ./*.sh "${TARGETMOUNTPOINT}/tmp/kaiten-yaki" + cp -r ./* -t "${TARGETMOUNTPOINT}/tmp/kaiten-yaki" # Change root and create the keyfile and ramfs image for Linux kernel. # The here document is script executed under chroot. And here we call From 5930627ee7d546c6cc181295763e934305cc65f5 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Tue, 6 Jul 2021 21:22:43 +0900 Subject: [PATCH 17/48] Add explanation moving to script directory --- INSTALL.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 5954a89..bdc6685 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -32,8 +32,11 @@ xbps-install -Su xbps nano ``` The nano is an editor package to configure the config.txt. The choice of editor is up to you. Kaiten-yaki script doesn't have a dependency on nano editor. -Then, edit the config.txt. - +And then, go to the kaiten-yaki/script directory. +```bash +cd /the/downloaded/directory/kaiten-yaki/script +``` +Now, ready to configure. ## Configuration parameters This is a very critical part of the installation. The configuration parameters are in the config.sh. Edit these parameters before the installation. From 6a1df4f25b7f178ab8a04af0a079e959470380f3 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Wed, 7 Jul 2021 13:04:39 +0900 Subject: [PATCH 18/48] Update change log. Make chroot'ed job independent script file #11 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ec8b588..221ac3f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ Record of the modification in project development. - [Issue 5 : OVERWRITEINSTALL confirmation is missing](https://github.com/suikan4github/kaiten-yaki/issues/5) - [Issue 6 : Remove loglevel dependency from the void-kaiten-yaki.sh ](https://github.com/suikan4github/kaiten-yaki/6) - [Issue 7 : Add the return status validation ](https://github.com/suikan4github/kaiten-yaki/7) +- [Issue 11 : Make chroot'ed job independent script file ](https://github.com/suikan4github/kaiten-yaki/11) ### Deprecated ### Removed From f2d4c8fee3941315e31bd5f938bea7cc2835c4c3 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Wed, 7 Jul 2021 13:08:55 +0900 Subject: [PATCH 19/48] change ERASEALL=0 as default Issue #12 --- CHANGELOG.md | 1 + script/config.sh | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 221ac3f..4633848 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ Record of the modification in project development. - [Issue 6 : Remove loglevel dependency from the void-kaiten-yaki.sh ](https://github.com/suikan4github/kaiten-yaki/6) - [Issue 7 : Add the return status validation ](https://github.com/suikan4github/kaiten-yaki/7) - [Issue 11 : Make chroot'ed job independent script file ](https://github.com/suikan4github/kaiten-yaki/11) +- [Issue 12 : change ERASEALL=0 as default ](https://github.com/suikan4github/kaiten-yaki/12) ### Deprecated ### Removed diff --git a/script/config.sh b/script/config.sh index 6f0f32f..70e20ee 100644 --- a/script/config.sh +++ b/script/config.sh @@ -8,7 +8,7 @@ export DEV="/dev/sda" # Whether you want to erase all contents of the storage device or not. # 1 : Yes, I want to erase all. # 0 : No, I don't. I want to add to the existing LUKS volume. -export ERASEALL=1 +export ERASEALL=0 # Logical Volume name for your Linux installation. Keep it unique from other distribution. export LVROOTNAME="anko" From ae1a48f8f5e8e05985bf1bf37080e788cae06cef Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Wed, 7 Jul 2021 13:33:10 +0900 Subject: [PATCH 20/48] Add ITERTIME parameter Add ITERTIME configuration parameter to config.txt Issue #13 --- script/config.sh | 5 +++++ script/lib/common.sh | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/script/config.sh b/script/config.sh index 70e20ee..6f32dfe 100644 --- a/script/config.sh +++ b/script/config.sh @@ -32,6 +32,11 @@ export LVSWAPNAME="swap" # 1 : Overwrite the existing logical volume as root vlume. 0 : Create new logical volume as root volume. export OVERWRITEINSTALL=0 +# Do not touch this parameter, unless you understand precisely what you are doing. +# This is a paameter value of the --iter-time option for cyrptsetup command. +# If you specify 1000, that means 1000mSec. 0 means compile default. +export ITERTIME=0 + # Void Linux only. Ignored in Ubuntu. # The font size of the void-installer export XTERMFONTSIZE=11 diff --git a/script/lib/common.sh b/script/lib/common.sh index 11c3fbd..43a9bb2 100644 --- a/script/lib/common.sh +++ b/script/lib/common.sh @@ -169,7 +169,7 @@ function pre_install() { # Encrypt the partition to install Linux echo "...Initializing \"${DEV}${CRYPTPARTITION}\" as crypt partition" - printf %s "${PASSPHRASE}" | cryptsetup luksFormat --type=luks1 --key-file - --batch-mode "${DEV}${CRYPTPARTITION}" + printf %s "${PASSPHRASE}" | cryptsetup luksFormat --iter-time "${ITERTIME}" --type=luks1 --key-file - --batch-mode "${DEV}${CRYPTPARTITION}" fi # if erase all From 373006dc9023df44f0eb54a293c1ac712db38451 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Wed, 7 Jul 2021 14:07:42 +0900 Subject: [PATCH 21/48] Edit changelog. Add ITERTIME configuration parameter to config.txt Issue #13 --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4633848..0c09d7c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ Record of the modification in project development. ## [Unreleased] - yyyy-mm-dd ### Added +- [Issue 13 : Add ITERTIME configuration parameter to config.txt #13](https://github.com/suikan4github/kaiten-yaki/issues/13) + ### Changed - [Issue 5 : OVERWRITEINSTALL confirmation is missing](https://github.com/suikan4github/kaiten-yaki/issues/5) - [Issue 6 : Remove loglevel dependency from the void-kaiten-yaki.sh ](https://github.com/suikan4github/kaiten-yaki/6) From e2aea91c11656a83b2d10720464175a7d161444c Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Wed, 7 Jul 2021 14:10:25 +0900 Subject: [PATCH 22/48] Reformat the comment of config. For the easy modification by nano editor --- script/config.sh | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/script/config.sh b/script/config.sh index 6f32dfe..7e79a78 100644 --- a/script/config.sh +++ b/script/config.sh @@ -10,15 +10,18 @@ export DEV="/dev/sda" # 0 : No, I don't. I want to add to the existing LUKS volume. export ERASEALL=0 -# Logical Volume name for your Linux installation. Keep it unique from other distribution. +# Logical Volume name for your Linux installation. +# Keep it unique from other distribution. export LVROOTNAME="anko" # Logical volume size of the Linux installation. -# 30% mean, new logical volume will use 30% of the free space in the LVM volume group. -# For example, assume the free space is 100GB, and LVROOTSIZE is 30%FREE. Script will create 30GB logical volume. +# 30% mean, new logical volume will use 30% of the free space +# in the LVM volume group. For example, assume the free space is 100GB, +# and LVROOTSIZE is 30%FREE. Script will create 30GB logical volume. export LVROOTSIZE="50%FREE" -# Set the size of EFI partition and swap partition. The unit is Byte. you can use M,G... notation. +# Set the size of EFI partition and swap partition. +# The unit is Byte. You can use M,G... notation. export EFISIZE="200M" export LVSWAPSIZE="8G" @@ -28,11 +31,12 @@ export CRYPTPARTNAME="luks_volume" export VGNAME="vg1" export LVSWAPNAME="swap" -# Do not touch this parameter, unless you understand precisely what you are doing. -# 1 : Overwrite the existing logical volume as root vlume. 0 : Create new logical volume as root volume. +# Do not touch this parameter, unless you understand what you are doing. +# 1 : Overwrite the existing logical volume as root vlume. +# 0 : Create new logical volume as root volume. export OVERWRITEINSTALL=0 -# Do not touch this parameter, unless you understand precisely what you are doing. +# Do not touch this parameter, unless you understand what you are doing. # This is a paameter value of the --iter-time option for cyrptsetup command. # If you specify 1000, that means 1000mSec. 0 means compile default. export ITERTIME=0 From 2a6f8619003e0bc47808500e5a04fbb6346ac676 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Wed, 7 Jul 2021 21:32:01 +0900 Subject: [PATCH 23/48] Change config.sh description Added explanation of ITERTIME parameter. Change ERASEALL default value. Update the config file contents in INSTALL.md Issue #14 --- INSTALL.md | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index bdc6685..4dd8f6e 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -42,7 +42,7 @@ This is a very critical part of the installation. The configuration parameters a Followings are the set of the default settings of the parameters : - Install to **/dev/sda** (DEV). -- Erase the entire disk (ERASEALL). +- Do not erase the entire disk (ERASEALL). - Overwrite install is disabled. - In the case of EFI firmware, 200MB is allocated to the EFI partition (EFISIZE). - Create a logical volume group named "vg1" in the encrypted volume (VGNAME) @@ -56,32 +56,41 @@ Followings are the set of the default settings of the parameters : export DEV="/dev/sda" # Whether you want to erase all contents of the storage device or not. -# 1: Yes, I want to erase all. -# 0: No, I don't. I want to add to the existing LUKS volume. -export ERASEALL=1 +# 1 : Yes, I want to erase all. +# 0 : No, I don't. I want to add to the existing LUKS volume. +export ERASEALL=0 -# Logical Volume name for your Linux installation. Keep it unique from other distributions. +# Logical Volume name for your Linux installation. +# Keep it unique from other distribution. export LVROOTNAME="anko" # Logical volume size of the Linux installation. -# 30% means the new logical volume will use 30% of the free space in the LVM volume group. -# For example, assume the free space is 100GB, and LVROOTSIZE is 30%FREE. The script will create a 30GB logical volume. +# 30% mean, new logical volume will use 30% of the free space +# in the LVM volume group. For example, assume the free space is 100GB, +# and LVROOTSIZE is 30%FREE. Script will create 30GB logical volume. export LVROOTSIZE="50%FREE" -# Set the size of the EFI partition and swap partition. The unit is Byte. you can use M, G... notation. +# Set the size of EFI partition and swap partition. +# The unit is Byte. You can use M,G... notation. export EFISIZE="200M" export LVSWAPSIZE="8G" # Usually, these names can be left untouched. -# If you change, keep them consistent through all installations in your system. +# If you change, keep them consistent through all instllation in your system. export CRYPTPARTNAME="luks_volume" export VGNAME="vg1" export LVSWAPNAME="swap" -# Do not touch this parameter unless you understand precisely what you are doing. -# 1: Overwrite the existing logical volume as root volume. 0: Create new logical volume as root volume. +# Do not touch this parameter, unless you understand what you are doing. +# 1 : Overwrite the existing logical volume as root vlume. +# 0 : Create new logical volume as root volume. export OVERWRITEINSTALL=0 +# Do not touch this parameter, unless you understand what you are doing. +# This is a paameter value of the --iter-time option for cyrptsetup command. +# If you specify 1000, that means 1000mSec. 0 means compile default. +export ITERTIME=0 + # Void Linux only. Ignored in Ubuntu. # The font size of the void-installer export XTERMFONTSIZE=11 @@ -94,7 +103,7 @@ There are several restrictions : - The EFISIZE and the LVSWAPSIZE are refereed during the first distribution installation only. - The LVROOTSIZE is the size of a logical volume to create. This is a relative value to the existing free space in the volume group. If you want to install 3 distributions in a computer, you may want to set 33%FREE, 50%FREE, and 100%FREE for the first, second, and third distribution installation, respectively. - The name with "-" is not allowed for the VGNAME, LVROOTNAME, and LVSWAPNAME. I saw some installer doesn't work if "-" in in the name. -## About the overwrite-install +### About the overwrite-install The OVERWRITEINSTALL parameter allows you to use an existing logical volume as the root volume of the new installation. This is very dangerous because of several aspects like destroying the wrong volume and the risk of security. But sometimes it is very useful. @@ -112,6 +121,15 @@ And set the following parameters as same as the previous installation. - CRYPTPARTNAME So, Kaiten-yaki will leave the "bad" logical volume and allow you to overwrite it by GUI/TUI installer. +### About ITERTIME parameter +This parameter is recommended to left as default value (=0), unless you understand what it mean well. + +The ITERTIME parameter is passed as --iter-time parameter to the [cryptosetup command](https://man7.org/linux/man-pages/man8/cryptsetup.8.html), when script setup the LUKS crypto volume. + +The unit of value is milliseconds. The target linux kernel may take this duration, to calculate a hash value from the given passphrase. You can change this duration through this parameter. + +The smaller value gives the weaker security. + ## First stage: Setting up the volumes After you set the configuration parameters correctly, execute the following command from the shell. Again, you have to be promoted as the root user, and you have to use Bash. From 7ec2046e5a9b9e2745e2c083f103e877522b65b5 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Wed, 7 Jul 2021 22:41:53 +0900 Subject: [PATCH 24/48] Add ITERTIME parameter to the rooted_job() ITERTIME parameter is not passed to the chrooted_job Issue #15 --- script/lib/chrooted_job_ubuntu.sh | 2 +- script/lib/chrooted_job_void.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/script/lib/chrooted_job_ubuntu.sh b/script/lib/chrooted_job_ubuntu.sh index ed16912..ce85d61 100644 --- a/script/lib/chrooted_job_ubuntu.sh +++ b/script/lib/chrooted_job_ubuntu.sh @@ -22,7 +22,7 @@ function chrooted_job() { # Add a key to the key file. Use the passphrase in the environment variable. echo "...Adding a key to the key file." - printf %s "${PASSPHRASE}" | cryptsetup luksAddKey -d - "${DEV}${CRYPTPARTITION}" /etc/luks/boot_os.keyfile + printf %s "${PASSPHRASE}" | cryptsetup luksAddKey --iter-time "${ITERTIME}" -d - "${DEV}${CRYPTPARTITION}" /etc/luks/boot_os.keyfile # Add the LUKS volume information to /etc/crypttab to decrypt by kernel. echo "...Adding LUKS volume info to /etc/crypttab." diff --git a/script/lib/chrooted_job_void.sh b/script/lib/chrooted_job_void.sh index ee58369..8482b01 100644 --- a/script/lib/chrooted_job_void.sh +++ b/script/lib/chrooted_job_void.sh @@ -22,7 +22,7 @@ function chrooted_job() { # Add a key to the key file. Use the passphrase in the environment variable. echo "...Adding a key to the key file." - printf %s "${PASSPHRASE}" | cryptsetup luksAddKey -d - "${DEV}${CRYPTPARTITION}" /etc/luks/boot_os.keyfile + printf %s "${PASSPHRASE}" | cryptsetup luksAddKey --iter-time "${ITERTIME}" -d - "${DEV}${CRYPTPARTITION}" /etc/luks/boot_os.keyfile # Add the LUKS volume information to /etc/crypttab to decrypt by kernel. echo "...Adding LUKS volume info to /etc/crypttab." From 97d3a46b728fcdefbeb0228d2a1bbf5f75303b54 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Wed, 7 Jul 2021 22:57:40 +0900 Subject: [PATCH 25/48] Update Changelog. ITERTIME parameter is not passed to the chrooted_job Issue #15 --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c09d7c..1337cbf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,11 +12,13 @@ Record of the modification in project development. - [Issue 7 : Add the return status validation ](https://github.com/suikan4github/kaiten-yaki/7) - [Issue 11 : Make chroot'ed job independent script file ](https://github.com/suikan4github/kaiten-yaki/11) - [Issue 12 : change ERASEALL=0 as default ](https://github.com/suikan4github/kaiten-yaki/12) +- [Issue 14 : Change config.sh description ](https://github.com/suikan4github/kaiten-yaki/14) ### Deprecated ### Removed ### Fixed - [Issue 8 : Wrong message after cancellation ](https://github.com/suikan4github/kaiten-yaki/8) +- [Issue 15 : CITERTIME parameter is not passed to the chrooted_job ](https://github.com/suikan4github/kaiten-yaki/15) ### Known Issue From be32e5e387cfdf7fa2c990a137f9e3d3dbd14e96 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Thu, 8 Jul 2021 07:47:23 +0900 Subject: [PATCH 26/48] Update comment No program change. --- script/lib/common.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/script/lib/common.sh b/script/lib/common.sh index 43a9bb2..4f732b8 100644 --- a/script/lib/common.sh +++ b/script/lib/common.sh @@ -298,7 +298,7 @@ function post_install() { echo "...Mounting all other dirs." for n in proc sys dev tmp etc/resolv.conf; do mount --rbind "/$n" "${TARGETMOUNTPOINT}/$n"; done - # Copy all scripts to the target /tmp + # Copy all scripts to the target /tmp to in chroot session. echo "...Copy files in current dir to ${TARGETMOUNTPOINT}/tmp." mkdir "${TARGETMOUNTPOINT}/tmp/kaiten-yaki" cp -r ./* -t "${TARGETMOUNTPOINT}/tmp/kaiten-yaki" @@ -306,7 +306,7 @@ function post_install() { # Change root and create the keyfile and ramfs image for Linux kernel. # The here document is script executed under chroot. And here we call # the distribution dependent script "lib/chrooted_job_${DISTRIBUTIONSIGNATURE}.sh". - echo "...Chroot to ${TARGETMOUNTPOINT}." + echo "...Chroot to ${TARGETMOUNTPOINT}. and execute chrooted_job_${DISTRIBUTIONSIGNATURE}.sh" # shellcheck disable=SC2086 cat <<- HEREDOC | chroot "${TARGETMOUNTPOINT}" /bin/bash cd /tmp/kaiten-yaki From 40264ce02f6ebbe965990b8dd11ae18ac1451613 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Thu, 8 Jul 2021 21:19:16 +0900 Subject: [PATCH 27/48] Refine the comment. --- script/lib/chrooted_job_ubuntu.sh | 14 +++++--- script/lib/chrooted_job_void.sh | 56 +++++++++++++++++-------------- script/lib/common.sh | 7 ++-- 3 files changed, 43 insertions(+), 34 deletions(-) diff --git a/script/lib/chrooted_job_ubuntu.sh b/script/lib/chrooted_job_ubuntu.sh index ce85d61..2d953ca 100644 --- a/script/lib/chrooted_job_ubuntu.sh +++ b/script/lib/chrooted_job_ubuntu.sh @@ -9,26 +9,30 @@ function chrooted_job() { # Mount the rest of partitions by target /etc/fstab mount -a - # Set up the kernel hook of encryption + # Prepare the crypto tool in the install target echo "...Installing cryptsetup-initramfs package." apt -qq install -y cryptsetup-initramfs - # Prepare a key file to embed in to the ramfs. + # Prepare a new key file to embed in to the ramfs. + # This new file contains a new key to open the LUKS volume. + # The new key is 4096byte length binary value. + # Because this key is sotred as "cleartext", in the target file sysmte, + # only root is allowed to access this key file. echo "...Prepairing key file." mkdir /etc/luks dd if=/dev/urandom of=/etc/luks/boot_os.keyfile bs=4096 count=1 status=none chmod u=rx,go-rwx /etc/luks chmod u=r,go-rwx /etc/luks/boot_os.keyfile - # Add a key to the key file. Use the passphrase in the environment variable. + # Add the new key to the LUKS 2nd key slot. The passphrase is required to modify the LUKS keyslot. echo "...Adding a key to the key file." printf %s "${PASSPHRASE}" | cryptsetup luksAddKey --iter-time "${ITERTIME}" -d - "${DEV}${CRYPTPARTITION}" /etc/luks/boot_os.keyfile - # Add the LUKS volume information to /etc/crypttab to decrypt by kernel. + # Register the LUKS voluem to /etc/crypttab to tell "This volume is encrypted" echo "...Adding LUKS volume info to /etc/crypttab." echo "${CRYPTPARTNAME} UUID=$(blkid -s UUID -o value ${DEV}${CRYPTPARTITION}) /etc/luks/boot_os.keyfile luks,discard" >> /etc/crypttab - # Putting key file into the ramfs initial image + # Add key file to the list of the intems in initfsram. echo "...Registering key file to the ramfs" echo "KEYFILE_PATTERN=/etc/luks/*.keyfile" >> /etc/cryptsetup-initramfs/conf-hook echo "UMASK=0077" >> /etc/initramfs-tools/initramfs.conf diff --git a/script/lib/chrooted_job_void.sh b/script/lib/chrooted_job_void.sh index 8482b01..2d50a73 100644 --- a/script/lib/chrooted_job_void.sh +++ b/script/lib/chrooted_job_void.sh @@ -6,39 +6,43 @@ source config.sh # Create a key file for LUKS and register it as contents of the initramfs image function chrooted_job() { - # Mount the rest of partitions by target /etc/fstab - mount -a + # Mount the rest of partitions by target /etc/fstab + mount -a - # Set up the kernel hook of encryption - echo "...Installing cryptsetup-initramfs package." - xbps-install -y lvm2 cryptsetup + # Prepare the crypto tool in the install target + echo "...Installing cryptsetup-initramfs package." + xbps-install -y lvm2 cryptsetup - # Prepare a key file to embed in to the ramfs. - echo "...Prepairing key file." - mkdir /etc/luks - dd if=/dev/urandom of=/etc/luks/boot_os.keyfile bs=4096 count=1 status=none - chmod u=rx,go-rwx /etc/luks - chmod u=r,go-rwx /etc/luks/boot_os.keyfile + # Prepare a new key file to embed in to the ramfs. + # This new file contains a new key to open the LUKS volume. + # The new key is 4096byte length binary value. + # Because this key is sotred as "cleartext", in the target file sysmte, + # only root is allowed to access this key file. + echo "...Prepairing key file." + mkdir /etc/luks + dd if=/dev/urandom of=/etc/luks/boot_os.keyfile bs=4096 count=1 status=none + chmod u=rx,go-rwx /etc/luks + chmod u=r,go-rwx /etc/luks/boot_os.keyfile - # Add a key to the key file. Use the passphrase in the environment variable. - echo "...Adding a key to the key file." - printf %s "${PASSPHRASE}" | cryptsetup luksAddKey --iter-time "${ITERTIME}" -d - "${DEV}${CRYPTPARTITION}" /etc/luks/boot_os.keyfile + # Add the new key to the LUKS 2nd key slot. The passphrase is required to modify the LUKS keyslot. + echo "...Adding a key to the key file." + printf %s "${PASSPHRASE}" | cryptsetup luksAddKey --iter-time "${ITERTIME}" -d - "${DEV}${CRYPTPARTITION}" /etc/luks/boot_os.keyfile - # Add the LUKS volume information to /etc/crypttab to decrypt by kernel. - echo "...Adding LUKS volume info to /etc/crypttab." - echo "${CRYPTPARTNAME} UUID=$(blkid -s UUID -o value ${DEV}${CRYPTPARTITION}) /etc/luks/boot_os.keyfile luks,discard" >> /etc/crypttab + # Register the LUKS voluem to /etc/crypttab to tell "This volume is encrypted" + echo "...Adding LUKS volume info to /etc/crypttab." + echo "${CRYPTPARTNAME} UUID=$(blkid -s UUID -o value ${DEV}${CRYPTPARTITION}) /etc/luks/boot_os.keyfile luks,discard" >> /etc/crypttab - # Putting key file into the ramfs initial image - echo "...Registering key file to the ramfs" - echo 'install_items+=" /etc/luks/boot_os.keyfile /etc/crypttab " ' > /etc/dracut.conf.d/10-crypt.conf + # Add key file to the list of the intems in initfsram. + echo "...Registering key file to the ramfs" + echo 'install_items+=" /etc/luks/boot_os.keyfile /etc/crypttab " ' > /etc/dracut.conf.d/10-crypt.conf - # Finally, update the ramfs initial image with the key file. - echo "...Upadting initramfs." - xbps-reconfigure -fa - echo "...grub-mkconfig." - grub-mkconfig -o /boot/grub/grub.cfg + # Finally, update the ramfs initial image with the key file. + echo "...Upadting initramfs." + xbps-reconfigure -fa + echo "...grub-mkconfig." + grub-mkconfig -o /boot/grub/grub.cfg - # Leave chroot + # Leave chroot } # Execute job diff --git a/script/lib/common.sh b/script/lib/common.sh index 4f732b8..ec076b5 100644 --- a/script/lib/common.sh +++ b/script/lib/common.sh @@ -298,14 +298,15 @@ function post_install() { echo "...Mounting all other dirs." for n in proc sys dev tmp etc/resolv.conf; do mount --rbind "/$n" "${TARGETMOUNTPOINT}/$n"; done - # Copy all scripts to the target /tmp to in chroot session. + # Copy all scripts to the target /tmp for using in chroot session. echo "...Copy files in current dir to ${TARGETMOUNTPOINT}/tmp." mkdir "${TARGETMOUNTPOINT}/tmp/kaiten-yaki" cp -r ./* -t "${TARGETMOUNTPOINT}/tmp/kaiten-yaki" # Change root and create the keyfile and ramfs image for Linux kernel. - # The here document is script executed under chroot. And here we call - # the distribution dependent script "lib/chrooted_job_${DISTRIBUTIONSIGNATURE}.sh". + # The here-document is script executed under chroot. At here we call + # the distribution dependent script "lib/chrooted_job_${DISTRIBUTIONSIGNATURE}.sh", + # which was copied to /temp at previous code. echo "...Chroot to ${TARGETMOUNTPOINT}. and execute chrooted_job_${DISTRIBUTIONSIGNATURE}.sh" # shellcheck disable=SC2086 cat <<- HEREDOC | chroot "${TARGETMOUNTPOINT}" /bin/bash From e5417d78a3aa7c596ef4075e1b0574838ae2d828 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Thu, 8 Jul 2021 22:35:18 +0900 Subject: [PATCH 28/48] Fix the unmount fails Trial fix. Change the --rbinds to --make-slave. #17 --- script/lib/common.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/script/lib/common.sh b/script/lib/common.sh index ec076b5..b5fd1b4 100644 --- a/script/lib/common.sh +++ b/script/lib/common.sh @@ -296,7 +296,9 @@ function post_install() { # And mount other directories echo "...Mounting all other dirs." - for n in proc sys dev tmp etc/resolv.conf; do mount --rbind "/$n" "${TARGETMOUNTPOINT}/$n"; done + mount --make-slave "${TARGETMOUNTPOINT}" + mount --rbind /etc/resolv.conf "${TARGETMOUNTPOINT}"/resolv.conf +# for n in proc sys dev tmp etc/resolv.conf; do mount --rbind "/$n" "${TARGETMOUNTPOINT}/$n"; done # Copy all scripts to the target /tmp for using in chroot session. echo "...Copy files in current dir to ${TARGETMOUNTPOINT}/tmp." From c9b69412948af77851454653cb6644c1c0de3e1a Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Thu, 8 Jul 2021 22:48:19 +0900 Subject: [PATCH 29/48] Revert "Fix the unmount fails" This reverts commit e5417d78a3aa7c596ef4075e1b0574838ae2d828. --- script/lib/common.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/script/lib/common.sh b/script/lib/common.sh index b5fd1b4..ec076b5 100644 --- a/script/lib/common.sh +++ b/script/lib/common.sh @@ -296,9 +296,7 @@ function post_install() { # And mount other directories echo "...Mounting all other dirs." - mount --make-slave "${TARGETMOUNTPOINT}" - mount --rbind /etc/resolv.conf "${TARGETMOUNTPOINT}"/resolv.conf -# for n in proc sys dev tmp etc/resolv.conf; do mount --rbind "/$n" "${TARGETMOUNTPOINT}/$n"; done + for n in proc sys dev tmp etc/resolv.conf; do mount --rbind "/$n" "${TARGETMOUNTPOINT}/$n"; done # Copy all scripts to the target /tmp for using in chroot session. echo "...Copy files in current dir to ${TARGETMOUNTPOINT}/tmp." From 2ae4d6cd269840e324150fbb12f00881ad074d44 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Thu, 8 Jul 2021 23:09:02 +0900 Subject: [PATCH 30/48] Add -l option ot unmount to surpress the "busy" error --- script/lib/common.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/script/lib/common.sh b/script/lib/common.sh index ec076b5..ba80dff 100644 --- a/script/lib/common.sh +++ b/script/lib/common.sh @@ -315,9 +315,9 @@ function post_install() { source "lib/chrooted_job_${DISTRIBUTIONSIGNATURE}.sh" HEREDOC - # Unmount all + # Unmount all. -l ( lazy ) option is added to supress the busy error. echo "...Unmounting all." - umount -R "${TARGETMOUNTPOINT}" + umount -R -l "${TARGETMOUNTPOINT}" # Finishing message cat <<- HEREDOC From 20826f2f6903a2263ebcfcab88af068df9e178f3 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Thu, 8 Jul 2021 23:10:39 +0900 Subject: [PATCH 31/48] Update changelog Unmount fails #17 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1337cbf..af2b381 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ Record of the modification in project development. ### Fixed - [Issue 8 : Wrong message after cancellation ](https://github.com/suikan4github/kaiten-yaki/8) - [Issue 15 : CITERTIME parameter is not passed to the chrooted_job ](https://github.com/suikan4github/kaiten-yaki/15) +- [Issue 17 : Unmount fails ](https://github.com/suikan4github/kaiten-yaki/17) ### Known Issue From bde36aa1ea3b74933872172b9bc69a03dab3e2fe Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sat, 10 Jul 2021 12:06:52 +0900 Subject: [PATCH 32/48] Refine the display message. No change on the executable code. --- script/lib/common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/lib/common.sh b/script/lib/common.sh index ba80dff..8fcb0ea 100644 --- a/script/lib/common.sh +++ b/script/lib/common.sh @@ -299,7 +299,7 @@ function post_install() { for n in proc sys dev tmp etc/resolv.conf; do mount --rbind "/$n" "${TARGETMOUNTPOINT}/$n"; done # Copy all scripts to the target /tmp for using in chroot session. - echo "...Copy files in current dir to ${TARGETMOUNTPOINT}/tmp." + echo "...Copying files in current dir to ${TARGETMOUNTPOINT}/tmp." mkdir "${TARGETMOUNTPOINT}/tmp/kaiten-yaki" cp -r ./* -t "${TARGETMOUNTPOINT}/tmp/kaiten-yaki" From badafda222079950475374dd083fd56750e041a9 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sat, 10 Jul 2021 12:31:42 +0900 Subject: [PATCH 33/48] Update the README and INSTALL --- INSTALL.md | 24 ++++++++++++------------ README.md | 16 ++++++++++------ 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 4dd8f6e..e19f912 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -13,19 +13,19 @@ The first stage of the script is preparation like: erasing a disk, format partit In the second stage, the distribution-dependent GUI/TUI installer is invoked from the running script. That is the Ubiquity/void-installer of Ubuntu/Void Linux, respectively. -The third stage is easy. There is nothing the user can do. Everything is automatic. +The third configure the target Linux system to decrypt the encrypted volume automatically, without prompting user to type passphrase. In this stage, Everything is automatic. # Installation Follow the steps below. ## Shell preparation -First of all, promote the shell to root. Almost of the procedure requires root privilege. Note that the scripts require Bash. +First of all, promote the shell to root. Almost of the procedure in the installation requires root privilege. Note that the scripts require Bash. -In the case of Ubuntu : +In the case of Ubuntu installation: ```bash # Promote to the root user sudo -i /bin/bash ``` -In the case of Void-Linux : +In the case of Void Linux installation: ```bash sudo -i /bin/bash xbps-install -Su xbps nano @@ -47,7 +47,7 @@ Followings are the set of the default settings of the parameters : - In the case of EFI firmware, 200MB is allocated to the EFI partition (EFISIZE). - Create a logical volume group named "vg1" in the encrypted volume (VGNAME) - Create a swap logical volume named "swap" in the "vg1". The size is 8GB (LVSWAPNAME,LVSWAPSIZE) -- Create a logical volume named **"anko"** for / in the "vg1". The size of the **50%** of the entire free space (LVROOTNAME, LVROOTSIZE). +- Create a logical volume named **"anko"** as root volume, in the "vg1". The size of the new volume is the **50%** of the free space (LVROOTNAME, LVROOTSIZE). ```bash # Configuration parameters for Kaiten-Yaki @@ -97,9 +97,9 @@ export XTERMFONTSIZE=11 ``` There are several restrictions : -- For the first distribution installation, you must set ERASEALL to 1, to erase the entire screen and create a LUKS partition. Kaiten-yaki script creates a maximum LUKS partition as possible. -- The LVROOMNAME must be unique among all installations in a computer. Otherwise, Kaiten-yaki terminates in a middle. -- The LVSWAPNAME must be unique among all installations in a computer. Otherwise, Kaiten-yaki creates an unnecessary logical volume. This is a waste of storage resources. +- For the first distribution installation, you must set ERASEALL to 1, to erase the entire storage device and create a LUKS partition. Kaiten-yaki script creates a maximum LUKS partition as possible. +- The LVROOTNAME must be unique among all installations in a computer. Otherwise, Kaiten-yaki terminates in a middle. +- The LVSWAPNAME must be identical among all installations in a computer. Otherwise, Kaiten-yaki creates an unnecessary logical volume. This is a waste of storage resources. - The EFISIZE and the LVSWAPSIZE are refereed during the first distribution installation only. - The LVROOTSIZE is the size of a logical volume to create. This is a relative value to the existing free space in the volume group. If you want to install 3 distributions in a computer, you may want to set 33%FREE, 50%FREE, and 100%FREE for the first, second, and third distribution installation, respectively. - The name with "-" is not allowed for the VGNAME, LVROOTNAME, and LVSWAPNAME. I saw some installer doesn't work if "-" in in the name. @@ -108,7 +108,7 @@ The OVERWRITEINSTALL parameter allows you to use an existing logical volume as t This is very dangerous because of several aspects like destroying the wrong volume and the risk of security. But sometimes it is very useful. -For example, assume you are installing a distribution by Kaiten-yaki. If you reboot the system at the end of GUI/TUI installer by mistake, your system will never boot again. +For example, assume you are installing a distribution by Kaiten-yaki. If you reboot the system at the end of GUI/TUI installer by mistake, your system may never boot again. In this case, the overwrite-install can recycle this "bad" logical volume and let your system boot again. To use the overwrite-install, you have to set some parameters as follows: @@ -120,7 +120,7 @@ And set the following parameters as same as the previous installation. - VGNAME - CRYPTPARTNAME -So, Kaiten-yaki will leave the "bad" logical volume and allow you to overwrite it by GUI/TUI installer. +Kaiten-yaki will leave the "bad" logical volume and allow you to overwrite it by GUI/TUI installer. ### About ITERTIME parameter This parameter is recommended to left as default value (=0), unless you understand what it mean well. @@ -142,7 +142,7 @@ In the case of Void Linux ```bash source void-kaiten-yaki.sh ``` -After several interactive confirmations, Kaiten-yaki will ask you to input a passphrase. This passphrase will be applied to the encryption of the LUKS volume. Make sure you use identical passphrases between all installations of the distributions in a computer. Otherwise, the install process terminates with an error. +After several interactive confirmations, Kaiten-yaki will ask you to input a passphrase. This passphrase will be applied to the encryption of the LUKS volume. Make sure you use identical passphrases between all installations of the distributions in a computer. Otherwise, the install process terminates with an error, except the first distribution installation. ## Second stage : GUI/TUI installer After the first script finishes, the GUI/TUI installer starts automatically. Configure it as usual and run it. Ensure you map the following correctly. @@ -166,7 +166,7 @@ At the end of the GUI/TUI installing, do not reboot the system. Click "Continue" ## Third stage: Finalizing After GUI/TUI installer quits without rebooting, the final part of the install process automatically starts. -In this section, Kaiten-yaki put the encryption key of the LUKS volume into the ramfs initial stage to allow the Linux kernel to decrypt the LUKS partition which contains root logical volume. So, the system will ask you passphrase only once when GRUB starts. +In this section, Kaiten-yaki put the encryption key of the LUKS volume into the ramfs initial stage to allow the Linux kernel to decrypt the LUKS partition which contains root logical volume. Thus, the system will ask you passphrase only once when GRUB starts. You can reboot the system if you see the "Ready to reboot" message on the console. diff --git a/README.md b/README.md index 02f196d..309ba27 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ # Kaiten-yaki: Full disk encryption install script for Linux -Kaiten-yaki is a script set to install to your desktop system. With these scripts, you can install Ubuntu/Void Linux to an encrypted partition easily. +Kaiten-yaki is a script set to install Linux to your desktop system. With these scripts, you can install Ubuntu/Void Linux to an encrypted partition easily. The followings are the list of functionalities: - Ubuntu and Void Linux. -- Install from LiveCD/USB. +- Help to install from LiveCD/USB. - Invoke GUI/TUI installer automatically at the middle of script execution, for the ease of installation. - Automatic detection of BIOS/EFI firmware and create MBR/GPT, respectively. - Create an EFI partition, if needed. @@ -14,7 +14,7 @@ The followings are the list of functionalities: With the configuration parameters, you can customize each installation. For example, you can configure the system to have 2, 3, or 4,... distributions in an HDD/SSD, as you want. -Following is the HDD/SSD partitioning plan of these scripts ( In the case of BIOS, the disk has MBR and doesn't have an EFI partition, while it is depicted here). +Following is the HDD/SSD partitioning plan of these scripts ( In the case of BIOS, the disk has MBR and doesn't have an EFI partition). ![Partition Diagram](image/partition_diagram_0.png) @@ -27,21 +27,25 @@ These scripts are tested with the following environment. - VMWare Workstation 15.5.7 ( EFI/BIOS ) - ThinkPad X220 (BIOS) - Ubuntu 20.04.2 amd64 desktop +- Ubuntu 21.04 amd64 desktop - Ubuntu Mate 20.04.2 amd64 desktop - void-live-x86_64-20210218-mate.iso - void-live-x86_64-musl-20210218-mate.iso - void-live-x86_64-20210218.iso # Installation -Start the PC with the LiveCD/LiveUSB of the distribution to install. Download this repository from GitHub, and expand it. +Rough procedure of the installation is as followings : +1. Start the PC with the LiveCD/LiveUSB of the distribution to install +1. Download this repository from GitHub +3. Run the script. -Then, go to the script directory and follow the procedure in the [INSTALL.md](INSTALL.md) +The detail procedure is explained in the [INSTALL.md](INSTALL.md). # Known issues If you install two or more Void Linux into the EFI system, only the last one can boot without trouble. This is not the problem of Kaiten-yaki. # Variants considerations -Ubuntu has several variants ( flavors ). While I have tested only MATE flavor, other flavors may work correctly as far as it uses Ubiquity installer. +Ubuntu has several variants ( flavors ). While while only the MATE flavor is tested, other flavors may work correctly as far as it uses Ubiquity installer. # Acknowledgments These scripts are based on the script by [myn's diary](https://myn.hatenablog.jp/entry/install-ubuntu-focal-with-lvm-on-luks). That page contains rich information, hint, and techniques around the encrypted volume and Ubiquity installer. From 8ad1362a3bdf16c3a3958279c9487c2bb30f31a3 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sat, 10 Jul 2021 14:05:23 +0900 Subject: [PATCH 34/48] Add an01 Add a document of how to receover from the mistyping of passphrase Issue#21 --- appnote/an01_howtorecover.md | 62 +++++++++++++++++++++++++++++++++++ image/an01_bios.png | Bin 0 -> 5718 bytes image/an01_efi.png | Bin 0 -> 10519 bytes image/an01_normal.png | Bin 0 -> 7280 bytes 4 files changed, 62 insertions(+) create mode 100644 appnote/an01_howtorecover.md create mode 100755 image/an01_bios.png create mode 100755 image/an01_efi.png create mode 100755 image/an01_normal.png diff --git a/appnote/an01_howtorecover.md b/appnote/an01_howtorecover.md new file mode 100644 index 0000000..c715be6 --- /dev/null +++ b/appnote/an01_howtorecover.md @@ -0,0 +1,62 @@ +# How to recover from the mistyping of the passphrase +The mistyping of the passphrase is painful, in the full disk encrypted Linux. + +In the usual encrypted Ubuntu install by Ubiquity, mistyping os passphrase is warn by the kernel, and prompted to re-type. But in the full encrypted system, the user sees a boring message and command prompt. Usually, the user just gives up and reboot. It adds tens of second to reboot, and discourage the under to use a long passphrase. + +![bios](../image/an01_bios.png) + +This application note explains how to recover from this condition, quickly. + +# BIOS system +In the BIOS system, the recovery is pretty easy. + +In the case of the mistyping passphrase, GRUB goes into rescue mode. In this mode, the user can recover from 3 commands. + +``` +cryptomount -a +insmod normal +normal +``` + +The **cryptomount** command tries to mount the specific encrypted partition to boot. To mount it, the GRUB prompts the user to type the passphrase. The "-a" option specifies all encrypted partitions. If the system is encrypted by Kaiten-yaki, it has only one encrypted partition. So, this is the easiest way. + +The **insmod** command loads the specified GRUB command module from the mounted storage and inserts it into the command list. The second line loads the "normal" command which displays the normal menu to the user. + +Finally, **normal** command shows the normal boot menu to the user. + +Now, the user can select the system to boot as usual. + +# EFI system +In the EFI system, recovery needs extra steps compared to the BIOS system. + +Alternatively, GURB is not in the rescue mode but the normal mode, even the passphrase is mistyped. So, the user can use command completion. This is better than the BIOS system. + +The first step of the recovery is the same with the BIOS system. +``` +cryptomount -a +``` +Again, in the EFI system, the user can use the command completion by pressing the [TAB] key. + +The second step is unique in the EFI system. By using **ls** command check the list of volumes existing in the system, and identify which volume contains the grub menu. And then, pick that volume and assign it to the **prefix** variable, with grub path. + +Following is the example. The (lvm/vg1-mate) is dependent on the system. It has to be substituted by the appropriate volume name for each system. + +``` +ls +set prefix=(lvm/vg1-mate)/boot/grub +``` + +Then, the third step is the same with the BIOS systems. + +``` +insmod normal +normal +``` +Following is the screenshot of the command sequence to recover the mistyping of the passphrase. + +![bios](../image/an01_efi.png) + +## Summary +In the full disk encrypted system, mistyping of the passphrase is more painful than the partially encrypted system. The user can overcome this situation with several steps of commands and can show the normal boot menu. + +![bios](../image/an01_normal.png) diff --git a/image/an01_bios.png b/image/an01_bios.png new file mode 100755 index 0000000000000000000000000000000000000000..034f2e73da997a3690aa576240190a9a07c65bfd GIT binary patch literal 5718 zcmb_gc{E%5zTa(6j#F;yRE1ND9%Ip(hZ@RNQz=R$X3-+%P%}04=uxHU5maNIOG4Bb z#8C4!Mr#%k5>w4F&t7`&yX(ER-oNj=)^A>W|MvcVKi@IN*hu#pGZ!-e0N3;$Ye4|u zay?_7{>x=X|Gk_2fH7S1h3Gy4aD%tMGZsHNYZz((K*f8O)8`<@`s$0vmc9URz5PeK z)a_O5$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normal.png b/image/an01_normal.png new file mode 100755 index 0000000000000000000000000000000000000000..a90c26f994168e5ec5efb5d569155467c99f2955 GIT binary patch literal 7280 zcmeHsX;_kL+wOx_HfZ){ljg8mrM1-5a@LGiYJ+o{BMy}n4v9m~C|Is6t)!MYlmbmk zX=;UnBe-fACMqSODI(^CfH2dhqp;_m=TJE`MnJqpi&GSFh5UVhy2dc1xlp0R6;21*l7(Uy?*G zo;qm^Qr+*O7uOPs)w$Iow}8(jNVr(Pu&!G6-!pfhNefrZcJI%!E$5D;HIiWv{ol! z>e!~xe$NcE#>&soHoATgrf`b*edpDENBo+^V?~g)kL==ge^Tk2i+|Sa5xKX*HSw|( zQa+a$qWXUG(@mf*=Z3QftCx-;aCw^59>^L<=d(MeW1|`ADgr-Qwz=H4Ig!^ALn~3y zr%gT~ja?6eb!eJ#%-|cYTKaFNPaJEJ66F0$sP^0-d4{VXu!eHV9_Np96ICyr3 z!ia0ZA{2t+X)B;j(6CPJzu+;muqh-3g{`oNQ~~bI(e=m#!%5XWfYOYEG9oI~2>_I% z5bXn+|0j?=?G8U<8b(4yL$(1*nHdVa&lTvuz?dZlgGYV~6JFjX`~BVI}eW?w9XpFvT^7dbSf zOz1Bu{2Maj(PAkxwq)=6%`*BMa|PzE4xn^Fs{>)k!VOW8N2@&)c^_rAqToNc;O+OX z*@Uh6$OOO!jY;nU3|s%4=`;r*P3z{(Q*a7)xJk%iW=qS<;B)H$%nS~#RiH0o_cF#*>BO7fH9>J(6)**D5@C7;MDU3aAkpqiIyBlnXw zX#ud4fM{%Kch5{LQ?LD!yBQme_Ki};XK*lS_Hvg4i!lf!d9#5;1*L`?@UY?*|L~KG{6$}T}I4LI7 z<%wixfpytB`rq52ZB zaj7w(CUipNIkjCsuP%t|D6oF|VeNW(HiBQq6|(NT6Q1ks4RZ|9+RK1X*kR?;^+VO0 zF?D*|pU^}d>(6#Y^F7@OwV?Zr?5vD6Sg1!B=_Xh79I3dyY|laP5D^hHUpkKaIa(Nb zrKW8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.noreply.github.com> Date: Sat, 10 Jul 2021 14:08:09 +0900 Subject: [PATCH 35/48] Add AN01 to the README --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 309ba27..4fc481d 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,9 @@ If you install two or more Void Linux into the EFI system, only the last one can # Variants considerations Ubuntu has several variants ( flavors ). While while only the MATE flavor is tested, other flavors may work correctly as far as it uses Ubiquity installer. +# Application notes +- [AP01 : How to recover from the mistyping of the passphrase](appnote/an01_howtorecover.md) + # Acknowledgments These scripts are based on the script by [myn's diary](https://myn.hatenablog.jp/entry/install-ubuntu-focal-with-lvm-on-luks). That page contains rich information, hint, and techniques around the encrypted volume and Ubiquity installer. From 8fd083a0ebbab1a1dd1b8153563219d5eba21561 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sat, 10 Jul 2021 15:19:38 +0900 Subject: [PATCH 36/48] Add an0. Still writing --- appnote/an02_keyslot.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 appnote/an02_keyslot.md diff --git a/appnote/an02_keyslot.md b/appnote/an02_keyslot.md new file mode 100644 index 0000000..88872f8 --- /dev/null +++ b/appnote/an02_keyslot.md @@ -0,0 +1,28 @@ +# Managing LUKS key slots +If somebody want to install two or three distributions into a system, Kaiten-yaki works perfectly. There is not problem at all. + +On the other hand, some extreme cases like installing distributions as many as possible, or repeating the overwrite installation, the user must understand and manage the LUKS key slots well. + +This application note explains the limitations and difficulties by the number of LUKS key slots, and how to overcome that limitation( if possible ). + +# The LUKS key slots +The LUKS volume has 8 key slots. That means, up to 8 key hashes can be stored. In other words, user can use 8 different keys to open a LUKS volume. + +In this case, the "user" is not limited as human being. Any software can use passphrase to open a LUKS volume. Thus, even the "user" is one person, multiple key slot may be used. + +If some user ( or software ) feed the passpharse to open a LUKS, the management software ( dm-crypt library ) scans keyslots and check whether there is a macching slot or not. If there is a slot which stored hash value maches with the hash value of the given passphrase, that passphrase is the right one. + +# Usage of key slots by Kaiten-yaki +Kaiten-yaki N+1 LUKS key slots to install the N distributions in a system. + +Whenever Kaiten-yaki create a LUKS volume, it registers the passphrase typed by the user. This passphrase is stored in to the key slot 0. So, when user type his passphrase correctly, it will be matched with the has value in the slot 0, by default. + +In addition to the user passphrase, Kaiten-yaki uses one key slot to register the passphrase to open the LUKS volume from the linux kernel. This passphrase is different from the + +# Overwrite installation + +# Managing key slots + + +# A dirty hack + From 81a07816165a2fc01377ad775be9701cdd43e135 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sat, 10 Jul 2021 22:18:09 +0900 Subject: [PATCH 37/48] Add AN02 key slot. Add a consideration of the number of key slot Issue #18 --- appnote/an02_keyslot.md | 78 +++++++++++++++++++++++++++++++++++------ 1 file changed, 67 insertions(+), 11 deletions(-) diff --git a/appnote/an02_keyslot.md b/appnote/an02_keyslot.md index 88872f8..74766c6 100644 --- a/appnote/an02_keyslot.md +++ b/appnote/an02_keyslot.md @@ -1,28 +1,84 @@ # Managing LUKS key slots -If somebody want to install two or three distributions into a system, Kaiten-yaki works perfectly. There is not problem at all. +If somebody wants to install two or three distributions into a system, Kaiten-yaki works perfectly. There is no problem at all. -On the other hand, some extreme cases like installing distributions as many as possible, or repeating the overwrite installation, the user must understand and manage the LUKS key slots well. +On the other hand, some extreme cases like installing distributions as many as possible, or repeating the overwrite installation unveils the limitation of the number of the LUKS key slots. The user must understand and must manage the LUKS key slots well, to handle these cases. -This application note explains the limitations and difficulties by the number of LUKS key slots, and how to overcome that limitation( if possible ). +This application note explains the limitations and difficulties that come from the number of LUKS key slots, and how to overcome that limitation( if possible ). # The LUKS key slots -The LUKS volume has 8 key slots. That means, up to 8 key hashes can be stored. In other words, user can use 8 different keys to open a LUKS volume. +The LUKS volume has 8 key slots. That means, up to 8 key hash values can be stored. In other words, the user can use 8 different keys to open a LUKS volume. -In this case, the "user" is not limited as human being. Any software can use passphrase to open a LUKS volume. Thus, even the "user" is one person, multiple key slot may be used. +In this context, the "user" is not limited to a human being. Any software can use a passphrase to open a LUKS volume. Thus, even only one person uses a computer, multiple key slots may be used. -If some user ( or software ) feed the passpharse to open a LUKS, the management software ( dm-crypt library ) scans keyslots and check whether there is a macching slot or not. If there is a slot which stored hash value maches with the hash value of the given passphrase, that passphrase is the right one. +If some user ( or software ) feeds a passphrase to open a LUKS volume, the management software ( dm-crypt library ) scans key slots and check whether there is a matching slot or not. If there is a slot in which the stored hash value matches with the hash value of the given passphrase, that passphrase is the right one. -# Usage of key slots by Kaiten-yaki -Kaiten-yaki N+1 LUKS key slots to install the N distributions in a system. +# How Kaiten-yaki uses the LUKS key slots +Kaiten-yaki uses N+1 LUKS key slots to install the N distributions in a system ( where N is an integer ). -Whenever Kaiten-yaki create a LUKS volume, it registers the passphrase typed by the user. This passphrase is stored in to the key slot 0. So, when user type his passphrase correctly, it will be matched with the has value in the slot 0, by default. +Whenever Kaiten-yaki creates a LUKS volume, it registers a passphrase typed by the user. This passphrase is stored in the key slot 0. So, when the user types his passphrase correctly, its hash will be matched with the hash value in slot 0, by default. -In addition to the user passphrase, Kaiten-yaki uses one key slot to register the passphrase to open the LUKS volume from the linux kernel. This passphrase is different from the +In addition to the user passphrase, Kaiten-yaki uses one key slot to register the passphrase to open the LUKS volume from the Linux kernel. This passphrase is different from the user passphrase. This passphrase is random binary brock generated by /dev/random. This key is stored in the file under /etc/luks. Even somebody watches its value over the shoulder, the risk is small because it is difficult to ready for a human being. +Anyway, this usage defines the maximum number of Linux installed in a system. That is 7 if all are installed by Kaiten-yaki. If a user try to install the 8th distribution in a LUKS volume with Kaiten-yaki, it will fail because there is no vacant LUKS key slot. # Overwrite installation +The overwrite installation is another case that consumes a LUKS key slot. +if the variable OVERWITEINSTALL in config.sh is set to 1, Kaiten-yaki just overwrites an existing logical volume in the LUKS volume. Also, in this case, Kaiten-yaki registers a new key file for the new installation. Thus, while the number of the installed Linux is the same, the number of the used LUKS key slot is increased. + +Eventually, the user fails to install even the installed Linux is 2 or 3, if there is not vacant LUKS key slot. # Managing key slots +Some users may want to delete a key slot to install another distribution. In this case, they must know which LUKS key slots are used or not. +This section explains how to investigate the used slots. -# A dirty hack +First of all, user can l +The example of this command is shown below. Slot 0, 1, and 2 are occupied : +``` +takemasa@mate-vm:~$ sudo cryptsetup luksDump /dev/sda2 | grep -i bled +Key Slot 0: ENABLED +Key Slot 1: ENABLED +Key Slot 2: ENABLED +Key Slot 3: DISABLED +Key Slot 4: DISABLED +Key Slot 5: DISABLED +Key Slot 6: DISABLED +Key Slot 7: DISABLED +``` +If there is still a vacant LUKS key slot, the user can install another distribution without deleting the existing slot. But if there is not vacant LUKS key slot at all, the user must delete an occupied but unused slot. To know such a slot, the user must mark all the occupied and used slots. +First of all, check the LUKS key slot for the user passphrase. Run the followings command. +```shell +cryptsetup -v --test-passphrase luksOpen /dev/sdXN +``` +Where X is a, b, c..., N is 1, 2, 3... + +The command will prompt to type the passphrase to decrypt. If the user types the correct passphrase, the command shows the key slot number of that passphrase. The followings are the example : +``` +takemasa@mate-vm:~$ sudo cryptsetup -v --test-passphrase luksOpen /dev/sda2 +Enter passphrase for /dev/sda2: +Key slot 0 unlocked. +Command successful. +``` +We can see the slot 0 is used. + +Next, run the following command **for each** installation of distribution. This command shows the slot number which stores the key of the passphrase file passing to the kernel. /etc/luks/boot_os.keyfile is created by Kaiten-yaki, during the installation + +```shell +sudo cryptsetup -v --test-passphrase luksOpen /dev/sdXN --key-file /etc/luks/boot_os.keyfile +``` +Followings are the sample execution : +``` +takemasa@mate-vm:~$ sudo cryptsetup -v --test-passphrase luksOpen /dev/sda2 --key-file /etc/luks/boot_os.keyfile +Key slot 2 unlocked. +Command successful. +``` +By repeating this command inside all installations, the user can list up the occupied and used slots. The other slots are occupied but not used. + +Finally, the user can delete the appropriate occupied but not used LUKS key slot by the following command. +```shell +sudo cryptsetup luksKillSlot /dev/sdXN key_slot_number_to_delete +``` +# Conclusion +For the typical case like installing 2 or 3 distributions in a system, there is no problem to use Kaiten-yaki, at all. + +But if users want to install as many as possible, or repeat the overwrite install, they must understand the number of the LUKS key slots. \ No newline at end of file From fe7a4a1439d855d82f36108f833e6b9f59570d14 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sat, 10 Jul 2021 22:21:39 +0900 Subject: [PATCH 38/48] Add AN02 to README --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4fc481d..9e75a32 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,8 @@ If you install two or more Void Linux into the EFI system, only the last one can Ubuntu has several variants ( flavors ). While while only the MATE flavor is tested, other flavors may work correctly as far as it uses Ubiquity installer. # Application notes -- [AP01 : How to recover from the mistyping of the passphrase](appnote/an01_howtorecover.md) +- [AN01 : How to recover from the mistyping of the passphrase](appnote/an01_howtorecover.md) +- [AN02 : Managing LUKS key slots](appnote/an02_keyslot.md) # Acknowledgments These scripts are based on the script by [myn's diary](https://myn.hatenablog.jp/entry/install-ubuntu-focal-with-lvm-on-luks). That page contains rich information, hint, and techniques around the encrypted volume and Ubiquity installer. From 75d7a7ccc357151d7243c9a945e2b22ac4ca1507 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sun, 11 Jul 2021 10:34:27 +0900 Subject: [PATCH 39/48] ADD AN03 itertime Add a consideration of LUKS stretching Issue #20 --- README.md | 1 + appnote/an02_keyslot.md | 2 +- appnote/an03_itertime.md | 48 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 appnote/an03_itertime.md diff --git a/README.md b/README.md index 9e75a32..3002494 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,7 @@ Ubuntu has several variants ( flavors ). While while only the MATE flavor is tes # Application notes - [AN01 : How to recover from the mistyping of the passphrase](appnote/an01_howtorecover.md) - [AN02 : Managing LUKS key slots](appnote/an02_keyslot.md) +- [AN03 : The ITERTIME parameter and vulnerability](appnote/an03_itertime.md) # Acknowledgments These scripts are based on the script by [myn's diary](https://myn.hatenablog.jp/entry/install-ubuntu-focal-with-lvm-on-luks). That page contains rich information, hint, and techniques around the encrypted volume and Ubiquity installer. diff --git a/appnote/an02_keyslot.md b/appnote/an02_keyslot.md index 74766c6..2b04fc4 100644 --- a/appnote/an02_keyslot.md +++ b/appnote/an02_keyslot.md @@ -1,4 +1,4 @@ -# Managing LUKS key slots +# AN02 Managing LUKS key slots If somebody wants to install two or three distributions into a system, Kaiten-yaki works perfectly. There is no problem at all. On the other hand, some extreme cases like installing distributions as many as possible, or repeating the overwrite installation unveils the limitation of the number of the LUKS key slots. The user must understand and must manage the LUKS key slots well, to handle these cases. diff --git a/appnote/an03_itertime.md b/appnote/an03_itertime.md new file mode 100644 index 0000000..7145cca --- /dev/null +++ b/appnote/an03_itertime.md @@ -0,0 +1,48 @@ +# AN03 The ITERTIME parameter and vulnerability +The ITERTIME configuration parameter in the config.sh can provide a better user experience during the passphrase input. It can reduce the pain of the longer passphrase and encourage users to use longer passphrases. + +On the other hand, it may pull a vulnerability. + +The followings are the consideration around the ITERTIME parameter. + +## The passphrase experience +Let's assume there is a Ubuntu desktop system in which the disk was encrypted by Ubiquity installer without Kaiten-yaki. In this system, the /boot partition is installed as a separate and un-encrypted state. So, the Linux kernel file is not protected. + +If the user mistyped the passphrase at boot, Ubuntu prompts to type a passphrase again. There is no pain. It just asks. + +Now, what's happen if a user mistyped the passphrase on the Kaiten-yaki installed system. It takes a very wrong time to see the error message. And the system doesn't prompt to type again ( The prompt issue is discussed in the [AN01](an01_howtorecover.md) ). Especially, the more number of the installations in a system makes the longer duration till the error message. Sometimes this is unbearable pain to the user. + +This kind of pain de-motivates users to use a long passphrase, because the longer passphrase causes more mistypes. As a result, some users may use the shorter passphrase. The bad user experience of passphrase input may help the malicious attackers. + +## Why the full disk encryption is so slow at passphrase input +GRUB is the root cause of this slow user passphrase matching. + +The passphrase is hashed and stored to LUKS key slot when a LUKS volume is created ( or, a new passphrase is added ). The stored hash value is not simple. The cryptsetup command makes hash value from the user passphrase. And then, create the next hash from this hash. And then, create a third hash from the 2nd hash, so on. This repeating is named [key stretching](https://en.wikipedia.org/wiki/Key_stretching). + +The key stretching technique enforces malicious attackers using more computation resources on the brute force attacking. The more stretching iteration times require the more resources to attack. + +Of course, there is a balance and security strength. By default, the cryptsetup command takes the iteration needing 1 sect to calculate the passphrase hash, for the LUKS1 format. This sounds like a good balance. The cryptsetup runs on Linux when it calculates the appropriate iteration of key stretching. So, there is no problem if Linux challenges user passwords. It will take about 1 sec, by default. + +But there is a pitfall. On the full disk encryption system by Kaiten-yaki, the /boot is encrypted. So, to load the Linux kernel, GRUB has to decrypt the LUKS volume. That means GRUB has to calculate the passphrase hash. Unfortunately, this calculation is slower than Linux's one. Thus the user has to wait longer than 1 second. + +The duration by GRUB is up to the system. It depends on the CPU. Also, In addition to this slow hashing, GRUB has to scan all used key slots when the user mistyped. For example, if 3 distributions are installed in a LUKS volume by Kaiten-yaki, 4 key slots are used. Thus, if it takes 10 seconds to challenged one hash by GRUB, this system takes 40seconds to show "The wrong password". + +This is the mechanism of the slow response at the passphrase input. +## The key stretching, the --iter-time parameter, and the vulnerability +Kaiten-yaki can relax this pain by ITERTIME configuration parameter in config.sh. This parameter is passed to the cryptsetup command as --iter-time parameter. + +By setting 1000 to the ITERTIME, cryptsetup takes the key stretching iteration cycle to take 1000 milliseconds. By setting 100, it will be 100 milliseconds. It is believed the default value of --iter-time is 1000 ( Its compile default ). Thus, choosing 100 as ITERTIME makes the duration to the "Wrong password" 4 seconds, in the above example. This sounds acceptable. + +On the other hand, the smaller ITERTIME is the weaker to the bute force attack. It is assumed the strength of the passphrase hash is linear to the ITERTIME parameter ( --iter-time parameter of cryptsetup ). + +## The longer passphrase vs. longer key stretching +While the passphrase hash strength is considered linear to the key stretching iteration, the passphrase strength is exponential to its length. + +There many discussions on the strength of the passphrase. Simply speaking, Adding one alphabet ( a-z ) may expand its strength 26 times. That is why the long passphrase is very important. + +The 1/10 strength of the key stretching can be covered by adding 1 character to the passphrase. + +## Conclusion +The full disk encryption will give big pain to the user at the passphrase input phase. It seems to be reasonable to use the smaller ITERTIME ( --iter-time ) parameter to encourage the user to use the longer passphrase like 20 letters, from the viewpoint of security. + +The security policy is up to the people, community, and mission. The consideration here assumed the desktop PC as a hobby. For mission-critical usage, the user should consult security experts. \ No newline at end of file From 1e3eb8943f11c7dcf81f7e0b5d756ed071a7171b Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sun, 11 Jul 2021 10:39:46 +0900 Subject: [PATCH 40/48] Update changelog. --- CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index af2b381..6029898 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,10 @@ Record of the modification in project development. ## [Unreleased] - yyyy-mm-dd ### Added -- [Issue 13 : Add ITERTIME configuration parameter to config.txt #13](https://github.com/suikan4github/kaiten-yaki/issues/13) +- [Issue 13 : Add ITERTIME configuration parameter to config.txt](https://github.com/suikan4github/kaiten-yaki/issues/13) +- [Issue 18 : Add a consideration of the number of key slot](https://github.com/suikan4github/kaiten-yaki/issues/18) +- [Issue 20 : Add a consideration of LUKS stretching](https://github.com/suikan4github/kaiten-yaki/issues/20) +- [Issue 21 : Add a document of how to recover from the mistyping of passphrase](https://github.com/suikan4github/kaiten-yaki/issues/21) ### Changed - [Issue 5 : OVERWRITEINSTALL confirmation is missing](https://github.com/suikan4github/kaiten-yaki/issues/5) From aaa5609a9a90353a0b5bf43fefdc1c4c6fc8bc6e Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sun, 11 Jul 2021 10:41:06 +0900 Subject: [PATCH 41/48] Add number to the title --- appnote/an01_howtorecover.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appnote/an01_howtorecover.md b/appnote/an01_howtorecover.md index c715be6..c7645af 100644 --- a/appnote/an01_howtorecover.md +++ b/appnote/an01_howtorecover.md @@ -1,4 +1,4 @@ -# How to recover from the mistyping of the passphrase +# AN01 : How to recover from the mistyping of the passphrase The mistyping of the passphrase is painful, in the full disk encrypted Linux. In the usual encrypted Ubuntu install by Ubiquity, mistyping os passphrase is warn by the kernel, and prompted to re-type. But in the full encrypted system, the user sees a boring message and command prompt. Usually, the user just gives up and reboot. It adds tens of second to reboot, and discourage the under to use a long passphrase. From f6033433ad55e0ba4d9ffb5ce80018bbba4681a1 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sun, 11 Jul 2021 12:51:21 +0900 Subject: [PATCH 42/48] Add AN04 partition Add a considration of more flexible partitionning Issue #19 --- INSTALL.md | 2 +- appnote/an02_keyslot.md | 6 ++--- appnote/an04_favoritepartition.md | 43 +++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 4 deletions(-) create mode 100644 appnote/an04_favoritepartition.md diff --git a/INSTALL.md b/INSTALL.md index e19f912..dcf3c30 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -6,7 +6,7 @@ Installation requires mainly 2 steps. - Run the kaiten-yaki script You can execute the install script without the command line parameter. For example : -```shell +```sh source ubuntu-kaiten-yaki.sh ``` The first stage of the script is preparation like: erasing a disk, format partition, and encryption. This is the most critical stage of the entire installation process. This part is controlled by the configuration parameter. Thus, you have to edit the config.txt carefully. diff --git a/appnote/an02_keyslot.md b/appnote/an02_keyslot.md index 2b04fc4..3cd0a28 100644 --- a/appnote/an02_keyslot.md +++ b/appnote/an02_keyslot.md @@ -47,7 +47,7 @@ Key Slot 7: DISABLED If there is still a vacant LUKS key slot, the user can install another distribution without deleting the existing slot. But if there is not vacant LUKS key slot at all, the user must delete an occupied but unused slot. To know such a slot, the user must mark all the occupied and used slots. First of all, check the LUKS key slot for the user passphrase. Run the followings command. -```shell +```sh cryptsetup -v --test-passphrase luksOpen /dev/sdXN ``` Where X is a, b, c..., N is 1, 2, 3... @@ -63,7 +63,7 @@ We can see the slot 0 is used. Next, run the following command **for each** installation of distribution. This command shows the slot number which stores the key of the passphrase file passing to the kernel. /etc/luks/boot_os.keyfile is created by Kaiten-yaki, during the installation -```shell +```sh sudo cryptsetup -v --test-passphrase luksOpen /dev/sdXN --key-file /etc/luks/boot_os.keyfile ``` Followings are the sample execution : @@ -75,7 +75,7 @@ Command successful. By repeating this command inside all installations, the user can list up the occupied and used slots. The other slots are occupied but not used. Finally, the user can delete the appropriate occupied but not used LUKS key slot by the following command. -```shell +```sh sudo cryptsetup luksKillSlot /dev/sdXN key_slot_number_to_delete ``` # Conclusion diff --git a/appnote/an04_favoritepartition.md b/appnote/an04_favoritepartition.md new file mode 100644 index 0000000..701c49c --- /dev/null +++ b/appnote/an04_favoritepartition.md @@ -0,0 +1,43 @@ +# AN04 How to make LUKS volume to the favorite partition +Kaiten-yaki creates the LUKS volume on the 1st partition for the BIOS system ( 2nd partition for the UEFI system ) by default. Also, Kaiten-yaki assigns all space for the LUKS volume, except the space for the EFI partition. + +This application note explains how to use the favorite partition with favorite size for LUKS volume. + +## Step 1: Making partitions +To use custom partitioning, the user must create all partitions by themselves. The user can do it with the popular partitioning tool like gparted. It is recommended to set the partition table as MBR and GPT for BIOS and UEFI systems, respectively. + +In this documentation, we assume the user wants to use /dev/sdb3 as LUKS partition to install Ubuntu. +## Step 2: Configuration +Next user must configure the config.sh. + +The first parameter to edit is **DEV** parameter which represents the target device. In this example, it must be set as /dev/sdb. +```sh +export DEV="/dev/sdb" +``` +The second parameter to edit is **CRYPTPARTITION**. By default, this parameter is set automatically according to the firmware type. The EFIPARTITION parameter can be left untouched. This parameter is not used. +```sh +if [ ${ISEFI} -ne 0 ] ; then +# EFI firmware +export EFIPARTITION=1 +export CRYPTPARTITION=3 +else +# BIOS firmware +export CRYPTPARTITION=3 +fi # EFI firmware +``` +Makes sure the **ERASEALL** and **OVERWRITEINSTALL** are 0. +## Step 3: Make LUKS partition +After saving the customer config.sh, run the following command to set the environment variable. +```sh +source config.sh +``` +Then, run the following command to create a LUKS volume. +```sh +cryptsetup luksFormat --iter-time "${ITERTIME}" --type=luks1 --key-file "${DEV}${CRYPTPARTITION}" +``` +This command sets up the LUKS volume on the specified partition. This command also asks for the passphrase of this LUKS volume. +## Step 4: Run Kaiten-yaki +Now, it's a time to run Kaiten-yaki +```sh +kaiten-yaki-ubuntu +``` \ No newline at end of file From e3d957c4be8c40de8028654f7525ab7cf968aab2 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sun, 11 Jul 2021 12:54:34 +0900 Subject: [PATCH 43/48] Corrected spell. --- INSTALL.md | 4 ++-- appnote/an04_favoritepartition.md | 4 ++-- script/config.sh | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index dcf3c30..b0b01bd 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -76,13 +76,13 @@ export EFISIZE="200M" export LVSWAPSIZE="8G" # Usually, these names can be left untouched. -# If you change, keep them consistent through all instllation in your system. +# If you change, keep them consistent through all installation in your system. export CRYPTPARTNAME="luks_volume" export VGNAME="vg1" export LVSWAPNAME="swap" # Do not touch this parameter, unless you understand what you are doing. -# 1 : Overwrite the existing logical volume as root vlume. +# 1 : Overwrite the existing logical volume as root volume. # 0 : Create new logical volume as root volume. export OVERWRITEINSTALL=0 diff --git a/appnote/an04_favoritepartition.md b/appnote/an04_favoritepartition.md index 701c49c..0335198 100644 --- a/appnote/an04_favoritepartition.md +++ b/appnote/an04_favoritepartition.md @@ -1,10 +1,10 @@ # AN04 How to make LUKS volume to the favorite partition -Kaiten-yaki creates the LUKS volume on the 1st partition for the BIOS system ( 2nd partition for the UEFI system ) by default. Also, Kaiten-yaki assigns all space for the LUKS volume, except the space for the EFI partition. +Kaiten-yaki creates the LUKS volume on the 1st partition for the BIOS system ( 2nd partition for the EFI system ) by default. Also, Kaiten-yaki assigns all space for the LUKS volume, except the space for the EFI partition. This application note explains how to use the favorite partition with favorite size for LUKS volume. ## Step 1: Making partitions -To use custom partitioning, the user must create all partitions by themselves. The user can do it with the popular partitioning tool like gparted. It is recommended to set the partition table as MBR and GPT for BIOS and UEFI systems, respectively. +To use custom partitioning, the user must create all partitions by themselves. The user can do it with the popular partitioning tool like gparted. It is recommended to set the partition table as MBR and GPT for BIOS and EFI systems, respectively. In this documentation, we assume the user wants to use /dev/sdb3 as LUKS partition to install Ubuntu. ## Step 2: Configuration diff --git a/script/config.sh b/script/config.sh index 7e79a78..bb378c0 100644 --- a/script/config.sh +++ b/script/config.sh @@ -26,13 +26,13 @@ export EFISIZE="200M" export LVSWAPSIZE="8G" # Usually, these names can be left untouched. -# If you change, keep them consistent through all instllation in your system. +# If you change, keep them consistent through all installation in your system. export CRYPTPARTNAME="luks_volume" export VGNAME="vg1" export LVSWAPNAME="swap" # Do not touch this parameter, unless you understand what you are doing. -# 1 : Overwrite the existing logical volume as root vlume. +# 1 : Overwrite the existing logical volume as root volume. # 0 : Create new logical volume as root volume. export OVERWRITEINSTALL=0 From a79ad35fe0e0a089f3233c856b5c7111562d9d68 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sun, 11 Jul 2021 13:52:09 +0900 Subject: [PATCH 44/48] Correct the AN04 based on the experiment --- appnote/an04_favoritepartition.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/appnote/an04_favoritepartition.md b/appnote/an04_favoritepartition.md index 0335198..b81f96d 100644 --- a/appnote/an04_favoritepartition.md +++ b/appnote/an04_favoritepartition.md @@ -6,23 +6,23 @@ This application note explains how to use the favorite partition with favorite s ## Step 1: Making partitions To use custom partitioning, the user must create all partitions by themselves. The user can do it with the popular partitioning tool like gparted. It is recommended to set the partition table as MBR and GPT for BIOS and EFI systems, respectively. -In this documentation, we assume the user wants to use /dev/sdb3 as LUKS partition to install Ubuntu. +In this documentation, we assume the user wants to use /dev/sda5 as LUKS partition to install Ubuntu. ## Step 2: Configuration Next user must configure the config.sh. The first parameter to edit is **DEV** parameter which represents the target device. In this example, it must be set as /dev/sdb. ```sh -export DEV="/dev/sdb" +export DEV="/dev/sda" ``` The second parameter to edit is **CRYPTPARTITION**. By default, this parameter is set automatically according to the firmware type. The EFIPARTITION parameter can be left untouched. This parameter is not used. ```sh if [ ${ISEFI} -ne 0 ] ; then # EFI firmware export EFIPARTITION=1 -export CRYPTPARTITION=3 +export CRYPTPARTITION=5 else # BIOS firmware -export CRYPTPARTITION=3 +export CRYPTPARTITION=5 fi # EFI firmware ``` Makes sure the **ERASEALL** and **OVERWRITEINSTALL** are 0. @@ -33,11 +33,11 @@ source config.sh ``` Then, run the following command to create a LUKS volume. ```sh -cryptsetup luksFormat --iter-time "${ITERTIME}" --type=luks1 --key-file "${DEV}${CRYPTPARTITION}" +cryptsetup luksFormat --iter-time "${ITERTIME}" --type=luks1 "${DEV}${CRYPTPARTITION}" ``` This command sets up the LUKS volume on the specified partition. This command also asks for the passphrase of this LUKS volume. ## Step 4: Run Kaiten-yaki Now, it's a time to run Kaiten-yaki ```sh -kaiten-yaki-ubuntu +source kaiten-yaki-ubuntu ``` \ No newline at end of file From f1ad8ae660caabd9b9b339f7ba0c40282306fe8a Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sun, 11 Jul 2021 13:59:42 +0900 Subject: [PATCH 45/48] Add AN04 to README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 3002494..b22dc3a 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,7 @@ Ubuntu has several variants ( flavors ). While while only the MATE flavor is tes - [AN01 : How to recover from the mistyping of the passphrase](appnote/an01_howtorecover.md) - [AN02 : Managing LUKS key slots](appnote/an02_keyslot.md) - [AN03 : The ITERTIME parameter and vulnerability](appnote/an03_itertime.md) +- [AN04 : How to make LUKS volume to the favorite partition](appnote/an04_favoritepartition.md) # Acknowledgments These scripts are based on the script by [myn's diary](https://myn.hatenablog.jp/entry/install-ubuntu-focal-with-lvm-on-luks). That page contains rich information, hint, and techniques around the encrypted volume and Ubiquity installer. From 40972cebaf3b832f51963437b5c227f0bcfb5ec3 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sun, 11 Jul 2021 14:31:21 +0900 Subject: [PATCH 46/48] Update the documentation --- appnote/an01_howtorecover.md | 14 +++++++------- appnote/an02_keyslot.md | 13 ++++++------- appnote/an03_itertime.md | 10 +++++----- appnote/an04_favoritepartition.md | 7 ++++--- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/appnote/an01_howtorecover.md b/appnote/an01_howtorecover.md index c7645af..6cc3b9a 100644 --- a/appnote/an01_howtorecover.md +++ b/appnote/an01_howtorecover.md @@ -1,7 +1,7 @@ # AN01 : How to recover from the mistyping of the passphrase The mistyping of the passphrase is painful, in the full disk encrypted Linux. -In the usual encrypted Ubuntu install by Ubiquity, mistyping os passphrase is warn by the kernel, and prompted to re-type. But in the full encrypted system, the user sees a boring message and command prompt. Usually, the user just gives up and reboot. It adds tens of second to reboot, and discourage the under to use a long passphrase. +In the usual encrypted Ubuntu install by Ubiquity, mistyping disk passphrase is warned by the kernel, and prompted to re-type. But in the full encrypted system, the user sees a boring message and command prompt. Usually, the user just gives up and reboot. It adds tens of second to reboot, and discourage the user to use a long passphrase. ![bios](../image/an01_bios.png) @@ -10,7 +10,7 @@ This application note explains how to recover from this condition, quickly. # BIOS system In the BIOS system, the recovery is pretty easy. -In the case of the mistyping passphrase, GRUB goes into rescue mode. In this mode, the user can recover from 3 commands. +In the case of the mistyping passphrase, GRUB goes into rescue mode. The user can recover by 3 commands from this mode. ``` cryptomount -a @@ -18,9 +18,9 @@ insmod normal normal ``` -The **cryptomount** command tries to mount the specific encrypted partition to boot. To mount it, the GRUB prompts the user to type the passphrase. The "-a" option specifies all encrypted partitions. If the system is encrypted by Kaiten-yaki, it has only one encrypted partition. So, this is the easiest way. +The **cryptomount** command tries to mount the encrypted partition specified by parameter. To mount it, GRUB prompts the user to type the passphrase. The "-a" option means all encrypted partitions. If the system is encrypted by Kaiten-yaki, it has only one encrypted LUKS partition. So, this is the easiest way. -The **insmod** command loads the specified GRUB command module from the mounted storage and inserts it into the command list. The second line loads the "normal" command which displays the normal menu to the user. +The **insmod** command loads a GRUB command module from the mounted storage and inserts it into the command list. The second line loads the "normal" command which displays the normal menu to the user. Finally, **normal** command shows the normal boot menu to the user. @@ -29,7 +29,7 @@ Now, the user can select the system to boot as usual. # EFI system In the EFI system, recovery needs extra steps compared to the BIOS system. -Alternatively, GURB is not in the rescue mode but the normal mode, even the passphrase is mistyped. So, the user can use command completion. This is better than the BIOS system. +Unlike the BIOS system, GURB is not in the rescue mode but the normal mode, when the passphrase is mistyped. So, the user can use command completion. This is better than the BIOS system. The first step of the recovery is the same with the BIOS system. ``` @@ -37,7 +37,7 @@ cryptomount -a ``` Again, in the EFI system, the user can use the command completion by pressing the [TAB] key. -The second step is unique in the EFI system. By using **ls** command check the list of volumes existing in the system, and identify which volume contains the grub menu. And then, pick that volume and assign it to the **prefix** variable, with grub path. +The second step is unique in the EFI system. The user can check the list of volumes existing in the system by **ls** command. The ls command allows the user can identify which volume contains the grub menu. And then, the user picks the right volume and assign it to the **prefix** variable, with the grub path. Following is the example. The (lvm/vg1-mate) is dependent on the system. It has to be substituted by the appropriate volume name for each system. @@ -56,7 +56,7 @@ Following is the screenshot of the command sequence to recover the mistyping of ![bios](../image/an01_efi.png) -## Summary +## Conclusion In the full disk encrypted system, mistyping of the passphrase is more painful than the partially encrypted system. The user can overcome this situation with several steps of commands and can show the normal boot menu. ![bios](../image/an01_normal.png) diff --git a/appnote/an02_keyslot.md b/appnote/an02_keyslot.md index 3cd0a28..525554f 100644 --- a/appnote/an02_keyslot.md +++ b/appnote/an02_keyslot.md @@ -6,18 +6,18 @@ On the other hand, some extreme cases like installing distributions as many as p This application note explains the limitations and difficulties that come from the number of LUKS key slots, and how to overcome that limitation( if possible ). # The LUKS key slots -The LUKS volume has 8 key slots. That means, up to 8 key hash values can be stored. In other words, the user can use 8 different keys to open a LUKS volume. +The LUKS volume has 8 key slots which can stores one key hash value. In other words, the user can use 8 different keys to open a LUKS volume. In this context, the "user" is not limited to a human being. Any software can use a passphrase to open a LUKS volume. Thus, even only one person uses a computer, multiple key slots may be used. -If some user ( or software ) feeds a passphrase to open a LUKS volume, the management software ( dm-crypt library ) scans key slots and check whether there is a matching slot or not. If there is a slot in which the stored hash value matches with the hash value of the given passphrase, that passphrase is the right one. +If an user ( or software ) feeds a passphrase to open a LUKS volume, the management software ( dm-crypt library ) scans key slots and check whether there is a matching slot or not. If there is a slot in which the stored hash value matches with the hash value of the given passphrase, that passphrase is the right one. # How Kaiten-yaki uses the LUKS key slots Kaiten-yaki uses N+1 LUKS key slots to install the N distributions in a system ( where N is an integer ). -Whenever Kaiten-yaki creates a LUKS volume, it registers a passphrase typed by the user. This passphrase is stored in the key slot 0. So, when the user types his passphrase correctly, its hash will be matched with the hash value in slot 0, by default. +Whenever Kaiten-yaki creates a LUKS volume, it registers a passphrase typed by the user. This passphrase is stored in the key slot 0. So, when the user types his passphrase correctly at boot time, its hash will be matched with the hash value in slot 0, by default. -In addition to the user passphrase, Kaiten-yaki uses one key slot to register the passphrase to open the LUKS volume from the Linux kernel. This passphrase is different from the user passphrase. This passphrase is random binary brock generated by /dev/random. This key is stored in the file under /etc/luks. Even somebody watches its value over the shoulder, the risk is small because it is difficult to ready for a human being. +In addition to the user passphrase, Kaiten-yaki uses one key slot to register the passphrase to let the Linux kernel open the LUKS volume. This passphrase is different from the user passphrase. Actually, this passphrase is random binary brock generated by /dev/random. This key is stored in the file under /etc/luks. Even somebody watches its value over the shoulder of a user, the risk is small because it is difficult to read for a human being. Anyway, this usage defines the maximum number of Linux installed in a system. That is 7 if all are installed by Kaiten-yaki. If a user try to install the 8th distribution in a LUKS volume with Kaiten-yaki, it will fail because there is no vacant LUKS key slot. # Overwrite installation @@ -25,14 +25,13 @@ The overwrite installation is another case that consumes a LUKS key slot. if the variable OVERWITEINSTALL in config.sh is set to 1, Kaiten-yaki just overwrites an existing logical volume in the LUKS volume. Also, in this case, Kaiten-yaki registers a new key file for the new installation. Thus, while the number of the installed Linux is the same, the number of the used LUKS key slot is increased. -Eventually, the user fails to install even the installed Linux is 2 or 3, if there is not vacant LUKS key slot. +Eventually, the user fails to install even the installed Linux is small like 2 or 3, if there is not vacant LUKS key slot. # Managing key slots Some users may want to delete a key slot to install another distribution. In this case, they must know which LUKS key slots are used or not. This section explains how to investigate the used slots. -First of all, user can l -The example of this command is shown below. Slot 0, 1, and 2 are occupied : +First of all, user can list the status of the all LUKS key slots. The example of this command is shown below. Slot 0, 1, and 2 are occupied : ``` takemasa@mate-vm:~$ sudo cryptsetup luksDump /dev/sda2 | grep -i bled Key Slot 0: ENABLED diff --git a/appnote/an03_itertime.md b/appnote/an03_itertime.md index 7145cca..2d440a8 100644 --- a/appnote/an03_itertime.md +++ b/appnote/an03_itertime.md @@ -10,7 +10,7 @@ Let's assume there is a Ubuntu desktop system in which the disk was encrypted by If the user mistyped the passphrase at boot, Ubuntu prompts to type a passphrase again. There is no pain. It just asks. -Now, what's happen if a user mistyped the passphrase on the Kaiten-yaki installed system. It takes a very wrong time to see the error message. And the system doesn't prompt to type again ( The prompt issue is discussed in the [AN01](an01_howtorecover.md) ). Especially, the more number of the installations in a system makes the longer duration till the error message. Sometimes this is unbearable pain to the user. +Now, let's see what's happen if a user mistyped the passphrase on the system which was installed by Kaiten-yaki. It takes a very wrong time to see the error message. And the system doesn't prompt to type again ( The prompt issue is discussed in the [AN01](an01_howtorecover.md) ). Especially, the more number of the installations in a system makes the longer duration till the error message. Sometimes this is unbearable pain to the user. This kind of pain de-motivates users to use a long passphrase, because the longer passphrase causes more mistypes. As a result, some users may use the shorter passphrase. The bad user experience of passphrase input may help the malicious attackers. @@ -19,19 +19,19 @@ GRUB is the root cause of this slow user passphrase matching. The passphrase is hashed and stored to LUKS key slot when a LUKS volume is created ( or, a new passphrase is added ). The stored hash value is not simple. The cryptsetup command makes hash value from the user passphrase. And then, create the next hash from this hash. And then, create a third hash from the 2nd hash, so on. This repeating is named [key stretching](https://en.wikipedia.org/wiki/Key_stretching). -The key stretching technique enforces malicious attackers using more computation resources on the brute force attacking. The more stretching iteration times require the more resources to attack. +The key stretching technique enforces malicious attackers to use more computation resources on the brute force attacking. The more stretching iteration times require the more resources to attack. -Of course, there is a balance and security strength. By default, the cryptsetup command takes the iteration needing 1 sect to calculate the passphrase hash, for the LUKS1 format. This sounds like a good balance. The cryptsetup runs on Linux when it calculates the appropriate iteration of key stretching. So, there is no problem if Linux challenges user passwords. It will take about 1 sec, by default. +Of course, there is a balance and security strength. By default, the cryptsetup command takes the iteration needing 1 sect to calculate the passphrase hash, for the LUKS1 format. This sounds like a good balance. The cryptsetup runs on Linux when it calculates the appropriate iteration of key stretching. So, there is no problem if Linux challenges user passwords. It will take about 1 sec, by default on the Linux system. 1 second is acceptable for almost users. But there is a pitfall. On the full disk encryption system by Kaiten-yaki, the /boot is encrypted. So, to load the Linux kernel, GRUB has to decrypt the LUKS volume. That means GRUB has to calculate the passphrase hash. Unfortunately, this calculation is slower than Linux's one. Thus the user has to wait longer than 1 second. -The duration by GRUB is up to the system. It depends on the CPU. Also, In addition to this slow hashing, GRUB has to scan all used key slots when the user mistyped. For example, if 3 distributions are installed in a LUKS volume by Kaiten-yaki, 4 key slots are used. Thus, if it takes 10 seconds to challenged one hash by GRUB, this system takes 40seconds to show "The wrong password". +The duration by GRUB to calculate the passphrase hash value is up to the system. It depends on the CPU. Also, In addition to this slow hashing, GRUB has to scan all used key slots when the user mistyped. For example, if 3 distributions are installed in a LUKS volume by Kaiten-yaki, 4 key slots are used. Thus, if it takes 10 seconds to challenged one hash by GRUB, this system takes 40seconds to show "The wrong password". This is the mechanism of the slow response at the passphrase input. ## The key stretching, the --iter-time parameter, and the vulnerability Kaiten-yaki can relax this pain by ITERTIME configuration parameter in config.sh. This parameter is passed to the cryptsetup command as --iter-time parameter. -By setting 1000 to the ITERTIME, cryptsetup takes the key stretching iteration cycle to take 1000 milliseconds. By setting 100, it will be 100 milliseconds. It is believed the default value of --iter-time is 1000 ( Its compile default ). Thus, choosing 100 as ITERTIME makes the duration to the "Wrong password" 4 seconds, in the above example. This sounds acceptable. +By setting 1000 to the ITERTIME, cryptsetup takes the key stretching iteration cycle to take 1000 milliseconds. By setting 100, it will be 100 milliseconds. It is believed the default value of --iter-time is 1000 ( Its compile default ). Thus, choosing 100 as ITERTIME shorten the duration to the "Wrong password" from 40 seconds to 4 seconds, in the above example. This sounds acceptable. On the other hand, the smaller ITERTIME is the weaker to the bute force attack. It is assumed the strength of the passphrase hash is linear to the ITERTIME parameter ( --iter-time parameter of cryptsetup ). diff --git a/appnote/an04_favoritepartition.md b/appnote/an04_favoritepartition.md index b81f96d..8ef4b61 100644 --- a/appnote/an04_favoritepartition.md +++ b/appnote/an04_favoritepartition.md @@ -6,11 +6,11 @@ This application note explains how to use the favorite partition with favorite s ## Step 1: Making partitions To use custom partitioning, the user must create all partitions by themselves. The user can do it with the popular partitioning tool like gparted. It is recommended to set the partition table as MBR and GPT for BIOS and EFI systems, respectively. -In this documentation, we assume the user wants to use /dev/sda5 as LUKS partition to install Ubuntu. +In this documentation, we assume the user wants to use /dev/sda5 as LUKS partition to install Ubuntu, as example. ## Step 2: Configuration Next user must configure the config.sh. -The first parameter to edit is **DEV** parameter which represents the target device. In this example, it must be set as /dev/sdb. +The first parameter to edit is **DEV** parameter which represents the target device. In this example, it must be set as /dev/sda. ```sh export DEV="/dev/sda" ``` @@ -40,4 +40,5 @@ This command sets up the LUKS volume on the specified partition. This command al Now, it's a time to run Kaiten-yaki ```sh source kaiten-yaki-ubuntu -``` \ No newline at end of file +``` +All other operations are same with usual install. \ No newline at end of file From ac70e126d83c4e0353bd201007977dbc557ed904 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sun, 11 Jul 2021 14:39:17 +0900 Subject: [PATCH 47/48] Update changelog --- CHANGELOG.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6029898..6169074 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,10 +2,19 @@ Record of the modification in project development. ## [Unreleased] - yyyy-mm-dd - +Added ITERTIME parameter and corrected other small issues. Application notes AN01-04 are added. +The Followings are tested distributions +- Ubuntu 20.04.2 +- Ubuntu MATE 20.04.2 +- Ubuntu 21.04 +- Void Linux glibc 20210218 mate +- Void Linux musl 20210218 mate +- VOid Linux glibc 20210218 base +See [Testing before release v1.1.0](https://github.com/suikan4github/kaiten-yaki/issues/16). ### Added - [Issue 13 : Add ITERTIME configuration parameter to config.txt](https://github.com/suikan4github/kaiten-yaki/issues/13) - [Issue 18 : Add a consideration of the number of key slot](https://github.com/suikan4github/kaiten-yaki/issues/18) +- [Issue 19 : Add a consideration of more flexible partitioning](https://github.com/suikan4github/kaiten-yaki/issues/19) - [Issue 20 : Add a consideration of LUKS stretching](https://github.com/suikan4github/kaiten-yaki/issues/20) - [Issue 21 : Add a document of how to recover from the mistyping of passphrase](https://github.com/suikan4github/kaiten-yaki/issues/21) From 456cbf87cde9d771e90a833595bd4a96980f9306 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sun, 11 Jul 2021 15:53:46 +0900 Subject: [PATCH 48/48] Update changelog for v1.1.0 --- CHANGELOG.md | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6169074..4e4e18d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,14 +2,23 @@ Record of the modification in project development. ## [Unreleased] - yyyy-mm-dd -Added ITERTIME parameter and corrected other small issues. Application notes AN01-04 are added. +### Added +### Changed +### Deprecated +### Removed +### Fixed +### Known Issue + +## [1.1.0] - 2021-07-11 +Added ITERTIME parameter and corrected other small issues. Application notes AN01 - AN04 are added. The Followings are tested distributions - Ubuntu 20.04.2 - Ubuntu MATE 20.04.2 - Ubuntu 21.04 - Void Linux glibc 20210218 mate - Void Linux musl 20210218 mate -- VOid Linux glibc 20210218 base +- Void Linux glibc 20210218 base + See [Testing before release v1.1.0](https://github.com/suikan4github/kaiten-yaki/issues/16). ### Added - [Issue 13 : Add ITERTIME configuration parameter to config.txt](https://github.com/suikan4github/kaiten-yaki/issues/13) @@ -48,5 +57,6 @@ See [Testing before release v1.1.0](https://github.com/suikan4github/kaiten-yaki ### Known Issue -[Unreleased]: https://github.com/suikan4github/kaiten-yaki/compare/v1.0.0...develop +[Unreleased]: https://github.com/suikan4github/kaiten-yaki/compare/v1.1.0...develop +[1.1.0]: https://github.com/suikan4github/kaiten-yaki/compare/v1.0.0...v1.1.0 [1.0.0]: https://github.com/suikan4github/kaiten-yaki/compare/v0.0.0...v1.0.0