Arch-Linux-Installer/encrypt.sh

51 lines
1.1 KiB
Bash

#!/bin/bash
# Get variable from filesystem.
part=$(</tmp/disk)2
# Encrypting partition.
echo "Encrypting system partition."
echo -e
cryptsetup -c aes-xts-plain -y -s 512 luksFormat /dev/$part &&
echo "Partition successfully encrypted."
echo -e
# Opening encrypted partition and mounting at /dev/mapper/lvm.
echo "Opening and mounting encrypted partition."
echo -e
cryptsetup luksOpen /dev/$part lvm &&
echo "Partition opened and mounted:"
echo -e
disk="${part%?}"
lsblk | grep "$disk"
echo -e
# Creating physical volume.
echo "Creating physical volume."
pvcreate /dev/mapper/lvm &&
echo -e
# Creating volume group "main".
echo "Creating volume group."
vgcreate main /dev/mapper/lvm &&
echo -e
# Creating logical volumes.
echo "Creating logical volumes for root and home."
echo -e
# Lol, this part:
part=$(</tmp/disk)2 && i=( $(lsblk | grep "$part" | tail -n+1 | awk '{print $4}') ) && size="${i%?}"
echo "Your system partition has a size of $size GB."
echo "What size should your root partition have?"
#read root
echo "Creating a $root GB root volume."
echo -e
lvcreate -L "${root}G" -n root main
lvcreate -l 100%FREE -n home main