Merge pull request #40 from suikan4github/develop

Merge Develop for v1.3.0
This commit is contained in:
Seiichi "Suikan" Horie 2022-05-15 10:17:54 +09:00 committed by GitHub
commit 809dafa70c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 432 additions and 145 deletions

View file

@ -9,6 +9,27 @@ Record of the modification in project development.
### Fixed ### Fixed
### Known Issue ### Known Issue
## [1.3.0] - 2022-05-15
### Added
- [Issue 31 : Add extra partition functionality.](https://github.com/suikan4github/kaiten-yaki/issues/31)
- [Issue 33 : Support "M/G/T" as size prefix.](https://github.com/suikan4github/kaiten-yaki/issues/33)
### Changed
- [Issue 38 : "Ready to reboot" message should be changed](https://github.com/suikan4github/kaiten-yaki/issues/38)
- [Issue 39 : Change message style](https://github.com/suikan4github/kaiten-yaki/issues/39)
### Deprecated
- [Issue 34 : BIOS support should be obsoleted ](https://github.com/suikan4github/kaiten-yaki/issues/34)
### Removed
- [Issue 35 : Remove XTERMFONTSIZE variable.](https://github.com/suikan4github/kaiten-yaki/issues/35)
### Fixed
- [Issue 32 : Ubuntu 22.04 fails to deactivate the swap](https://github.com/suikan4github/kaiten-yaki/issues/32)
- [Issue 36 : Clear the PASSPHRASE variable at the end of installation](https://github.com/suikan4github/kaiten-yaki/issues/36)
### Known Issue
## [1.2.0] - 2021-10-16 ## [1.2.0] - 2021-10-16
### Added ### Added
### Changed ### Changed
@ -74,7 +95,8 @@ See [Testing before release v1.1.0](https://github.com/suikan4github/kaiten-yaki
### Known Issue ### Known Issue
[Unreleased]: https://github.com/suikan4github/kaiten-yaki/compare/v1.2.0...develop [Unreleased]: https://github.com/suikan4github/kaiten-yaki/compare/v1.3.0...develop
[1.3.0]: https://github.com/suikan4github/kaiten-yaki/compare/v1.2.0...v1.3.0
[1.2.0]: https://github.com/suikan4github/kaiten-yaki/compare/v1.1.0...v1.2.0 [1.2.0]: https://github.com/suikan4github/kaiten-yaki/compare/v1.1.0...v1.2.0
[1.1.0]: https://github.com/suikan4github/kaiten-yaki/compare/v1.0.0...v1.1.0 [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 [1.0.0]: https://github.com/suikan4github/kaiten-yaki/compare/v0.0.0...v1.0.0

View file

@ -48,7 +48,8 @@ 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). - 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 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 swap logical volume named "swap" in the "vg1". The size is 8GB (LVSWAPNAME,LVSWAPSIZE)
- 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). - Create a logical volume named **"anko"** as root volume, in the "vg1". The size of the new volume is the **10GB** (LVROOTNAME, LVROOTSIZE).
- No Extra volumes will be created (USELVEXT1, LVEXT1SUFFIX, LVEXT1SIZE, USELVEXT2, LVEXT2SUFFIX, LVEXT2SIZE).
```sh ```sh
# Configuration parameters for Kaiten-Yaki # Configuration parameters for Kaiten-Yaki
@ -65,17 +66,53 @@ export ERASEALL=0
# Keep it unique from other distribution. # Keep it unique from other distribution.
export LVROOTNAME="anko" export LVROOTNAME="anko"
# Logical volume size of the Linux installation. # Suffix of the optional logical volumes.
# 30% mean, new logical volume will use 30% of the free space # If you want to have optional OVs, set USELVEXT# to 1.
# in the LVM volume group. For example, assume the free space is 100GB, # Then, the suffix will be added to the LVROOTNAME.
# and LVROOTSIZE is 30%FREE. Script will create 30GB logical volume. # For example, Assume you have setting below :
export LVROOTSIZE="50%FREE" # LVROOTNAME="anko"
# USELVEXT1=1
# LVEXT1SUFFIX="_home"
# USELVEXT2=0
# LVEXT2SUFFIX="_var"
# You will have
# anko
# anko_home
# You will not have anko_var because the USELVEXT2=0.
export USELVEXT1=0
export LVEXT1SUFFIX="_home"
export USELVEXT2=0
export LVEXT2SUFFIX="_var"
# 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
# Set the size of EFI partition and swap partition. # Set the size of EFI partition and swap partition.
# The unit is Byte. You can use M,G... notation. # The unit is Byte. You can use M,G... notation.
# You CANNOT use the % notation.
export EFISIZE="200M" export EFISIZE="200M"
# Logical volume size of the swap volumes.
export LVSWAPSIZE="8G" 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. # Usually, these names can be left untouched.
# If you change, keep them consistent through all installation in your system. # If you change, keep them consistent through all installation in your system.
export CRYPTPARTNAME="luks_volume" export CRYPTPARTNAME="luks_volume"
@ -92,18 +129,22 @@ export OVERWRITEINSTALL=0
# If you specify 1000, that means 1000mSec. 0 means compile default. # If you specify 1000, that means 1000mSec. 0 means compile default.
export ITERTIME=0 export ITERTIME=0
# Void Linux only. Ignored in Ubuntu.
# The font size of the void-installer
export XTERMFONTSIZE=11
``` ```
There are several restrictions : There are several restrictions :
- 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. - 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 CRYPTPARTNAME and VGNAME must be unique among all installations in a physical disk. 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 LVSWAPNAME must be identical among all installations in a physical disk. 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 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 LVROOTSIZE, LVEXT1SIZE, LVEXT2SIZE are the size of a logical volumes to create. There are several way to specify the size ( where n is number) :
- The name with "-" is not allowed for the VGNAME, LVROOTNAME, and LVSWAPNAME. I saw some installer doesn't work if "-" in in the name. - nnnM : New logical volume size is nnn**MByte**.
- nnnG : New logical volume size is nnn**GByte**.
- nnnT : New logical volume size is nnn**TByte**.
- nn%VG : New logical volume size is nn% of the **entire volume group**.
- nn%FREE : New logical volume size is nn% of the **free space** in the volume group.
- The name with "-" is not allowed for the VGNAME, LVROOTNAME, and LVSWAPNAME. I saw some distribution 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. 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 This is very dangerous because of several aspects like destroying the wrong volume and the risk of security. But sometimes it is
@ -131,6 +172,28 @@ The unit of value is milliseconds. The target linux kernel may take this duratio
The smaller value gives the weaker security. The smaller value gives the weaker security.
### About the extra logical volume
From ver 1.3.0, Kaiten-yaki support two extra volume in addition to LVROOT and LVSWAP.
- LVEXT1
- LVEXT2
The usage of the extra logical volume is up to the user. Typically, user may want to use it for example separated /home partition.
The name of the extra volume is the concatenation of the LVROOTNAME and LVEXTnSUFFIX ( where n is 1 or 2 ). For example, let's assume following configuration :
- LVROOTNAME="FOO"
- LVEXT1SUFFIX="_BAR"
Thus, the name of the LVEXT1 is "FOO_BAR".
### Partition and logical volume creation order.
Kaiten-yaki creates the partition/volume in the following order :
1. EFI partition
1. LUKS partition
1. LVSWAP
1. LVROOT
1. LVEXT1
1. LVEXT2
## First stage: Setting up the volumes ## 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. 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.

View file

@ -1,17 +1,17 @@
# Kaiten-yaki: Full disk encryption install script for Linux # Kaiten-yaki: Full disk encryption install script for Linux
Kaiten-yaki is a script set to install Linux to your AMD64 desktop system. With these scripts, you can install Ubuntu/Void Linux to an encrypted partition easily. Kaiten-yaki v1.3.0 is a script set to install Linux to your AMD64 desktop system. With these scripts, you can install Ubuntu/Void Linux to an encrypted partition easily.
The followings are the list of functionalities: The followings are the list of functionalities:
- Ubuntu and Void Linux. - Ubuntu and Void Linux support.
- Help to 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. - 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. - Automatic detection of EFI firmware and create GPT (The BIOS detection and MBR creation function exist. But they are not test from v1.3.0).
- Create an EFI partition, if needed. - Create an EFI partition, if needed.
- Support multiple boot in a LUKS partition. - Support multiple boot in a LUKS partition.
- Support btrfs in addition to the major file systems. - Support btrfs in addition to the major file systems.
- The "/boot" is located in the same logical volume as the "/". - The "/boot" is located in the same encrypted logical volume with the "/".
- The swap logical volume is located inside the encrypted volume. - The swap is located in the same encrypted logical volume with the "/".
- You need to type a passphrase only once in the boot sequence. - You need to type a passphrase only once in the boot sequence of the installed system.
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. 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.
@ -25,6 +25,11 @@ As depicted above, the LVM volume group has only one physical volume.
# Tested environment # Tested environment
These scripts are tested with the following environment. These scripts are tested with the following environment.
- VMVare Workstation 15.5.7 ( EFI )
- Ubuntu 22.04 amd64 desktop
- void-live-x86_64-20210930-xfce.iso
- void-live-x86_64-20210930.iso
- Followings are the tested environment of the Kaiten-Yaki v1.2.0
- VMWare Workstation 15.5.7 ( EFI/BIOS ) - VMWare Workstation 15.5.7 ( EFI/BIOS )
- ThinkPad X220 (BIOS) - ThinkPad X220 (BIOS)
- Ubuntu 20.04.3 amd64 desktop - Ubuntu 20.04.3 amd64 desktop
@ -43,11 +48,8 @@ Rough procedure of the installation is as followings :
The detail procedure is explained 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 # 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. Ubuntu has several variants ( flavors ). While while only the Ubuntu desktop is tested, other flavors may work correctly as far as it uses Ubiquity installer.
# Other resources # Other resources
See [Wiki](https://github.com/suikan4github/kaiten-yaki/wiki) for the application notes and the useful links. See [Wiki](https://github.com/suikan4github/kaiten-yaki/wiki) for the application notes and the useful links.

View file

@ -14,17 +14,53 @@ export ERASEALL=0
# Keep it unique from other distribution. # Keep it unique from other distribution.
export LVROOTNAME="anko" export LVROOTNAME="anko"
# Logical volume size of the Linux installation. # Suffix of the optional logical volumes.
# 30% mean, new logical volume will use 30% of the free space # If you want to have optional OVs, set USELVEXT# to 1.
# in the LVM volume group. For example, assume the free space is 100GB, # Then, the suffix will be added to the LVROOTNAME.
# and LVROOTSIZE is 30%FREE. Script will create 30GB logical volume. # For example, Assume you have setting below :
export LVROOTSIZE="50%FREE" # LVROOTNAME="anko"
# USELVEXT1=1
# LVEXT1SUFFIX="_home"
# USELVEXT2=0
# LVEXT2SUFFIX="_var"
# You will have
# anko
# anko_home
# You will not have anko_var because the USELVEXT2=0.
export USELVEXT1=0
export LVEXT1SUFFIX="_home"
export USELVEXT2=0
export LVEXT2SUFFIX="_var"
# 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
# Set the size of EFI partition and swap partition. # Set the size of EFI partition and swap partition.
# The unit is Byte. You can use M,G... notation. # The unit is Byte. You can use M,G[Kaiten-Yaki] notation.
# You CANNOT use the % notation.
export EFISIZE="200M" export EFISIZE="200M"
# Logical volume size of the swap volumes.
export LVSWAPSIZE="8G" 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. # Usually, these names can be left untouched.
# If you change, keep them consistent through all installation in your system. # If you change, keep them consistent through all installation in your system.
export CRYPTPARTNAME="luks_volume" export CRYPTPARTNAME="luks_volume"
@ -41,9 +77,6 @@ export OVERWRITEINSTALL=0
# If you specify 1000, that means 1000mSec. 0 means compile default. # If you specify 1000, that means 1000mSec. 0 means compile default.
export ITERTIME=0 export ITERTIME=0
# Void Linux only. Ignored in Ubuntu.
# The font size of the void-installer
export XTERMFONTSIZE=11
# !!!!!!!!!!!!!! DO NOT EDIT FOLLOWING LINES. !!!!!!!!!!!!!! # !!!!!!!!!!!!!! DO NOT EDIT FOLLOWING LINES. !!!!!!!!!!!!!!
@ -63,11 +96,3 @@ else
# BIOS firmware # BIOS firmware
export CRYPTPARTITION=1 export CRYPTPARTITION=1
fi # EFI firmware fi # EFI firmware
# Detect the GUI environment
# This code is not efered. Just left because it is interestintg code.
if env | grep -w -e XDG_SESSION_TYPE -e DISPLAY -e WAYLAND_DISPLAY > /dev/null ; then
export GUIENV=1 # set 1 if GUI env.
else
export GUIENV=0 # set 0 if not GUI env.
fi

View file

@ -6,7 +6,7 @@ function chrooted_job() {
mount -a mount -a
# Prepare the crypto tool in the install target # Prepare the crypto tool in the install target
echo "...Installing cryptsetup-initramfs package." echo "[Kaiten-Yaki] Installing cryptsetup-initramfs package."
apt -qq install -y cryptsetup-initramfs apt -qq install -y cryptsetup-initramfs
# Prepare a new key file to embed in to the ramfs. # Prepare a new key file to embed in to the ramfs.
@ -14,28 +14,28 @@ function chrooted_job() {
# The new key is 4096byte length binary value. # The new key is 4096byte length binary value.
# Because this key is sotred as "cleartext", in the target file sysmte, # Because this key is sotred as "cleartext", in the target file sysmte,
# only root is allowed to access this key file. # only root is allowed to access this key file.
echo "...Prepairing key file." echo "[Kaiten-Yaki] Prepairing key file."
mkdir /etc/luks mkdir /etc/luks
dd if=/dev/urandom of=/etc/luks/boot_os.keyfile bs=4096 count=1 status=none 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=rx,go-rwx /etc/luks
chmod u=r,go-rwx /etc/luks/boot_os.keyfile chmod u=r,go-rwx /etc/luks/boot_os.keyfile
# Add the new key to the LUKS 2nd key slot. The passphrase is required to modify the LUKS keyslot. # 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." echo "[Kaiten-Yaki] Adding a key to the key file."
printf %s "${PASSPHRASE}" | cryptsetup luksAddKey --iter-time "${ITERTIME}" -d - "${DEV}${CRYPTPARTITION}" /etc/luks/boot_os.keyfile printf %s "${PASSPHRASE}" | cryptsetup luksAddKey --iter-time "${ITERTIME}" -d - "${DEV}${CRYPTPARTITION}" /etc/luks/boot_os.keyfile
# Register the LUKS voluem to /etc/crypttab to tell "This volume is encrypted" # Register the LUKS voluem to /etc/crypttab to tell "This volume is encrypted"
echo "...Adding LUKS volume info to /etc/crypttab." echo "[Kaiten-Yaki] 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 echo "${CRYPTPARTNAME} UUID=$(blkid -s UUID -o value ${DEV}${CRYPTPARTITION}) /etc/luks/boot_os.keyfile luks,discard" >> /etc/crypttab
# Add key file to the list of the intems in initramfs. # Add key file to the list of the intems in initramfs.
# See https://cryptsetup-team.pages.debian.net/cryptsetup/README.initramfs.html for detail # See https://cryptsetup-team.pages.debian.net/cryptsetup/README.initramfs.html for detail
echo "...Directing to include keyfile into the initramfs" echo "[Kaiten-Yaki] Directing to include keyfile into the initramfs"
echo "KEYFILE_PATTERN=/etc/luks/*.keyfile" >> /etc/cryptsetup-initramfs/conf-hook echo "KEYFILE_PATTERN=/etc/luks/*.keyfile" >> /etc/cryptsetup-initramfs/conf-hook
echo "UMASK=0077" >> /etc/initramfs-tools/initramfs.conf echo "UMASK=0077" >> /etc/initramfs-tools/initramfs.conf
# Finally, update the ramfs initial image with the key file. # Finally, update the ramfs initial image with the key file.
echo "...Upadting initramfs." echo "[Kaiten-Yaki] Upadting initramfs."
update-initramfs -uk all update-initramfs -uk all
# Leave chroot # Leave chroot

View file

@ -6,7 +6,7 @@ function chrooted_job() {
mount -a mount -a
# Prepare the crypto tool in the install target # Prepare the crypto tool in the install target
echo "...Installing cryptsetup-initramfs package." echo "[Kaiten-Yaki] Installing cryptsetup-initramfs package."
xbps-install -y lvm2 cryptsetup xbps-install -y lvm2 cryptsetup
# Prepare a new key file to embed in to the ramfs. # Prepare a new key file to embed in to the ramfs.
@ -14,29 +14,29 @@ function chrooted_job() {
# The new key is 4096byte length binary value. # The new key is 4096byte length binary value.
# Because this key is sotred as "cleartext", in the target file sysmte, # Because this key is sotred as "cleartext", in the target file sysmte,
# only root is allowed to access this key file. # only root is allowed to access this key file.
echo "...Prepairing key file." echo "[Kaiten-Yaki] Prepairing key file."
mkdir /etc/luks mkdir /etc/luks
dd if=/dev/urandom of=/etc/luks/boot_os.keyfile bs=4096 count=1 status=none 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=rx,go-rwx /etc/luks
chmod u=r,go-rwx /etc/luks/boot_os.keyfile chmod u=r,go-rwx /etc/luks/boot_os.keyfile
# Add the new key to the LUKS 2nd key slot. The passphrase is required to modify the LUKS keyslot. # 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." echo "[Kaiten-Yaki] Adding a key to the key file."
printf %s "${PASSPHRASE}" | cryptsetup luksAddKey --iter-time "${ITERTIME}" -d - "${DEV}${CRYPTPARTITION}" /etc/luks/boot_os.keyfile printf %s "${PASSPHRASE}" | cryptsetup luksAddKey --iter-time "${ITERTIME}" -d - "${DEV}${CRYPTPARTITION}" /etc/luks/boot_os.keyfile
# Register the LUKS voluem to /etc/crypttab to tell "This volume is encrypted" # Register the LUKS voluem to /etc/crypttab to tell "This volume is encrypted"
echo "...Adding LUKS volume info to /etc/crypttab." echo "[Kaiten-Yaki] 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 echo "${CRYPTPARTNAME} UUID=$(blkid -s UUID -o value ${DEV}${CRYPTPARTITION}) /etc/luks/boot_os.keyfile luks,discard" >> /etc/crypttab
# Add key file to the list of the intems in initramfs. # Add key file to the list of the intems in initramfs.
# See https://man7.org/linux/man-pages/man5/dracut.conf.5.html for details. # See https://man7.org/linux/man-pages/man5/dracut.conf.5.html for details.
echo "...Directing to include keyfile into the initramfs" echo "[Kaiten-Yaki] Directing to include keyfile into the initramfs"
echo 'install_items+=" /etc/luks/boot_os.keyfile /etc/crypttab " ' >> /etc/dracut.conf.d/10-crypt.conf 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. # Finally, update the ramfs initial image with the key file.
echo "...Upadting initramfs." echo "[Kaiten-Yaki] Upadting initramfs."
xbps-reconfigure -fa xbps-reconfigure -fa
echo "...grub-mkconfig." echo "[Kaiten-Yaki] grub-mkconfig."
grub-mkconfig -o /boot/grub/grub.cfg grub-mkconfig -o /boot/grub/grub.cfg
# Leave chroot # Leave chroot

View file

@ -9,11 +9,11 @@ function confirmation(){
if [ "${ERASEALL}" -ne 0 ] && [ "${OVERWRITEINSTALL}" -ne 0 ] ; then if [ "${ERASEALL}" -ne 0 ] && [ "${OVERWRITEINSTALL}" -ne 0 ] ; then
cat <<- HEREDOC cat <<- HEREDOC
***** ERROR : Confliction between ERASEALL and OVERWRITEINSTALL ***** ***** ERROR : Confliction between ERASEALL and OVERWRITEINSTALL *****
...ERASEALL = ${ERASEALL} [Kaiten-Yaki] ERASEALL = ${ERASEALL}
...OVERWRITEINSTALL = ${OVERWRITEINSTALL} [Kaiten-Yaki] OVERWRITEINSTALL = ${OVERWRITEINSTALL}
...Check configuration in your config.sh [Kaiten-Yaki] Check configuration in your config.sh
...Installation process terminated.. [Kaiten-Yaki] Installation process terminated..
HEREDOC HEREDOC
return 1 # with error status return 1 # with error status
fi fi
@ -22,10 +22,10 @@ function confirmation(){
if echo "${VGNAME}" | grep "-" -i > /dev/null ; then # "-" is found in the volume group name. if echo "${VGNAME}" | grep "-" -i > /dev/null ; then # "-" is found in the volume group name.
cat <<- HEREDOC cat <<- HEREDOC
***** ERROR : VGNAME is "${VGNAME}" ***** ***** ERROR : VGNAME is "${VGNAME}" *****
..."-" is not allowed in the volume name. [Kaiten-Yaki] "-" is not allowed in the volume name.
...Check configuration in your config.sh [Kaiten-Yaki] Check configuration in your config.sh
...Installation process terminated.. [Kaiten-Yaki] Installation process terminated..
HEREDOC HEREDOC
return 1 # with error status return 1 # with error status
fi # "-" is found in the volume group name. fi # "-" is found in the volume group name.
@ -34,22 +34,50 @@ function confirmation(){
if echo "${LVROOTNAME}" | grep "-" -i > /dev/null ; then # "-" is found in the volume name. if echo "${LVROOTNAME}" | grep "-" -i > /dev/null ; then # "-" is found in the volume name.
cat <<- HEREDOC cat <<- HEREDOC
***** ERROR : LVROOTNAME is "${LVROOTNAME}" ***** ***** ERROR : LVROOTNAME is "${LVROOTNAME}" *****
..."-" is not allowed in the volume name. [Kaiten-Yaki] "-" is not allowed in the volume name.
...Check configuration in your config.sh [Kaiten-Yaki] Check configuration in your config.sh
...Installation process terminated.. [Kaiten-Yaki] Installation process terminated..
HEREDOC HEREDOC
return 1 # with error status return 1 # with error status
fi # "-" is found in the volume name. fi # "-" is found in the volume name.
# Sanity check for lvext1 volume suffix
if [ "${USELVEXT1}" -ne 0 ] ; then
if echo "${LVEXT1SUFFIX}" | grep "-" -i > /dev/null ; then # "-" is found in the volume name.
cat <<- HEREDOC
***** ERROR : LVEXT1SUFFIX is "${LVEXT1SUFFIX}" *****
[Kaiten-Yaki] "-" is not allowed in the volume name.
[Kaiten-Yaki] Check configuration in your config.sh
[Kaiten-Yaki] Installation process terminated..
HEREDOC
return 1 # with error status
fi # "-" is found in the volume suffix.
fi # USELVEXT1
# Sanity check for lvext2 volume suffix
if [ "${USELVEXT2}" -ne 0 ] ; then
if echo "${LVEXT2SUFFIX}" | grep "-" -i > /dev/null ; then # "-" is found in the volume name.
cat <<- HEREDOC
***** ERROR : LVEXT2SUFFIX is "${LVEXT2SUFFIX}" *****
[Kaiten-Yaki] "-" is not allowed in the volume name.
[Kaiten-Yaki] Check configuration in your config.sh
[Kaiten-Yaki] Installation process terminated..
HEREDOC
return 1 # with error status
fi # "-" is found in the volume suffix.
fi # USELVEXT2
# Sanity check for swap volume name # Sanity check for swap volume name
if echo "${LVSWAPNAME}" | grep "-" -i > /dev/null ; then # "-" is found in the volume name. if echo "${LVSWAPNAME}" | grep "-" -i > /dev/null ; then # "-" is found in the volume name.
cat <<- HEREDOC cat <<- HEREDOC
***** ERROR : LVSWAPNAME is "${LVSWAPNAME}" ***** ***** ERROR : LVSWAPNAME is "${LVSWAPNAME}" *****
..."-" is not allowed in the volume name. [Kaiten-Yaki] "-" is not allowed in the volume name.
...Check configuration in your config.sh [Kaiten-Yaki] Check configuration in your config.sh
...Installation process terminated.. [Kaiten-Yaki] Installation process terminated..
HEREDOC HEREDOC
return 1 # with error status return 1 # with error status
fi # "-" is found in the volume name. fi # "-" is found in the volume name.
@ -62,28 +90,45 @@ function confirmation(){
Volume group name : "${VGNAME}" Volume group name : "${VGNAME}"
Root volume name : "${VGNAME}-${LVROOTNAME}" Root volume name : "${VGNAME}-${LVROOTNAME}"
Root volume size : "${LVROOTSIZE}" Root volume size : "${LVROOTSIZE}"
HEREDOC
if [ "${USELVEXT1}" -ne 0 ] ; then
cat <<- HEREDOC
Extra volume name 1 : "${VGNAME}-${LVROOTNAME}${LVEXT1SUFFIX}"
Extra volume size 1 : "${LVEXT1SIZE}"
HEREDOC
fi # USELVEXT1
if [ "${USELVEXT2}" -ne 0 ] ; then
cat <<- HEREDOC
Extra volume name 2 : "${VGNAME}-${LVROOTNAME}${LVEXT2SUFFIX}"
Extra volume size 2 : "${LVEXT2SIZE}"
HEREDOC
fi # USELVEXT2
cat <<- HEREDOC
Swap volume name : "${VGNAME}-${LVSWAPNAME}" Swap volume name : "${VGNAME}-${LVSWAPNAME}"
Swap volume size : "${LVSWAPSIZE}" Swap volume size : "${LVSWAPSIZE}"
--iter-time parameter : ${ITERTIME} --iter-time parameter : ${ITERTIME}
HEREDOC HEREDOC
if [ "${ERASEALL}" -ne 0 ] ; then if [ "${ERASEALL}" -ne 0 ] ; then
echo "Going to erase entire disk ${DEV}." echo "[Kaiten-Yaki] Going to erase entire disk ${DEV}."
elif [ "${OVERWRITEINSTALL}" -ne 0 ] ; then elif [ "${OVERWRITEINSTALL}" -ne 0 ] ; then
echo "Going to overwrite the logical volume \"${VGNAME}-${LVROOTNAME}\"." echo "[Kaiten-Yaki] Going to overwrite the logical volume \"${VGNAME}-${LVROOTNAME}\"."
else else
echo "Going to create a new logical volume \"${VGNAME}-${LVROOTNAME}\"." echo "[Kaiten-Yaki] Going to create a new logical volume \"${VGNAME}-${LVROOTNAME}\"."
fi fi
# ----- Set Passphrase ----- # ----- Set Passphrase -----
# Input passphrase # Input passphrase
echo "" echo ""
echo "Type passphrase for the disk encryption." echo "[Kaiten-Yaki] Type passphrase for the disk encryption."
read -sr PASSPHRASE read -sr PASSPHRASE
export PASSPHRASE export PASSPHRASE
echo "Type passphrase again, to confirm." echo "[Kaiten-Yaki] Type passphrase again, to confirm."
read -sr PASSPHRASE_C read -sr PASSPHRASE_C
# Validate whether both are indentical or not # Validate whether both are indentical or not
@ -91,11 +136,33 @@ function confirmation(){
cat <<-HEREDOC cat <<-HEREDOC
***** ERROR : Passphrase doesn't match ***** ***** ERROR : Passphrase doesn't match *****
...Installation process terminated.. [Kaiten-Yaki] Installation process terminated..
HEREDOC HEREDOC
return 1 # with error status return 1 # with error status
else
# Clear the PASSPHRASE for checking because we don't use it anymore.
PASSPHRASE_C=""
fi # passphrase validation fi # passphrase validation
# Add -l or -L parameter to the size. The lvcreate command have two size parameter.
# -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 '/%/{print "-l", $0; exit} /M|G|T|m|g|t/{print "-L", $0}')
export LVSWAPSIZE
LVROOTSIZE=$(echo "${LVROOTSIZE}" | awk '/%/{print "-l", $0; exit} /M|G|T|m|g|t/{print "-L", $0}')
export LVROOTSIZE
LVEXT1SIZE=$(echo "${LVEXT1SIZE}" | awk '/%/{print "-l", $0; exit} /M|G|T|m|g|t/{print "-L", $0}')
export LVEXT1SIZE
LVEXT2SIZE=$(echo "${LVEXT2SIZE}" | awk '/%/{print "-l", $0; exit} /M|G|T|m|g|t/{print "-L", $0}')
export LVEXT2SIZE
# succesfull return # succesfull return
return 0 return 0
} }
@ -107,6 +174,11 @@ function confirmation(){
function pre_install() { function pre_install() {
# Internal variables.
# These variables displays whether the volumes are created in this installation.
IS_ROOT_CREATED=0
IS_LVEXT1_CREATED=0
IS_LVEXT2_CREATED=0
# ----- Erase entire disk, create partitions, format them and encrypt the LUKS partition ----- # ----- Erase entire disk, create partitions, format them and encrypt the LUKS partition -----
if [ "${ERASEALL}" -ne 0 ] ; then if [ "${ERASEALL}" -ne 0 ] ; then
@ -114,19 +186,19 @@ function pre_install() {
# Assign specified space and rest of disk to the EFI and LUKS partition, respectively. # Assign specified space and rest of disk to the EFI and LUKS partition, respectively.
if [ "${ISEFI}" -ne 0 ] ; then # EFI if [ "${ISEFI}" -ne 0 ] ; then # EFI
# Zap existing partition table and create new GPT # Zap existing partition table and create new GPT
echo "...Initializing \"${DEV}\" with GPT." echo "[Kaiten-Yaki] Initializing \"${DEV}\" with GPT."
sgdisk --zap-all "${DEV}" sgdisk --zap-all "${DEV}"
if is_error ; then return 1 ; fi; # If error, terminate if is_error ; then return 1 ; fi; # If error, terminate
# Create EFI partition and format it # Create EFI partition and format it
echo "...Creating an EFI partition on \"${DEV}\"." echo "[Kaiten-Yaki] Creating an EFI partition on \"${DEV}\"."
# shellcheck disable=SC2140 # shellcheck disable=SC2140
sgdisk --new="${EFIPARTITION}":0:+"${EFISIZE}" --change-name="${EFIPARTITION}":"EFI System" --typecode="${EFIPARTITION}":ef00 "${DEV}" sgdisk --new="${EFIPARTITION}":0:+"${EFISIZE}" --change-name="${EFIPARTITION}":"EFI System" --typecode="${EFIPARTITION}":ef00 "${DEV}"
if is_error ; then return 1 ; fi; # If error, terminate if is_error ; then return 1 ; fi; # If error, terminate
echo "...Formatting the EFI parttion." echo "[Kaiten-Yaki] Formatting the EFI parttion."
mkfs.vfat -F 32 -n EFI-SP "${DEV}${EFIPARTITION}" mkfs.vfat -F 32 -n EFI-SP "${DEV}${EFIPARTITION}"
if is_error ; then return 1 ; fi; # If error, terminate if is_error ; then return 1 ; fi; # If error, terminate
# Create Linux partition # Create Linux partition
echo "...Creating a Linux partition on ${DEV}." echo "[Kaiten-Yaki] Creating a Linux partition on ${DEV}."
# shellcheck disable=SC2140 # shellcheck disable=SC2140
sgdisk --new="${CRYPTPARTITION}":0:0 --change-name="${CRYPTPARTITION}":"Linux LUKS" --typecode="${CRYPTPARTITION}":8309 "${DEV}" sgdisk --new="${CRYPTPARTITION}":0:0 --change-name="${CRYPTPARTITION}":"Linux LUKS" --typecode="${CRYPTPARTITION}":8309 "${DEV}"
if is_error ; then return 1 ; fi; # If error, terminate if is_error ; then return 1 ; fi; # If error, terminate
@ -134,11 +206,11 @@ function pre_install() {
sgdisk --print "${DEV}" sgdisk --print "${DEV}"
else # BIOS else # BIOS
# Zap existing partition table # Zap existing partition table
echo "...Erasing partition table of \"${DEV}\"." echo "[Kaiten-Yaki] Erasing partition table of \"${DEV}\"."
dd if=/dev/zero of="${DEV}" bs=512 count=1 dd if=/dev/zero of="${DEV}" bs=512 count=1
if is_error ; then return 1 ; fi; # If error, terminate if is_error ; then return 1 ; fi; # If error, terminate
# Create MBR and allocate max storage for Linux partition # Create MBR and allocate max storage for Linux partition
echo "...Creating a Linux partition on ${DEV} with MBR." echo "[Kaiten-Yaki] Creating a Linux partition on ${DEV} with MBR."
sfdisk "${DEV}" <<- HEREDOC sfdisk "${DEV}" <<- HEREDOC
2M,,L 2M,,L
HEREDOC HEREDOC
@ -146,23 +218,23 @@ function pre_install() {
fi # if EFI firmware fi # if EFI firmware
# Encrypt the partition to install Linux # Encrypt the partition to install Linux
echo "...Initializing \"${DEV}${CRYPTPARTITION}\" as crypt partition" echo "[Kaiten-Yaki] Initializing \"${DEV}${CRYPTPARTITION}\" as crypt partition"
printf %s "${PASSPHRASE}" | cryptsetup luksFormat --iter-time "${ITERTIME}" --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 fi # if erase all
# ----- Open the LUKS partition ----- # ----- Open the LUKS partition -----
# Open the crypt partition. # Open the crypt partition.
echo "...Opening a crypt partition \"${DEV}${CRYPTPARTITION}\" as \"${CRYPTPARTNAME}\"" echo "[Kaiten-Yaki] Opening a crypt partition \"${DEV}${CRYPTPARTITION}\" as \"${CRYPTPARTNAME}\""
printf %s "${PASSPHRASE}" | cryptsetup open -d - "${DEV}${CRYPTPARTITION}" "${CRYPTPARTNAME}" printf %s "${PASSPHRASE}" | cryptsetup open -d - "${DEV}${CRYPTPARTITION}" "${CRYPTPARTNAME}"
# Check whether successful open. If mapped, it is successful. # Check whether successful open. If mapped, it is successful.
if [ ! -e /dev/mapper/"${CRYPTPARTNAME}" ] ; then if [ ! -e /dev/mapper/"${CRYPTPARTNAME}" ] ; then
cat <<- HEREDOC cat <<- HEREDOC
***** ERROR : Cannot open LUKS volume "${CRYPTPARTNAME}" on "${DEV}${CRYPTPARTITION}". ***** ***** ERROR : Cannot open LUKS volume "${CRYPTPARTNAME}" on "${DEV}${CRYPTPARTITION}". *****
...Check passphrase and your config.txt [Kaiten-Yaki] Check passphrase and your config.txt
...Installation process terminated.. [Kaiten-Yaki] Installation process terminated..
HEREDOC HEREDOC
return 1 # with error status return 1 # with error status
fi # if crypt volume is unable to open fi # if crypt volume is unable to open
@ -170,55 +242,68 @@ function pre_install() {
# ----- Configure the LVM in LUKS volume ----- # ----- Configure the LVM in LUKS volume -----
# Check volume group ${VGNAME} exist or not # Check volume group ${VGNAME} exist or not
if vgdisplay -s "${VGNAME}" &> /dev/null ; then # if exist if vgdisplay -s "${VGNAME}" &> /dev/null ; then # if exist
echo "...Volume group \"${VGNAME}\" already exist. Skipped to create. No problem." echo "[Kaiten-Yaki] Volume group \"${VGNAME}\" already exist. Skipped to create. No problem."
echo "...Activating all logical volumes in volume group \"${VGNAME}\"." echo "[Kaiten-Yaki] Activating all logical volumes in volume group \"${VGNAME}\"."
vgchange -ay vgchange -ay
echo "...Scanning all logical volumes." echo "[Kaiten-Yaki] Scanning all logical volumes."
lvscan lvscan
else else
echo "...Initializing a physical volume on \"${CRYPTPARTNAME}\"" echo "[Kaiten-Yaki] Initializing a physical volume on \"${CRYPTPARTNAME}\""
pvcreate /dev/mapper/"${CRYPTPARTNAME}" pvcreate /dev/mapper/"${CRYPTPARTNAME}"
if [ $? -ne 0 ] ; then deactivate_and_close; return 1 ; fi; if [ $? -ne 0 ] ; then deactivate_and_close; return 1 ; fi;
echo "...And then creating Volume group \"${VGNAME}\"." echo "[Kaiten-Yaki] And then creating Volume group \"${VGNAME}\"."
vgcreate "${VGNAME}" /dev/mapper/"${CRYPTPARTNAME}" vgcreate "${VGNAME}" /dev/mapper/"${CRYPTPARTNAME}"
if [ $? -ne 0 ] ; then deactivate_and_close; return 1 ; fi; if [ $? -ne 0 ] ; then deactivate_and_close; return 1 ; fi;
fi # if /dev/volume-groupt exist fi # if /dev/volume-groupt exist
# Create a SWAP Logical Volume on VG, if it doesn't exist # Create a SWAP Logical Volume on VG, if it doesn't exist
if [ -e /dev/mapper/"${VGNAME}"-"${LVSWAPNAME}" ] ; then if [ -e /dev/mapper/"${VGNAME}"-"${LVSWAPNAME}" ] ; then
echo "...Swap volume already exist. Skipped to create. No problem." echo "[Kaiten-Yaki] Swap volume already exist. Skipped to create. No problem."
else else
echo "...Creating logical volume \"${LVSWAPNAME}\" on \"${VGNAME}\"." echo "[Kaiten-Yaki] Creating logical volume \"${LVSWAPNAME}\" on \"${VGNAME}\"."
lvcreate -L "${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; if [ $? -ne 0 ] ; then deactivate_and_close; return 1 ; fi;
fi # if /dev/mapper/swap volume already exit. fi # if /dev/mapper/swap volume already exit.
# Create a ROOT Logical Volume on VG. # Create a ROOT Logical Volume on VG.
if [ -e /dev/mapper/"${VGNAME}"-"${LVROOTNAME}" ] ; then # exist if [ -e /dev/mapper/"${VGNAME}"-"${LVROOTNAME}" ] ; then # exist
if [ "${OVERWRITEINSTALL}" -ne 0 ] ; then # exist and overwrite install if [ "${OVERWRITEINSTALL}" -ne 0 ] ; then # exist and overwrite install
echo "...Logical volume \"${VGNAME}-${LVROOTNAME}\" already exists. OK." echo "[Kaiten-Yaki] Logical volume \"${VGNAME}-${LVROOTNAME}\" already exists. OK."
# Create extended volumes if needed
create_ext_lv
if [ $? -ne 0 ] ; then deactivate_and_close; return 1 ; fi;
else # exist and not overwriteinstall else # exist and not overwriteinstall
cat <<- HEREDOC cat <<- HEREDOC
***** ERROR : Logical volume "${VGNAME}-${LVROOTNAME}" already exists. ***** ***** ERROR : Logical volume "${VGNAME}-${LVROOTNAME}" already exists. *****
...Check LVROOTNAME environment variable in your config.txt. [Kaiten-Yaki] Check LVROOTNAME environment variable in your config.txt.
HEREDOC HEREDOC
# Deactivate all lg and close the LUKS volume # Deactivate all lg and close the LUKS volume
deactivate_and_close deactivate_and_close
return 1 # with error status return 1 # with error status
fi fi
else # not exsit else # not exsit
if [ "${OVERWRITEINSTALL}" -ne 0 ] ; then if [ "${OVERWRITEINSTALL}" -ne 0 ] ; then # not exist and overwrite install
cat <<- HEREDOC cat <<- HEREDOC
***** ERROR : Logical volume "${VGNAME}-${LVROOTNAME}" doesn't exist while overwrite install. ***** ***** ERROR : Logical volume "${VGNAME}-${LVROOTNAME}" doesn't exist while overwrite install. *****
...Check consistency of your config.txt. [Kaiten-Yaki] Check consistency of your config.txt.
HEREDOC HEREDOC
# Deactivate all lg and close the LUKS volume # Deactivate all lg and close the LUKS volume
deactivate_and_close deactivate_and_close
return 1 # with error status return 1 # with error status
else # not exist and not overwrite install else # not exist and not overwrite install
echo "...Creating logical volume \"${LVROOTNAME}\" on \"${VGNAME}\"." echo "[Kaiten-Yaki] Creating logical volume \"${LVROOTNAME}\" on \"${VGNAME}\"."
lvcreate -l "${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; if [ $? -ne 0 ] ; then deactivate_and_close; return 1 ; fi;
IS_ROOT_CREATED=1
# Create extended volumes if needed
create_ext_lv
if [ $? -ne 0 ] ; then deactivate_and_close; return 1 ; fi;
fi fi
fi fi
@ -253,6 +338,16 @@ function para_install_msg() {
# Root volume mapping # Root volume mapping
echo "/ : /dev/mapper/${VGNAME}-${LVROOTNAME}" echo "/ : /dev/mapper/${VGNAME}-${LVROOTNAME}"
# If USELVEXT1 exist.
if [ "${USELVEXT1}" -ne 0 ] ; then
echo "LVEXT1 : /dev/mapper/${VGNAME}-${LVROOTNAME}${LVEXT1SUFFIX}"
fi
# If USELVEXT2 exist.
if [ "${USELVEXT2}" -ne 0 ] ; then
echo "LVEXT2 : /dev/mapper/${VGNAME}-${LVROOTNAME}${LVEXT2SUFFIX}"
fi
# In case of erased storage, add this mapping # In case of erased storage, add this mapping
if [ "${ERASEALL}" -ne 0 ] ; then if [ "${ERASEALL}" -ne 0 ] ; then
echo "swap : /dev/mapper/${VGNAME}-${LVSWAPNAME}" echo "swap : /dev/mapper/${VGNAME}-${LVSWAPNAME}"
@ -272,15 +367,15 @@ function post_install() {
# ${BTRFSOPTION} is defined by the caller of this function for BTRFS formated volume. # ${BTRFSOPTION} is defined by the caller of this function for BTRFS formated volume.
# ${BTRFSOPTION} have to be NOT quoted. Otherwise, mount will receive an empty # ${BTRFSOPTION} have to be NOT quoted. Otherwise, mount will receive an empty
# string as first option, when the veraible is empty. # string as first option, when the veraible is empty.
echo "...Mounting /dev/mapper/${VGNAME}-${LVROOTNAME} on ${TARGETMOUNTPOINT}." echo "[Kaiten-Yaki] Mounting /dev/mapper/${VGNAME}-${LVROOTNAME} on ${TARGETMOUNTPOINT}."
mount ${BTRFSOPTION} /dev/mapper/"${VGNAME}"-"${LVROOTNAME}" "${TARGETMOUNTPOINT}" mount ${BTRFSOPTION} /dev/mapper/"${VGNAME}"-"${LVROOTNAME}" "${TARGETMOUNTPOINT}"
# And mount other directories # And mount other directories
echo "...Mounting all other dirs." echo "[Kaiten-Yaki] Mounting all other dirs."
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. # Copy all scripts to the target /tmp for using in chroot session.
echo "...Copying files in current dir to ${TARGETMOUNTPOINT}/tmp." echo "[Kaiten-Yaki] Copying files in current dir to ${TARGETMOUNTPOINT}/tmp."
mkdir "${TARGETMOUNTPOINT}/tmp/kaiten-yaki" mkdir "${TARGETMOUNTPOINT}/tmp/kaiten-yaki"
cp -r ./* -t "${TARGETMOUNTPOINT}/tmp/kaiten-yaki" cp -r ./* -t "${TARGETMOUNTPOINT}/tmp/kaiten-yaki"
@ -288,7 +383,7 @@ function post_install() {
# The here-document is script executed under chroot. At here we call # The here-document is script executed under chroot. At here we call
# the distribution dependent script "lib/chrooted_job_${DISTRIBUTIONSIGNATURE}.sh", # the distribution dependent script "lib/chrooted_job_${DISTRIBUTIONSIGNATURE}.sh",
# which was copied to /temp at previous code. # which was copied to /temp at previous code.
echo "...Chroot to ${TARGETMOUNTPOINT}. and execute chrooted_job_${DISTRIBUTIONSIGNATURE}.sh" echo "[Kaiten-Yaki] Chroot to ${TARGETMOUNTPOINT}. and execute chrooted_job_${DISTRIBUTIONSIGNATURE}.sh"
# shellcheck disable=SC2086 # shellcheck disable=SC2086
cat <<- HEREDOC | chroot "${TARGETMOUNTPOINT}" /bin/bash cat <<- HEREDOC | chroot "${TARGETMOUNTPOINT}" /bin/bash
cd /tmp/kaiten-yaki cd /tmp/kaiten-yaki
@ -297,14 +392,31 @@ function post_install() {
HEREDOC HEREDOC
# Unmount all. -l ( lazy ) option is added to supress the busy error. # Unmount all. -l ( lazy ) option is added to supress the busy error.
echo "...Unmounting all." echo "[Kaiten-Yaki] Unmounting all."
umount -R -l "${TARGETMOUNTPOINT}" umount -R -l "${TARGETMOUNTPOINT}"
echo "[Kaiten-Yaki] Post install process finished."
# Free LUKS volume as swap volume.
echo "[Kaiten-Yaki] Disabling swap to release the LUKS volume."
swapoff -a
# Close LUKS
echo "[Kaiten-Yaki] Deactivating all logical volumes in volume group \"${VGNAME}\"."
vgchange -a n "${VGNAME}"
echo "[Kaiten-Yaki] Closing LUKS volume \"${CRYPTPARTNAME}\"."
cryptsetup close "${CRYPTPARTNAME}"
# Deleting the passphrase information.
echo "[Kaiten-Yaki] Deleting passphrase information."
PASSPHRASE=""
export PASSPHRASE
# Finishing message # Finishing message
cat <<- HEREDOC cat <<- HEREDOC
****************** Post-install process finished ****************** ****************** Install process finished ******************
...Ready to reboot. [Kaiten-Yaki] Ready to reboot.
HEREDOC HEREDOC
return 0 return 0
@ -317,13 +429,36 @@ function post_install() {
# ******************************************************************************* # *******************************************************************************
function deactivate_and_close(){ function deactivate_and_close(){
echo "...Deactivating all logical volumes in volume group \"${VGNAME}\"."
if [ "${IS_ROOT_CREATED}" -ne 0 ] ; then # if extra volume 1 created
# Remove newly created root volume
echo "[Kaiten-Yaki] Deleting the new logical volume \"${VGNAME}-${LVROOTNAME}\"."
lvremove -f /dev/mapper/"${VGNAME}"-"${LVROOTNAME}"
fi
if [ "${IS_LVEXT1_CREATED}" -ne 0 ] ; then # if extra volume 1 created
# Remove newly created extra volume 1
echo "[Kaiten-Yaki] Deleting the new logical volume \"${VGNAME}-${LVROOTNAME}${LVEXT1SUFFIX}\"."
lvremove -f /dev/mapper/"${VGNAME}"-"${LVROOTNAME}${LVEXT1SUFFIX}"
fi
if [ "${IS_LVEXT2_CREATED}" -ne 0 ] ; then # if extra volume 2 created
# Remove newly created extra volume 2
echo "[Kaiten-Yaki] Deleting the new logical volume \"${VGNAME}-${LVROOTNAME}${LVEXT2SUFFIX}\"."
lvremove -f /dev/mapper/"${VGNAME}"-"${LVROOTNAME}${LVEXT2SUFFIX}"
fi
echo "[Kaiten-Yaki] Deactivating all logical volumes in volume group \"${VGNAME}\"."
vgchange -a n "${VGNAME}" vgchange -a n "${VGNAME}"
echo "...Closing LUKS volume \"${CRYPTPARTNAME}\"." echo "[Kaiten-Yaki] Closing LUKS volume \"${CRYPTPARTNAME}\"."
cryptsetup close "${CRYPTPARTNAME}" cryptsetup close "${CRYPTPARTNAME}"
cat <<- HEREDOC cat <<- HEREDOC
...Installation process terminated.. [Kaiten-Yaki] Installation process terminated..
HEREDOC HEREDOC
} }
@ -334,14 +469,11 @@ function deactivate_and_close(){
function on_unexpected_installer_quit(){ function on_unexpected_installer_quit(){
echo "***** ERROR : The GUI/TUI installer terminated unexpectedly. *****" echo "***** ERROR : The GUI/TUI installer terminated unexpectedly. *****"
if [ "${OVERWRITEINSTALL}" -ne 0 ] ; then # If overwrite install, keep the volume if [ "${OVERWRITEINSTALL}" -ne 0 ] ; then # If overwrite install, keep the volume
echo "...Keep logical volume \"${VGNAME}-${LVROOTNAME}\" untouched." echo "[Kaiten-Yaki] 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 fi
# Deactivate all lg and close the LUKS volume # Deactivate all lg and close the LUKS volume
deactivate_and_close deactivate_and_close
echo "...You can retry Kaiten-yaki again." echo "[Kaiten-Yaki] You can retry Kaiten-yaki again."
} }
@ -361,7 +493,7 @@ function distribution_check(){
if [ "${YESNO}" != "Y" ] && [ "${YESNO}" != "y" ] ; then if [ "${YESNO}" != "Y" ] && [ "${YESNO}" != "y" ] ; then
cat <<- HEREDOC cat <<- HEREDOC
...Installation process terminated.. [Kaiten-Yaki] Installation process terminated..
HEREDOC HEREDOC
return 1 # with error status return 1 # with error status
fi # if YES fi # if YES
@ -372,6 +504,49 @@ function distribution_check(){
return 0 return 0
} }
# *******************************************************************************
# Create extended volume, if needed.
# *******************************************************************************
function create_ext_lv() {
if [ "${USELVEXT1}" -ne 0 ] ; then # if using extra volume 1
if [ -e /dev/mapper/"${VGNAME}-${LVROOTNAME}${LVEXT1SUFFIX}" ] ; then # if extra volume 1 exist
echo "[Kaiten-Yaki] Logical volume \"${VGNAME}-${LVROOTNAME}${LVEXT1SUFFIX}\" already exists. OK."
else
echo "[Kaiten-Yaki] Creating logical volume \"${LVROOTNAME}${LVEXT1SUFFIX}\" on \"${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 ;
else # if success
IS_LVEXT1_CREATED=1 # Mark this volume is created
fi;
fi
fi
if [ "${USELVEXT2}" -ne 0 ] ; then # if using extra volume 2
if [ -e /dev/mapper/"${VGNAME}-${LVROOTNAME}${LVEXT2SUFFIX}" ] ; then # if extra volume 2 exist
echo "[Kaiten-Yaki] Logical volume \"${VGNAME}-${LVROOTNAME}${LVEXT2SUFFIX}\" already exists. OK."
else
echo "[Kaiten-Yaki] Creating logical volume \"${LVROOTNAME}${LVEXT2SUFFIX}\" on \"${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 ;
else # if success
IS_LVEXT2_CREATED=1 # Mark this volume is created
fi;
fi
fi
# no error
return 0
}
# ******************************************************************************* # *******************************************************************************
# Error report and return revsers status. # Error report and return revsers status.

View file

@ -81,13 +81,13 @@ function para_install_local() {
# Distrobution dependent message # Distrobution dependent message
cat <<- HEREDOC cat <<- HEREDOC
************************ CAUTION! CAUTION! CAUTION! **************************** **************** CAUTION! CAUTION! CAUTION! ********************
[Kaiten-Yaki]
Make sure to click "Continue Testing", at the end of the Ubiquity installer. [Kaiten-Yaki] Make sure to click "Continue Testing", at the end of
Just exit the installer without rebooting. Other wise, your system [Kaiten-Yaki] the Ubiquity installer. Just exit the installer without
is unable to boot. [Kaiten-Yaki] rebooting. Otherwise, your system becomes unable to boot.
[Kaiten-Yaki]
Type return key to start Ubiquity. [Kaiten-Yaki] Type return key to start Ubiquity.
HEREDOC HEREDOC
# waiting for a console input # waiting for a console input
@ -134,12 +134,12 @@ function grub_check_and_modify_local() {
# Make target GRUB aware to the crypt partition # Make target GRUB aware to the crypt partition
# This must do it after start of the file copy by installer, but before the end of the file copy. # This must do it after start of the file copy by installer, but before the end of the file copy.
echo "...Adding GRUB_ENABLE_CRYPTODISK entry to ${TARGETMOUNTPOINT}/etc/default/grub " echo "[Kaiten-Yaki] Adding GRUB_ENABLE_CRYPTODISK entry to ${TARGETMOUNTPOINT}/etc/default/grub "
echo "GRUB_ENABLE_CRYPTODISK=y" >> ${TARGETMOUNTPOINT}/etc/default/grub echo "GRUB_ENABLE_CRYPTODISK=y" >> ${TARGETMOUNTPOINT}/etc/default/grub
# And then, wait for the end of installer process # And then, wait for the end of installer process
echo "...Waiting for the end of GUI/TUI installer." echo "[Kaiten-Yaki] Waiting for the end of GUI/TUI installer."
echo "...Again, DO NOT reboot/restart here. Just exit the GUI/TUI installer." echo "[Kaiten-Yaki] Again, DO NOT reboot/restart here. Just exit the GUI/TUI installer."
wait $INSTALLER_PID wait $INSTALLER_PID
# succesfull return # succesfull return

View file

@ -45,17 +45,17 @@ function main() {
export GRUB_ADDITIONAL_PARAMETERS="rd.auto=1 cryptdevice=${DEV}${CRYPTPARTITION}:${CRYPTPARTNAME} root=/dev/mapper/${VGNAME}-${LVROOTNAME}" export GRUB_ADDITIONAL_PARAMETERS="rd.auto=1 cryptdevice=${DEV}${CRYPTPARTITION}:${CRYPTPARTNAME} root=/dev/mapper/${VGNAME}-${LVROOTNAME}"
if grep "$GRUB_ADDITIONAL_PARAMETERS" /etc/default/grub ; then # Is additonal parameter already added? if grep "$GRUB_ADDITIONAL_PARAMETERS" /etc/default/grub ; then # Is additonal parameter already added?
# Yes # Yes
echo ".../etc/default/grub already modified. OK, skipping to modiy." echo "[Kaiten-Yaki] /etc/default/grub already modified. OK, skipping to modiy."
else else
# Not yet. Let's add. # Not yet. Let's add.
echo "...Modify /etc/default/grub." echo "[Kaiten-Yaki] Modify /etc/default/grub."
sed -i -e "/GRUB_CMDLINE_LINUX_DEFAULT/{s#\"# ${GRUB_ADDITIONAL_PARAMETERS}\"#2}" /etc/default/grub sed -i -e "/GRUB_CMDLINE_LINUX_DEFAULT/{s#\"# ${GRUB_ADDITIONAL_PARAMETERS}\"#2}" /etc/default/grub
fi fi
# Common part of the pre-install stage # Common part of the pre-install stage
if ! pre_install ; then if ! pre_install ; then
# If error, restore the modification. # If error, restore the modification.
echo "...restoring /etc/default/grub, if needed" echo "[Kaiten-Yaki] restoring /etc/default/grub, if needed"
sed -i -e "s#${GRUB_ADDITIONAL_PARAMETERS}##" /etc/default/grub sed -i -e "s#${GRUB_ADDITIONAL_PARAMETERS}##" /etc/default/grub
return 1 # with error status return 1 # with error status
fi fi
@ -96,13 +96,13 @@ function para_install_local() {
# Distrobution dependent message # Distrobution dependent message
cat <<- HEREDOC cat <<- HEREDOC
************************ CAUTION! CAUTION! CAUTION! **************************** ******************** CAUTION! CAUTION! CAUTION! ************************
[Kaiten-Yaki]
Make sure to click "NO", if the void-installer ask you to reboot. [Kaiten-Yaki] Make sure to click "NO", if the void-installer ask you to
Just exit the installer without rebooting. Other wise, your system [Kaiten-Yaki] reboot.Just exit the installer without rebooting. Otherwise,
is unable to boot. [Kaiten-Yaki] your system becomes unable to boot.
[Kaiten-Yaki]
Type return key to start void-installer. [Kaiten-Yaki] Type return key to start void-installer.
HEREDOC HEREDOC
# waiting for a console input # waiting for a console input
@ -123,7 +123,7 @@ function para_install_local() {
# If exist, the grub was not modifyed -> void-installer termianted unexpectedly # If exist, the grub was not modifyed -> void-installer termianted unexpectedly
# Delete the nwe volume if overwrite install, and close all # Delete the nwe volume if overwrite install, and close all
on_unexpected_installer_quit on_unexpected_installer_quit
echo "...restoring modified /etc/default/grub." echo "[Kaiten-Yaki] restoring modified /etc/default/grub."
sed -i "s#loglevel=4 ${GRUB_ADDITIONAL_PARAMETERS}#loglevel=4#" /etc/default/grub sed -i "s#loglevel=4 ${GRUB_ADDITIONAL_PARAMETERS}#loglevel=4#" /etc/default/grub
return 1 # with error status return 1 # with error status
fi fi
@ -149,7 +149,7 @@ function grub_check_and_modify_local() {
# Make target GRUB aware to the crypt partition # Make target GRUB aware to the crypt partition
# This must do it after start of the file copy by installer, but before the end of the file copy. # This must do it after start of the file copy by installer, but before the end of the file copy.
echo "...Adding GRUB_ENABLE_CRYPTODISK entry to ${TARGETMOUNTPOINT}/etc/default/grub " echo "[Kaiten-Yaki] Adding GRUB_ENABLE_CRYPTODISK entry to ${TARGETMOUNTPOINT}/etc/default/grub "
echo "GRUB_ENABLE_CRYPTODISK=y" >> ${TARGETMOUNTPOINT}/etc/default/grub echo "GRUB_ENABLE_CRYPTODISK=y" >> ${TARGETMOUNTPOINT}/etc/default/grub
# succesfull return # succesfull return