From f0f081ad34eef12edfa858bc1042d4bf3cad4f19 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sat, 7 May 2022 21:05:47 +0900 Subject: [PATCH 1/4] Modify to accespt the absolute volume size. --- script/config.sh | 26 +++++++++++++++++--------- script/lib/common.sh | 26 ++++++++++++++++++++++---- 2 files changed, 39 insertions(+), 13 deletions(-) diff --git a/script/config.sh b/script/config.sh index 096c64b..a4b0e8e 100644 --- a/script/config.sh +++ b/script/config.sh @@ -32,27 +32,35 @@ export LVEXT1SUFFIX="_home" export USELVEXT2=0 export LVEXT2SUFFIX="_var" -# 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. + +# Volume size parameters. # Note that the order of the volume creation is : # 1. EFI if needed # 2. SWAP # 3. LVROOT # 4. LVEXT1 if needed # 5. LVEXT2 if needed -export LVROOTSIZE="10%FREE" - -# Logical volume size of the optional volumes. -export LVEXT1SIZE="90%FREE" -export LVEXT2SIZE="100%FREE" # Set the size of EFI partition and swap partition. # The unit is Byte. You can use M,G... notation. +# You CANNOT use the % notation. export EFISIZE="200M" + +# Logical volume size of the swap volumes. export LVSWAPSIZE="8G" +# Logical volume size of the Linux installation. +# There are four posibble way to specify the volume. +# nnnM, nnnG, nnnT : Absolute size speicification. nnnMbyte, nnnGByte, nnnT byte. +# mm%VG : Use mm% of the entire volume group. +# mm%FREE : Use mm% of the avairable storage are in the volume group. +export LVROOTSIZE="10G" + +# Logical volume size of the optional volumes. +export LVEXT1SIZE="30G" +export LVEXT2SIZE="10G" + + # Usually, these names can be left untouched. # If you change, keep them consistent through all installation in your system. export CRYPTPARTNAME="luks_volume" diff --git a/script/lib/common.sh b/script/lib/common.sh index c2a26e0..91a8d3f 100644 --- a/script/lib/common.sh +++ b/script/lib/common.sh @@ -141,6 +141,24 @@ function confirmation(){ return 1 # with error status fi # passphrase validation + + # Add -l or -L parameter to the size. The lvcreate command have two size parameter. + # -L ###[M|G|T|m|g|t] : Size by absolute value. + # -l ###%[FREE|VG|PVS|ORIGIN] : Size by relative value. + # If Unit is not specified, installation will fail. + + LVSWAPSIZE=$(echo "${LVSWAPSIZE}" | awk '/M|G|T|m|g|t/{print "-L", $0} /%/ {print "-l", $0}') + export LVSWAPSIZE + + LVROOTSIZE=$(echo "${LVROOTSIZE}" | awk '/M|G|T|m|g|t/{print "-L", $0} /%/ {print "-l", $0}') + export LVROOTSIZE + + LVEXT1SIZE=$(echo "${LVEXT1SIZE}" | awk '/M|G|T|m|g|t/{print "-L", $0} /%/ {print "-l", $0}') + export LVEXT1SIZE + + LVEXT2SIZE=$(echo "${LVEXT2SIZE}" | awk '/M|G|T|m|g|t/{print "-L", $0} /%/ {print "-l", $0}') + export LVEXT2SIZE + # succesfull return return 0 } @@ -239,7 +257,7 @@ function pre_install() { echo "...Swap volume already exist. Skipped to create. No problem." else echo "...Creating logical volume \"${LVSWAPNAME}\" on \"${VGNAME}\"." - lvcreate -L "${LVSWAPSIZE}" -n "${LVSWAPNAME}" "${VGNAME}" + lvcreate "${LVSWAPSIZE}" -n "${LVSWAPNAME}" "${VGNAME}" if [ $? -ne 0 ] ; then deactivate_and_close; return 1 ; fi; fi # if /dev/mapper/swap volume already exit. @@ -272,7 +290,7 @@ function pre_install() { 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}" + lvcreate "${LVROOTSIZE}" -n "${LVROOTNAME}" "${VGNAME}" if [ $? -ne 0 ] ; then deactivate_and_close; return 1 ; fi; IS_ROOT_CREATED=1 @@ -474,7 +492,7 @@ function create_ext_lv() { echo "...Logical volume \"${VGNAME}-${LVROOTNAME}${LVEXT1SUFFIX}\" already exists. OK." else echo "...Creating logical volume \"${LVROOTNAME}${LVEXT1SUFFIX}\" on \"${VGNAME}\"." - lvcreate -l "${LVEXT1SIZE}" -n "${LVROOTNAME}${LVEXT1SUFFIX}" "${VGNAME}" + lvcreate "${LVEXT1SIZE}" -n "${LVROOTNAME}${LVEXT1SUFFIX}" "${VGNAME}" if [ $? -ne 0 ] ; then # if fail echo "***** ERROR : failed to create "${VGNAME}-${LVROOTNAME}${LVEXT1SUFFIX}" . *****" return 1 ; @@ -489,7 +507,7 @@ function create_ext_lv() { echo "...Logical volume \"${VGNAME}-${LVROOTNAME}${LVEXT2SUFFIX}\" already exists. OK." else echo "...Creating logical volume \"${LVROOTNAME}${LVEXT2SUFFIX}\" on \"${VGNAME}\"." - lvcreate -l "${LVEXT2SIZE}" -n "${LVROOTNAME}${LVEXT2SUFFIX}" "${VGNAME}" + lvcreate "${LVEXT2SIZE}" -n "${LVROOTNAME}${LVEXT2SUFFIX}" "${VGNAME}" if [ $? -ne 0 ] ; then # if fail echo "***** ERROR : failed to create "${VGNAME}-${LVROOTNAME}${LVEXT1SUFFIX}" . *****" return 1 ; From d322e8d5c54e09d2c3a498f01171e2a1fde8f145 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sat, 7 May 2022 21:35:29 +0900 Subject: [PATCH 2/4] Unquoted first parameter of lvcreate. This is to use the IFS ( Internal Field Separator ). Without IFS the string "-L 8G" will be wrapped by single quote like '-L 8G', while we need -L 8G. --- script/lib/common.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/script/lib/common.sh b/script/lib/common.sh index 91a8d3f..a1bd2f5 100644 --- a/script/lib/common.sh +++ b/script/lib/common.sh @@ -257,7 +257,8 @@ function pre_install() { echo "...Swap volume already exist. Skipped to create. No problem." else echo "...Creating logical volume \"${LVSWAPNAME}\" on \"${VGNAME}\"." - lvcreate "${LVSWAPSIZE}" -n "${LVSWAPNAME}" "${VGNAME}" + # Too use the bash IFS, first parameter is not quoted. + lvcreate ${LVSWAPSIZE} -n "${LVSWAPNAME}" "${VGNAME}" if [ $? -ne 0 ] ; then deactivate_and_close; return 1 ; fi; fi # if /dev/mapper/swap volume already exit. @@ -290,7 +291,8 @@ function pre_install() { return 1 # with error status else # not exist and not overwrite install echo "...Creating logical volume \"${LVROOTNAME}\" on \"${VGNAME}\"." - lvcreate "${LVROOTSIZE}" -n "${LVROOTNAME}" "${VGNAME}" + # Too use the bash IFS, first parameter is not quoted. + lvcreate ${LVROOTSIZE} -n "${LVROOTNAME}" "${VGNAME}" if [ $? -ne 0 ] ; then deactivate_and_close; return 1 ; fi; IS_ROOT_CREATED=1 @@ -492,7 +494,8 @@ function create_ext_lv() { echo "...Logical volume \"${VGNAME}-${LVROOTNAME}${LVEXT1SUFFIX}\" already exists. OK." else echo "...Creating logical volume \"${LVROOTNAME}${LVEXT1SUFFIX}\" on \"${VGNAME}\"." - lvcreate "${LVEXT1SIZE}" -n "${LVROOTNAME}${LVEXT1SUFFIX}" "${VGNAME}" + # Too use the bash IFS, first parameter is not quoted. + lvcreate ${LVEXT1SIZE} -n "${LVROOTNAME}${LVEXT1SUFFIX}" "${VGNAME}" if [ $? -ne 0 ] ; then # if fail echo "***** ERROR : failed to create "${VGNAME}-${LVROOTNAME}${LVEXT1SUFFIX}" . *****" return 1 ; @@ -507,7 +510,8 @@ function create_ext_lv() { echo "...Logical volume \"${VGNAME}-${LVROOTNAME}${LVEXT2SUFFIX}\" already exists. OK." else echo "...Creating logical volume \"${LVROOTNAME}${LVEXT2SUFFIX}\" on \"${VGNAME}\"." - lvcreate "${LVEXT2SIZE}" -n "${LVROOTNAME}${LVEXT2SUFFIX}" "${VGNAME}" + # Too use the bash IFS, first parameter is not quoted. + lvcreate ${LVEXT2SIZE} -n "${LVROOTNAME}${LVEXT2SUFFIX}" "${VGNAME}" if [ $? -ne 0 ] ; then # if fail echo "***** ERROR : failed to create "${VGNAME}-${LVROOTNAME}${LVEXT1SUFFIX}" . *****" return 1 ; From 425181aff1f0139bc23609aece48280c38b07542 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sat, 7 May 2022 22:02:42 +0900 Subject: [PATCH 3/4] Fix the duplicate awk match. Now, it exits the process when the first pattern is procesed. --- script/lib/common.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/script/lib/common.sh b/script/lib/common.sh index a1bd2f5..c37b0f9 100644 --- a/script/lib/common.sh +++ b/script/lib/common.sh @@ -143,20 +143,21 @@ function confirmation(){ # Add -l or -L parameter to the size. The lvcreate command have two size parameter. - # -L ###[M|G|T|m|g|t] : Size by absolute value. # -l ###%[FREE|VG|PVS|ORIGIN] : Size by relative value. + # -L ###[M|G|T|m|g|t] : Size by absolute value. + # Too preven the duplicated match, awk exists the process after it match the /%/ pattern. # If Unit is not specified, installation will fail. - LVSWAPSIZE=$(echo "${LVSWAPSIZE}" | awk '/M|G|T|m|g|t/{print "-L", $0} /%/ {print "-l", $0}') + LVSWAPSIZE=$(echo "${LVSWAPSIZE}" | awk '/%/{print "-l", $0; exit} /M|G|T|m|g|t/{print "-L", $0}') export LVSWAPSIZE - LVROOTSIZE=$(echo "${LVROOTSIZE}" | awk '/M|G|T|m|g|t/{print "-L", $0} /%/ {print "-l", $0}') + LVROOTSIZE=$(echo "${LVROOTSIZE}" | awk '/%/{print "-l", $0; exit} /M|G|T|m|g|t/{print "-L", $0}') export LVROOTSIZE - LVEXT1SIZE=$(echo "${LVEXT1SIZE}" | awk '/M|G|T|m|g|t/{print "-L", $0} /%/ {print "-l", $0}') + LVEXT1SIZE=$(echo "${LVEXT1SIZE}" | awk '/%/{print "-l", $0; exit} /M|G|T|m|g|t/{print "-L", $0}') export LVEXT1SIZE - LVEXT2SIZE=$(echo "${LVEXT2SIZE}" | awk '/M|G|T|m|g|t/{print "-L", $0} /%/ {print "-l", $0}') + LVEXT2SIZE=$(echo "${LVEXT2SIZE}" | awk '/%/{print "-l", $0; exit} /M|G|T|m|g|t/{print "-L", $0}') export LVEXT2SIZE # succesfull return From d7b319a89f89b47ba848d1ee8d4777bd693128b7 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sun, 8 May 2022 05:53:44 +0900 Subject: [PATCH 4/4] Update CHANGELOG for feature/33 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e9dd79..c5a4e66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ Record of the modification in project development. ## [Unreleased] - yyyy-mm-dd ### Added - [Issue 31 : Add extra partition functionality.](https://github.com/suikan4github/kaiten-yaki/issues/31) +- [Issue 35 : Support "M/G/T" as size prefix.](https://github.com/suikan4github/kaiten-yaki/issues/35) ### Changed ### Deprecated