Arch-Linux-Installer/encrypt.sh

73 lines
1.5 KiB
Bash
Raw Normal View History

2022-02-12 17:05:23 +01:00
#!/bin/bash
# Get variable from filesystem.
2022-02-12 17:07:49 +01:00
part=$(</tmp/disk)2
2022-02-12 17:05:23 +01:00
# Encrypting partition.
echo "Encrypting system partition."
echo -e
2022-02-12 18:08:30 +01:00
cryptsetup -c aes-xts-plain -y -s 512 luksFormat /dev/$part &&
2022-02-12 17:05:23 +01:00
echo "Partition successfully encrypted."
2022-02-12 17:07:49 +01:00
echo -e
2022-02-12 17:05:23 +01:00
# Opening encrypted partition and mounting at /dev/mapper/lvm.
echo "Opening and mounting encrypted partition."
echo -e
2022-02-12 17:07:49 +01:00
2022-02-12 18:08:30 +01:00
cryptsetup luksOpen /dev/$part lvm &&
2022-02-12 17:07:49 +01:00
echo "Partition opened and mounted:"
echo -e
disk="${part%?}"
lsblk | grep "$disk"
2022-02-12 17:51:08 +01:00
echo -e
# Creating physical volume.
echo "Creating physical volume."
pvcreate /dev/mapper/lvm &&
echo -e
# Creating volume group "main".
2022-02-12 18:08:30 +01:00
echo "Creating volume group."
2022-02-12 17:51:08 +01:00
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
2022-02-12 18:21:17 +01:00
lvcreate -L ${root}G -n root main &&
lvcreate -l 100%FREE -n home main &&
echo -e
echo "Logical volumes successfully created."
echo -e
echo "Creating the filesystem."
echo -e
boot=$(</tmp/disk)1
mkfs.fat -F 32 -n UEFI /dev/$boot &&
echo "Filesystem for boot successfully created."
echo -e
mkfs.ext4 -L root /dev/mapper/main-root &&
echo "Filesystem for root successfully created."
echo -e
mkfs.ext4 -L home /dev/mapper/main-home &&
echo "Filesystem for home successfully created."
echo -e