feat: add lvm support

This commit is contained in:
Price Hiller 2022-07-30 04:04:46 -05:00
parent 1704b08bb9
commit af8bbde6df

View File

@ -24,7 +24,7 @@ confirmation() {
}
print-break() {
local green=
local green
green="$(tput setaf 2)"
local reset
reset="$(tput sgr0)"
@ -283,44 +283,32 @@ main() {
fi
printf "Writing new partitions to %s\n" "${i_selected_disk}" >&2
partition-disk "${selected_disk}"
printf "Successfully wrote partitions to %s\n" "${i_selected_disk}" >&2
local boot_partion="${selected_disk}${DISK_PARTITION_LETTER}${BOOT_PARTITION_NUMBER}"
local root_partition="${selected_disk}${DISK_PARTITION_LETTER}${ROOT_PARTITION_NUMBER}"
mkfs.vfat -F32 -n EFI "${boot_partion}"
printf "Successfully wrote partitions to %s\n" "${i_selected_disk}" >&2
print-break
print-title "Partition Encryption"
printf "Encrypting %s\n" "$(important "${root_partition}")" >&2
cryptsetup -y -v luksFormat "${root_partition}" || exit
printf "Opening encrypted device %s\n" \
"${i_selected_disk}" >&2
"$(important "${root_partition}")" >&2
cryptsetup open "${root_partition}" cryptroot || exit
mkfs.fat -F 32 "${boot_partion}"
mkfs.ext4 "/dev/mapper/cryptroot"
printf "Configuring LVM\n" >&2
pvcreate /dev/mapper/cryptroot
vgcreate vg0 /dev/mapper/cryptroot
lvcreate --size 16G vg0 --name swap
lvcreate -l +100%FREE vg0 --name root
printf "Writing filesystems\n" >&2
mkfs.ext4 -L root "/dev/mapper/vg0-root"
mkswap /dev/mapper/vg0-swap
print-break
print-title "Configure Swap"
local mem_amount_kb
mem_amount_kb="$(grep MemTotal /proc/meminfo | tr -s " " | cut -d " " -f2)"
mem_amount_mb=$((mem_amount_kb / 1024))
# Space to swap is taken from fedora guidelines:
# https://docs.fedoraproject.org/en-US/Fedora/22/html/Installation_Guide/sect-installation-gui-manual-partitioning-recommended.html
if ((mem_amount_mb < 2048)); then
mem_amount_kb=$((mem_amount_kb * 3 / 1024))
elif ((mem_amount_mb < 8192)); then
mem_amount_kb=$((mem_amount_kb * 2 / 1024))
elif ((mem_amount_mb < 65536)); then
mem_amount_kb=$((mem_amount_kb * 3 / 2 / 1024))
fi
printf "Creating swap file with memory amount: %s mebibytes\n" "$(important "${mem_amount_kb}")"
dd if=/dev/zero of=/mnt/swapfile bs=1M count="${mem_amount_kb}" status=progress
chmod 600 /mnt/swapfile
mkswap /mnt/swapfile
swapon /mnt/swapfile
printf "Finished creating swapfile\n" >&2
print-title "Install Arch Into Encrypted Volume"
printf "Mounting Needed Directores\n" >&2
mount /dev/mapper/cryptroot /mnt
mount /dev/mapper/vg0-root /mnt
swapon /dev/mapper/vg0-swap
mkdir /mnt/boot
mount "${boot_partion}" /mnt/boot
printf "Doing Pacstrap\n" >&2