Compare commits

...

62 commits
v1.1.0 ... main

Author SHA1 Message Date
Suikan
fd5a51a070 Update CHANGELOG for v1.3.1 2023-04-15 07:13:14 +09:00
Seiichi "Suikan" Horie
851bfe6544
Merge pull request #43 from uraza/main
Partition names should be prefixed by "p" for NVMe
2023-04-15 07:04:06 +09:00
Uraza
b5adafafe6
Partition names should be prefixed by "p" for NVMe 2023-04-11 20:08:59 +00:00
Seiichi "Suikan" Horie
809dafa70c
Merge pull request #40 from suikan4github/develop
Merge Develop for v1.3.0
2022-05-15 10:17:54 +09:00
Suikan
09ae43b7c1 Changed README.md
"maintained" -> "tested"
2022-05-15 10:15:51 +09:00
Suikan
353a9dd8b4 Preparing release of the v1.3.0 2022-05-14 08:33:21 +09:00
Suikan
ecbafb4a6d Update README.md for v1.3.0 2022-05-12 07:54:33 +09:00
Suikan
70fa79a8d5 Issue #39 : Change message style
https://github.com/suikan4github/kaiten-yaki/issues/39
2022-05-11 07:30:19 +09:00
Suikan
73b3329cd7 Add "[Kaiten-Yaki]" to the message header 2022-05-11 07:16:08 +09:00
Suikan
555bf5a38e Refactor the closing sequence.
All closing sequence is gathered to the post-install().
2022-05-10 22:22:30 +09:00
Suikan
f725af8f44 Issue 38 : "Ready to reboot" message should be changed
https://github.com/suikan4github/kaiten-yaki/issues/38
2022-05-10 21:25:51 +09:00
Suikan
316131c2b3 Merge branch 'feature/36' into develop 2022-05-08 12:29:32 +09:00
Suikan
4a69ef1db6 Correct the informaiton in CHANGELOG.
Issue 33 was written as 35. It was mistake.
2022-05-08 12:28:41 +09:00
Suikan
b81ec5667c Record #36 to CHANGELOG.
Issue 36 : Clear the PASSPHRASE variable at the end of installation
https://github.com/suikan4github/kaiten-yaki/issues/36
2022-05-08 12:26:57 +09:00
Suikan
6722b160cb Clear passphrase information before exit. 2022-05-08 12:25:24 +09:00
Suikan
27a64ba066 Issue 34 : BIOS support should be obsoleted
This is still documented only. Functionality exists. Just not tested anymore.
https://github.com/suikan4github/kaiten-yaki/issues/34
2022-05-08 08:51:20 +09:00
Suikan
d45481b194 Update installatin and readme. 2022-05-08 07:44:13 +09:00
Suikan
d324960448 Merge branch 'feature/35' into develop
For issue #33 ( not 35! )
Support "M/G/T" as size prefix
2022-05-08 05:55:08 +09:00
Suikan
d7b319a89f Update CHANGELOG for feature/33 2022-05-08 05:53:44 +09:00
Suikan
425181aff1 Fix the duplicate awk match.
Now, it exits the process when the first pattern is procesed.
2022-05-07 22:02:42 +09:00
Suikan
d322e8d5c5 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.
2022-05-07 21:35:29 +09:00
Suikan
f0f081ad34 Modify to accespt the absolute volume size. 2022-05-07 21:05:47 +09:00
Suikan
b8db4d4977 Merge branch 'feature/35' into develop 2022-05-07 14:54:51 +09:00
Suikan
03a294b407 Unsed variables are removed
Issue #35 Remove XTERMFONTSIZE variable.
https://github.com/suikan4github/kaiten-yaki/issues/35
2022-05-07 14:53:31 +09:00
Suikan
ac709e1513 Removed GUIENV variable. It is not used anymore. 2022-05-07 14:48:01 +09:00
Suikan
64e2edd173 Removed XTERMFONTSIZE variable.
This variable is not used anymore.
2022-05-07 14:44:45 +09:00
Suikan
5ed04d3a0a Merge branch 'feature/32' into develop 2022-05-07 14:40:56 +09:00
Suikan
91cc1c3857 Add swap off to the script.
At the end of the main() function of the scripts, added swapoff -a.

Issue 32 : Ubuntu 22.04 fails to deactivate the swap
https://github.com/suikan4github/kaiten-yaki/issues/32
2022-05-07 14:39:41 +09:00
Suikan
7d3abc56b0 Add swapoff -a 2022-05-07 14:38:38 +09:00
Suikan
eb6f0eef0f test subdirectory is removed. 2022-05-07 14:34:47 +09:00
Suikan
121f1950b8 Update CHANGELOG to describe issue #31.
Issue 31 : Add extra partition functionality.
https://github.com/suikan4github/kaiten-yaki/issues/31
2022-05-07 14:30:52 +09:00
Suikan
3aef04ab97 Merge branch 'feature/31' into develop 2022-05-07 14:27:34 +09:00
Suikan
f6d43382fe Move lvremove.
To simplify, removing new voluves are gathered to deactivate_and remove.
2022-05-07 08:41:18 +09:00
Suikan
8cd947c912 fixed behavior of lvext
When overwrite installing, the lvext# were not created.

The detection of the error processing was
 refactored to use the global variable to see the newly created or not.
2022-05-06 08:44:16 +09:00
Suikan
a21470f594 Correct the display of the LVEXT1,2 2022-05-05 23:47:17 +09:00
Suikan
9ef15cc1f1 Add display of the additional volumes.
The user
2022-05-05 23:32:48 +09:00
Suikan
ed48590821 Test update. 2022-05-05 23:20:30 +09:00
Suikan
4699f87cc7 Add test script for development 2022-03-02 07:24:56 +09:00
Suikan
0f8cc7dbb1 Merge branch 'develop' into main for v1.2.0 releae 2021-10-16 07:52:37 +09:00
Suikan
fdfd8953d5 Update README and CHANGELOG
prepare to release v1.2.0
2021-10-16 07:51:31 +09:00
Suikan
95820a63d7 Change > to >>
Item should be added to /etc/dracut.conf.d/10-crypt.conf ,
 rather than be overwritten

 Issue #29
2021-07-28 08:22:45 +09:00
Suikan
2a7d5ff125 Update comment
For keyfile registration to initfsram
2021-07-24 15:22:25 +09:00
Suikan
44bb28e50a Refine the INSTALL.md 2021-07-23 08:17:47 +09:00
Suikan
47bfcac6cc Refinet the configuration parameter display 2021-07-21 21:14:59 +09:00
Suikan
f92e092295 Fixed link to wiki. 2021-07-21 09:31:55 +09:00
Suikan
00d506a017 Removed applicaiton notes.
Move application notes to Wiki

  Issue #28
2021-07-21 09:27:45 +09:00
Suikan
e0ff77c549 Explain the target is AMD64 explicitly. 2021-07-21 05:44:21 +09:00
Suikan
9bf7f36be8 Merge branch 'feature/27' into develop 2021-07-18 21:59:53 +09:00
Suikan
73c2e1e2e2 Update the INSTALL.md and CHANGELOG.md
Eliminates the confirmation dialog #27
2021-07-18 21:59:43 +09:00
Suikan
8bf48b9b0c Refine the parameter printing. 2021-07-18 21:53:48 +09:00
Suikan
36acfe505b Removed Y/N confirmation
Eliminates the confirmation dialog
 Issue #27
2021-07-18 21:11:26 +09:00
Suikan
fd6663d2f3 Add btrfs support in the README. 2021-07-17 16:00:03 +09:00
Suikan
d5e113259f Refactoring: Sourcing config.sys is not needed in the chrooted_job
#25
2021-07-17 15:05:43 +09:00
Suikan
e1e67af67c Correct spell. 2021-07-17 14:40:35 +09:00
Suikan
3bb2a5622c Update AN01 for btrfs
Issue #26
2021-07-17 14:38:01 +09:00
Suikan
885ac34a5a Merge branch 'feature/24' into develop 2021-07-12 23:12:27 +09:00
Suikan
ea1a1ae7fd Test OK
Fail to install the ubuntu when the / volume is btrfs
 #24

 Tested on Ubuntu and Void Linux. Btrfs and ext4.
2021-07-12 23:12:17 +09:00
Suikan
3c7691db07 Fix the blank option problem. 2021-07-12 22:03:36 +09:00
Suikan
47b40316c0 btrfs support
Fail to install the ubuntu when the / volume is btrfs
 #24
2021-07-12 17:55:02 +09:00
Seiichi "Suikan" Horie
c126247add
Merge pull request #23 from suikan4github/develop
Merege Develop as v1.1.0 release
2021-07-11 15:55:34 +09:00
Seiichi "Suikan" Horie
858dadff8f
Merge pull request #4 from suikan4github/develop
Merge Develop as hot fix
2021-07-03 12:41:52 +00:00
Seiichi "Suikan" Horie
2aef4ae4a9
Merge pull request #3 from suikan4github/develop
Merge Develop to main to release
2021-07-03 12:36:50 +00:00
16 changed files with 522 additions and 449 deletions

View file

@ -9,6 +9,53 @@ Record of the modification in project development.
### Fixed ### Fixed
### Known Issue ### Known Issue
## [1.3.1] - 2023-04-15
### Added
### Changed
### Deprecated
### Removed
### Fixed
- [Issue 43 : Partition names should be prefixed by "p" for NVMe](https://github.com/suikan4github/kaiten-yaki/pull/43). Thank you Uraza for your contribution.
### 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
### Added
### Changed
- [Issue 25 : Refactoring: Sourcing config.sys is not needed in the chrooted_job](https://github.com/suikan4github/kaiten-yaki/issues/25)
- [Issue 26 : Update AN01 for btrfs](https://github.com/suikan4github/kaiten-yaki/issues/26)
- [Issue 27 : Eliminates the confirmation dialog](https://github.com/suikan4github/kaiten-yaki/issues/27)
### Deprecated
### Removed
- [Issue 28 : Move application notes to Wiki](https://github.com/suikan4github/kaiten-yaki/issues/28)
### Fixed
- [Issue 24 : Fail to install the ubuntu when the / volume is btrfs](https://github.com/suikan4github/kaiten-yaki/issues/24)
- [Issue 29 : Item should be added to /etc/dracut.conf.d/10-crypt.conf , rather than be overwritten](https://github.com/suikan4github/kaiten-yaki/issues/29)
### Known Issue
## [1.1.0] - 2021-07-11 ## [1.1.0] - 2021-07-11
Added ITERTIME parameter and corrected other small issues. Application notes AN01 - AN04 are added. Added ITERTIME parameter and corrected other small issues. Application notes AN01 - AN04 are added.
The Followings are tested distributions The Followings are tested distributions
@ -57,6 +104,9 @@ 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.1.0...develop [Unreleased]: https://github.com/suikan4github/kaiten-yaki/compare/v1.3.0...develop
[1.3.1]: https://github.com/suikan4github/kaiten-yaki/compare/v1.3.0...v1.3.1
[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.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

@ -9,31 +9,32 @@ You can execute the install script without the command line parameter. For examp
```sh ```sh
source ubuntu-kaiten-yaki.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. 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.sh carefully.
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. 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 configure the target Linux system to decrypt the encrypted volume automatically, without prompting user to type passphrase. In this stage, Everything is automatic. The third stage configures the target Linux system to decrypt the encrypted volume automatically, without prompting user to type passphrase. In this stage, Everything is automatic.
# Installation # Installation
Follow the steps below. Follow the steps below.
## Shell preparation ## Shell preparation
First of all, promote the shell to root. Almost of the procedure in the installation requires root privilege. Note that the scripts require Bash. First of all, promote the shell to root. Kaiten-yaki script requires root permission to edit the storage device. Note that the scripts require Bash as shell.
In the case of Ubuntu installation: In the case of Ubuntu installation:
```bash ```sh
# Promote to the root user # Promote to the root user
sudo -i /bin/bash sudo -i /bin/bash
``` ```
In the case of Void Linux installation: In the case of Void Linux installation:
```bash ```sh
# Promote to the root user
sudo -i /bin/bash sudo -i /bin/bash
xbps-install -Su xbps nano 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. The nano is an editor package to configure the config.sh. The choice of editor is up to you. Kaiten-yaki script doesn't have a dependency on nano editor.
And then, go to the kaiten-yaki/script directory. And then, go to the kaiten-yaki/script directory.
```bash ```sh
cd /the/downloaded/directory/kaiten-yaki/script cd /the/downloaded/directory/kaiten-yaki/script
``` ```
Now, ready to configure. Now, ready to configure.
@ -43,13 +44,14 @@ This is a very critical part of the installation. The configuration parameters a
Followings are the set of the default settings of the parameters : Followings are the set of the default settings of the parameters :
- Install to **/dev/sda** (DEV). - Install to **/dev/sda** (DEV).
- Do not erase the entire disk (ERASEALL). - Do not erase the entire disk (ERASEALL).
- Overwrite install is disabled. - Do not overwrite the existing logical volume (OVERWRITEINSTALL).
- 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).
```bash ```sh
# Configuration parameters for Kaiten-Yaki # Configuration parameters for Kaiten-Yaki
# Storage device to install the linux. # Storage device to install the linux.
@ -64,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"
@ -91,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
@ -120,29 +162,51 @@ And set the following parameters as same as the previous installation.
- VGNAME - VGNAME
- CRYPTPARTNAME - CRYPTPARTNAME
Kaiten-yaki will leave the "bad" logical volume and allow you to overwrite it by GUI/TUI installer. Kaiten-yaki will leave the LUKS encrypted partition and allow you to overwrite the "bad" logical volume by GUI/TUI installer.
### About ITERTIME parameter ### About ITERTIME parameter
This parameter is recommended to left as default value (=0), unless you understand what it mean well. 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 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. See [AN03](https://github.com/suikan4github/kaiten-yaki/wiki/AN03:-The-ITERTIME-parameter-and-vulnerability)
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 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. 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.
In the case of Ubuntu : In the case of Ubuntu :
```bash ```sh
source ubuntu-kaiten-yaki.sh source ubuntu-kaiten-yaki.sh
``` ```
In the case of Void Linux In the case of Void Linux
```bash ```sh
source void-kaiten-yaki.sh 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, except the first distribution installation. After printing the configuration parameters, Kaiten-yaki will prompt 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 case of the ERASEALL configuration parameter is 1.
## Second stage : GUI/TUI installer ## 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. After the first script finishes, the GUI/TUI installer starts automatically. Configure it as usual and run it. Ensure you map the following correctly.
@ -152,12 +216,12 @@ Target Directory | Host Volume | Comment
/ | /dev/mapper/vg1-ubuntu | Host volume name is up to your configuration parameter. / | /dev/mapper/vg1-ubuntu | Host volume name is up to your configuration parameter.
swap | /dev/mapper/swap | Only the first distribution installation requires this mapping. swap | /dev/mapper/swap | Only the first distribution installation requires this mapping.
During the GUI/TUI installer copying files, Kaiten-yaki modifies the /etc/default/grub of the target system. This is the pretty dirty way. But if we don't modify this file, GUI/TUI installer fails at last. During the GUI/TUI installer copying files, Kaiten-yaki modifies the /etc/default/grub of the target system. This is a pretty dirty way. But if we don't modify this file, GUI/TUI installer fails at last.
![Ubuntu Partitioning](image/ubuntu_partitioning.png) ![Ubuntu Partitioning](image/ubuntu_partitioning.png)
![Void Partitioning](image/void_partitioning.png) ![Void Partitioning](image/void_partitioning.png)
## Do not reboot ### Do not reboot
At the end of the GUI/TUI installing, do not reboot the system. Click "Continue" and just exit the GUI/TUI installer without rebooting. Otherwise, we cannot finalize the entire installation process. At the end of the GUI/TUI installing, do not reboot the system. Click "Continue" and just exit the GUI/TUI installer without rebooting. Otherwise, we cannot finalize the entire installation process.
![Ubuntu done](image/ubuntu_done.png) ![Ubuntu done](image/ubuntu_done.png)
@ -166,7 +230,7 @@ At the end of the GUI/TUI installing, do not reboot the system. Click "Continue"
## Third stage: Finalizing ## Third stage: Finalizing
After GUI/TUI installer quits without rebooting, the final part of the install process automatically starts. 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. Thus, 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 initramfs image to allow the Linux kernel decrypting the LUKS partition which contains root logical volume. Thus, the system will ask you the passphrase only once when GRUB starts.
You can reboot the system if you see the "Ready to reboot" message on the console. You can reboot the system if you see the "Ready to reboot" message on the console.

View file

@ -1,16 +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 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.
- The "/boot" is located in the same logical volume as the "/". - Support btrfs in addition to the major file systems.
- The swap logical volume is located inside the encrypted volume. - The "/boot" is located in the same encrypted logical volume with the "/".
- You need to type a passphrase only once in the boot sequence. - The swap is located in the same encrypted logical volume with the "/".
- 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.
@ -24,11 +25,17 @@ 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.2 amd64 desktop - Ubuntu 20.04.3 amd64 desktop
- Ubuntu 21.04 amd64 desktop - Ubuntu 21.04 amd64 desktop
- Ubuntu Mate 20.04.2 amd64 desktop - Ubuntu 21.10 amd64 desktop
- Ubuntu Mate 20.04.3 amd64 desktop
- void-live-x86_64-20210218-mate.iso - void-live-x86_64-20210218-mate.iso
- void-live-x86_64-musl-20210218-mate.iso - void-live-x86_64-musl-20210218-mate.iso
- void-live-x86_64-20210218.iso - void-live-x86_64-20210218.iso
@ -41,17 +48,11 @@ 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.
# Application notes # Other resources
- [AN01 : How to recover from the mistyping of the passphrase](appnote/an01_howtorecover.md) See [Wiki](https://github.com/suikan4github/kaiten-yaki/wiki) for the application notes and the useful links.
- [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 # 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. 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.

View file

@ -1,62 +0,0 @@
# 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 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)
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. The user can recover by 3 commands from this mode.
```
cryptomount -a
insmod normal
normal
```
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 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.
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.
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.
```
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. 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.
```
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)
## 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)

View file

@ -1,83 +0,0 @@
# 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.
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 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 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 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 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
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 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 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
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.
```sh
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
```sh
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.
```sh
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.

View file

@ -1,48 +0,0 @@
# 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, 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.
## 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 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 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 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 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 ).
## 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.

View file

@ -1,44 +0,0 @@
# 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 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 EFI systems, respectively.
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/sda.
```sh
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=5
else
# BIOS firmware
export CRYPTPARTITION=5
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 "${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
source kaiten-yaki-ubuntu
```
All other operations are same with usual install.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.1 KiB

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. !!!!!!!!!!!!!!
@ -54,20 +87,20 @@ else
export ISEFI=0 # No, BIOS export ISEFI=0 # No, BIOS
fi # is EFI firmaare? fi # is EFI firmaare?
# Detect drive type.
# For NVME drives, partition names should be prefixed by p.
if [[ ${DEV} == *"nvme"* ]] ; then
export PARTPREFIX="p" # Yes, NVME
else
export PARTPREFIX="" # No, regular
fi
# Set partition number based on the firmware type # Set partition number based on the firmware type
if [ ${ISEFI} -ne 0 ] ; then if [ ${ISEFI} -ne 0 ] ; then
# EFI firmware # EFI firmware
export EFIPARTITION=1 export EFIPARTITION=${PARTPREFIX}1
export CRYPTPARTITION=2 export CRYPTPARTITION=${PARTPREFIX}2
else else
# BIOS firmware # BIOS firmware
export CRYPTPARTITION=1 export CRYPTPARTITION=${PARTPREFIX}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

@ -1,16 +1,12 @@
#!/bin/bash #!/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 # Create a key file for LUKS and register it as contents of the initramfs image
function chrooted_job() { function chrooted_job() {
# Mount the rest of partitions by target /etc/fstab # Mount the rest of partitions by target /etc/fstab
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.
@ -18,27 +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 initfsram. # Add key file to the list of the intems in initramfs.
echo "...Registering key file to the ramfs" # See https://cryptsetup-team.pages.debian.net/cryptsetup/README.initramfs.html for detail
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

@ -1,16 +1,12 @@
#!/bin/bash #!/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 # Create a key file for LUKS and register it as contents of the initramfs image
function chrooted_job() { function chrooted_job() {
# Mount the rest of partitions by target /etc/fstab # Mount the rest of partitions by target /etc/fstab
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.
@ -18,28 +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 initfsram. # Add key file to the list of the intems in initramfs.
echo "...Registering key file to the ramfs" # See https://man7.org/linux/man-pages/man5/dracut.conf.5.html for details.
echo 'install_items+=" /etc/luks/boot_os.keyfile /etc/crypttab " ' > /etc/dracut.conf.d/10-crypt.conf 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
# 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.
@ -57,55 +85,50 @@ function confirmation(){
# For surre ask the your config.sh is edited # For surre ask the your config.sh is edited
cat <<- HEREDOC cat <<- HEREDOC
The destination logical volume label is "${LVROOTNAME}" LUKS volume partition : ${DEV}${CRYPTPARTITION}
"${LVROOTNAME}" uses ${LVROOTSIZE} of the LVM volume group. LUKS volume name : "${CRYPTPARTNAME}"
Are you sure to install? [Y/N] Volume group name : "${VGNAME}"
Root volume name : "${VGNAME}-${LVROOTNAME}"
Root volume size : "${LVROOTSIZE}"
HEREDOC HEREDOC
read -r YESNO
if [ "${YESNO}" != "Y" ] && [ "${YESNO}" != "y" ] ; then if [ "${USELVEXT1}" -ne 0 ] ; then
cat <<- HEREDOC cat <<- HEREDOC
Extra volume name 1 : "${VGNAME}-${LVROOTNAME}${LVEXT1SUFFIX}"
...Installation process terminated.. 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 size : "${LVSWAPSIZE}"
--iter-time parameter : ${ITERTIME}
HEREDOC HEREDOC
return 1 # with error status
fi # if YES
# For sure ask to erase.
if [ "${ERASEALL}" -ne 0 ] ; then if [ "${ERASEALL}" -ne 0 ] ; then
echo "Are you sure you want to erase entire \"${DEV}\"? [Y/N]" echo "[Kaiten-Yaki] Going to erase entire disk ${DEV}."
read -r YESNO elif [ "${OVERWRITEINSTALL}" -ne 0 ] ; then
if [ "${YESNO}" != "Y" ] && [ "${YESNO}" != "y" ] ; then echo "[Kaiten-Yaki] Going to overwrite the logical volume \"${VGNAME}-${LVROOTNAME}\"."
cat <<-HEREDOC else
...Check your config.sh. The variable ERASEALL is ${ERASEALL}. echo "[Kaiten-Yaki] Going to create a new logical volume \"${VGNAME}-${LVROOTNAME}\"."
fi
...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 ----- # ----- 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
@ -113,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
} }
@ -129,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
@ -136,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
@ -156,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
@ -168,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
@ -192,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
@ -275,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}"
@ -291,15 +364,18 @@ function para_install_msg() {
function post_install() { function post_install() {
## Mount the target file system ## Mount the target file system
# ${TARGETMOUNTPOINT} is created by the GUI/TUI installer # ${TARGETMOUNTPOINT} is created by the GUI/TUI installer
echo "...Mounting /dev/mapper/${VGNAME}-${LVROOTNAME} on ${TARGETMOUNTPOINT}." # ${BTRFSOPTION} is defined by the caller of this function for BTRFS formated volume.
mount /dev/mapper/"${VGNAME}"-"${LVROOTNAME}" "${TARGETMOUNTPOINT}" # ${BTRFSOPTION} have to be NOT quoted. Otherwise, mount will receive an empty
# string as first option, when the veraible is empty.
echo "[Kaiten-Yaki] Mounting /dev/mapper/${VGNAME}-${LVROOTNAME} on ${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"
@ -307,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
@ -316,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
@ -336,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
} }
@ -353,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."
} }
@ -380,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
@ -391,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

@ -53,6 +53,15 @@ function main() {
# Post-install stage # Post-install stage
# ******************************************************************************* # *******************************************************************************
# If the target volume is formated by btrfs, Ubiquity install the root into the
# @ sub-volume. Thus, mount command inside post_install have to use special option
# to specify @ as mount target.
if lsblk -o NAME,FSTYPE | grep -i "${VGNAME}-${LVROOTNAME}" | grep -i "btrfs" > /dev/null ; then
export BTRFSOPTION="-o subvol=@"
else
export BTRFSOPTION=""
fi
# Distribution dependent finalizing. Embedd encryption key into the ramfs image. # Distribution dependent finalizing. Embedd encryption key into the ramfs image.
# The script is parameterized by env-variable to fit to the distribution # The script is parameterized by env-variable to fit to the distribution
post_install post_install
@ -72,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
@ -125,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
@ -74,6 +74,9 @@ function main() {
# Post-install stage # Post-install stage
# ******************************************************************************* # *******************************************************************************
# We don't need special option for BTRFSOPTION.
export BTRFSOPTION=""
# Distribution dependent finalizing. Embedd encryption key into the ramfs image. # Distribution dependent finalizing. Embedd encryption key into the ramfs image.
# The script is parameterized by env-variable to fit to the distribution # The script is parameterized by env-variable to fit to the distribution
post_install post_install
@ -93,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
@ -120,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
@ -146,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