1
0
mirror of https://github.com/tommytran732/Arch-Setup-Script synced 2024-11-24 10:31:34 -05:00

Add files via upload

This commit is contained in:
Tommaso Chiti 2021-01-31 14:23:32 +01:00 committed by GitHub
parent 1b6b249ae7
commit 6102ed9395
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

74
easy-arch.sh Normal file
View File

@ -0,0 +1,74 @@
#!/bin/bash
# Selecting the target for the installation.
echo "Select the disk where Arch Linux is going to be installed."
select ENTRY in $(lsblk -dpn -I 8 -oNAME);
do
DISK=$ENTRY
echo "Installing Arch Linux on $DISK."
break
done
# Deleting old partition scheme.
read -r -p "This will delete the current partition table on $DISK. Do you agree [y/N]? " response
response=${response,,}
then
if [[ "$response" =~ ^(yes|y)$ ]]
wipefs -af $DISK
sgdisk -Zo $DISK
else
echo "Quitting."
break
fi
# Creating a new partition scheme.
echo "Creating new partition scheme on $DISK."
parted -s $DISK \
mklabel gpt \
mkpart ESP fat32 1MiB 513MiB \
mkpart Cryptroot 513MiB 100% \
ESP="/dev/disk/by-partlabel/ESP"
Cryptroot="/dev/disk/by-partlabel/Cryptroot"
echo "Done."
partprobe $DISK
# Formatting the ESP as FAT32.
echo "Formatting the EFI Partition as FAT32."
mkfs.fat -F 32 $ESP
# Creating a LUKS Container for the root partition.
echo "Creating LUKS Container for the root partition."
cryptsetup --type luks1 luksFormat $Cryptroot
echo "Opening the newly created LUKS Container."
cryptsetup open $Cryptroot cryptroot
BTRFS=/dev/mapper/cryptroot
partprobe $DISK
# Formatting the LUKS Container as BTRFS.
echo "Formatting the LUKS container as BTRFS."
mkfs.btrfs $BTRFS
mount $BTRFS /mnt
# Creating BTRFS subvolumes.
echo "Creating BTRFS subvolumes."
btrfs su cr /mnt/@
btrfs su cr /mnt/@home
btrfs su cr /mnt/@snapshots
btrfs su cr /mnt/@var_log
btrfs su cr /mnt/@swap
# Mounting the newly created subvolumes.
umount /mnt
mount -o compress=zstd,subvol=@ $BTRFS /mnt
mkdir -p /mnt/{home,.snapshots,/var/log,swap,boot}
mount -o compress=zstd,subvol=@home $BTRFS /mnt/home
mount -o compress=zstd,subvol=@snapshots $BTRFS /mnt/.snapshots
mount -o nodatacow,subvol=@var_log $BTRFS /mnt/var/log
mount -o nodatacow,subvol=@swap $BTRFS /mnt/swap
mount $ESP /mnt/boot
echo "Done."