Manage partition according to grub

This commit is contained in:
gardouille 2020-12-10 22:26:44 +01:00
parent e8900c1aec
commit db305d20a2
Signed by: gardouille
GPG Key ID: E759BAA22501AF32
1 changed files with 23 additions and 12 deletions

35
debian/chroot.install vendored
View File

@ -26,7 +26,7 @@ manage_luks=1
## You need to set a new passphrase after the installation or at least change this one
luks_passphrase="generic key"
luks_key_file="/tmp/luks.keyfile.temp"
luks_pv_name=$(basename "${hdd}"2_crypt)
luks_pv_name=$(basename "${hdd}"_crypt)
## If the script should manage everything (partition, package,…) related to grub
manage_grub=0
## Colors definition {{{
@ -63,25 +63,36 @@ if [ "${manage_part}" -eq 0 ]; then
## Recreate partition (/boot and LV) {{{
### Partition type
parted "${hdd}" mklabel msdos || exit 1
### /boot
parted "${hdd}" mkpart primary 0% 512MB || exit 1
parted "${hdd}" set 1 boot on
### LV
parted "${hdd}" mkpart primary 512MB 100% || exit 1
parted "${hdd}" set 2 lvm on
if [ "${manage_grub}" -eq 0 ]; then
### /boot
parted "${hdd}" mkpart primary 0% 512MB || exit 1
parted "${hdd}" set 1 boot on
mkfs.ext3 -F -L boot -- "${hdd}"1 || exit 4
### LV
root_part_id="2"
parted "${hdd}" mkpart primary 512MB 100% || exit 1
parted "${hdd}" set "${root_part_id}" lvm on
else
### LV
root_part_id="1"
parted "${hdd}" mkpart primary 0% 100% || exit 1
parted "${hdd}" set "${root_part_id}" lvm on
fi
if [ "${manage_luks}" -eq 0 ]; then
rm -f -- "${luks_key_file}" && printf '%b' "${luks_passphrase}" > "${luks_key_file}"
cryptsetup -c aes-xts-plain64 -s 512 --use-random -y luksFormat "${hdd}"2 "${luks_passphrase}" --key-file "${luks_key_file}" || exit 2
cryptsetup luksOpen "${hdd}"2 "${luks_pv_name}" --key-file "${luks_key_file}" || exit 2
cryptsetup -c aes-xts-plain64 -s 512 --use-random -y luksFormat "${hdd}${root_part_id}" "${luks_passphrase}" --key-file "${luks_key_file}" || exit 2
cryptsetup luksOpen "${hdd}${root_part_id}" "${luks_pv_name}" --key-file "${luks_key_file}" || exit 2
pvcreate /dev/mapper/"${luks_pv_name}" || exit 3
vgcreate "${vgname}" /dev/mapper/"${luks_pv_name}" || exit 3
else
pvcreate "${hdd}"2 || exit 3
vgcreate "${vgname}" "${hdd}"2 || exit 3
pvcreate "${hdd}${root_part_id}" || exit 3
vgcreate "${vgname}" "${hdd}${root_part_id}" || exit 3
fi
fi
mkfs.ext3 -F -L boot -- "${hdd}"1 || exit 4
## }}}
## Create Logical Volumes {{{