Btrfs is now the default install.sh.

This commit is contained in:
proledatarian 2022-04-26 15:52:51 +00:00
parent 3dde2e5f2a
commit f2449e9cf5
2 changed files with 120 additions and 120 deletions

View File

@ -13,6 +13,8 @@
# $pwur = user password
# $pwrt = root password
# $pwcr = encryption password
# $pwfr = password first
# $pwsc = password second
# Friendly introduction.
echo "Welcome to the Arch Linux installation script!"
@ -54,6 +56,14 @@ IFS=' '
# Create new variable of selection.
array=($dev)
dev="${array[0]}"
szmn="${array[1]%?}"
# Setting partition size.
echo "Your system partition has a size of $szmn GB."
echo "What size should your root volume have (GB)?"
echo "The rest will be used for your home volume."
read szrt
echo
echo "2. ENCRYPTION"
echo
@ -72,6 +82,8 @@ then
else
echo
echo "You have entered different passwords. Try again.."
echo
continue
fi
break
done
@ -90,7 +102,7 @@ echo
# Setting root password.
echo "Choose a password for the root account:"
while [ -z "$pwr" ]; do
while [ -z "$pwrt" ]; do
echo "Please enter a password: "
read -s pwfr
read -s -p "Retype a password: " pwsc
@ -102,6 +114,8 @@ then
else
echo
echo "You have entered different passwords. Try again.."
echo
continue
fi
break
done
@ -117,7 +131,7 @@ echo
# Setting user password.
echo "Also please choose a password for your user:"
while [ -z "$pwu" ]; do
while [ -z "$pwur" ]; do
echo "Please enter a password: "
read -s pwfr
read -s -p "Retype a password: " pwsc
@ -129,6 +143,8 @@ then
else
echo
echo "You have entered different passwords. Try again.."
echo
continue
fi
break
@ -148,15 +164,18 @@ sgdisk -Z /dev/$dev &&
echo
# Creating boot partition.
#szmn="${array[1]%?}"
echo "Creating boot partition of 256 MB."
sgdisk -n 1:0:+256M /dev/$dev &&
echo
# Setting type for EFI.
echo "Marking partition as boot."
sgdisk -t 1:ef00 /dev/$dev &&
echo
# Creating system partition.
echo "Creating system partition."
echo "Creating system partition of $szmn GB."
sgdisk -n 2:0:0 /dev/$dev
echo
@ -175,45 +194,58 @@ echo -en "$pwcr\n$pwcr" | cryptsetup -c aes-xts-plain -s 512 luksFormat /dev/$ma
echo "Partition successfully encrypted."
echo
# Opening encrypted partition and mounting at /dev/mapper/main.
# Opening encrypted partition and mounting at /dev/mapper/lvm.
echo "Decrypting.. This also might take a while."
echo
echo -en "$pwcr\n$pwcr" | cryptsetup luksOpen /dev/$main main &&
echo -en "$pwcr\n$pwcr" | cryptsetup luksOpen /dev/$main lvm &&
echo "Partition successfully opened."
echo
lsblk | grep "$dev"
echo
# Creating physical volume.
echo "Creating physical volume."
pvcreate /dev/mapper/lvm &&
echo
# Creating volume group "main".
echo "Creating volume group."
vgcreate main /dev/mapper/lvm &&
echo
# Creating logical volumes.
echo "Creating logical volumes for root and home."
lvcreate -L ${szrt}G -n root main &&
lvcreate -l 100%FREE -n home main &&
echo "Logical volumes successfully created."
echo
echo "Creating the filesystem."
boot=${dev}1
mkfs.fat -F 32 -n UEFI /dev/$boot &&
echo "Filesystem for boot successfully created."
echo
# Creating btrfs partition.
mkfs.btrfs /dev/mapper/main &&
mount /dev/mapper/main /mnt &&
btrfs subvolume create /mnt/@root &&
btrfs subvolume create /mnt/@home &&
btrfs subvolume create /mnt/@snapshots &&
umount /mnt &&
echo "Mounting.." &&
mount -o compress=zstd,subvol=@root /dev/mapper/main /mnt &&
mkdir /mnt/home &&
mount -o compress=zstd,subvol=@home /dev/mapper/main /mnt/home &&
mkdir /mnt/.snapshots &&
mount -o compress=zstd,subvol=@snapshots /dev/mapper/main /mnt/.snapshots &&
mkdir /mnt/boot &&
mount /dev/$boot /mnt/boot &&
echo "Mounting complete." &&
mkfs.ext4 -L root /dev/mapper/main-root &&
echo "Filesystem for root successfully created."
echo
lsblk | grep "$dev"
mkfs.ext4 -L home /dev/mapper/main-home &&
echo "Filesystem for home successfully created."
echo
echo "Mounting.."
mount /dev/mapper/main-root /mnt &&
mkdir /mnt/boot &&
mkdir /mnt/home &&
mount /dev/$boot /mnt/boot &&
mount /dev/mapper/main-home /mnt/home &&
echo "Mounting complete."
echo
#lsblk | grep "$dev"
lsblk
echo
# Updating mirrors using reflector.
@ -223,17 +255,22 @@ reflector --verbose --latest 10 --country Germany --age 24 --protocol https --so
echo "Done."
echo
echo "Updating keyring.."
pacman -Sy archlinux-keyring --noconfirm &&
echo "Done."
echo
# Installing base system.
echo "Installing basic packages.."
#pacstrap /mnt base base-devel firefox konsole linux linux-firmware linux-zen lvm2 networkmanager nano plasma-desktop sddm sddm-kcm &&
pacstrap /mnt base btrfs-progs firefox konsole linux linux-firmware linux-zen lvm2 nano networkmanager plasma-desktop sddm sddm-kcm sudo &&
pacstrap /mnt base firefox konsole linux linux-firmware linux-zen lvm2 nano networkmanager plasma-desktop sddm sddm-kcm sudo &&
echo "Base system installed."
echo
# Generating fstab.
echo "Generating fstab."
genfstab -Up /mnt > /mnt/etc/fstab &&
echo "Installed fstab."
echo "Done."
echo
# Setting hostname.
@ -245,9 +282,9 @@ echo
# Setting locale.
echo "Setting and generating locale."
#localegen=$(cat /mnt/etc/locale.gen)
cat <<EOF >/mnt/etc/locale.gen
cat <<EOF > /mnt/etc/locale.gen
en_US.UTF-8 UTF-8
#de_DE.UTF-8 UTF-8
de_DE.UTF-8 UTF-8
EOF
#echo "${localegen}" >>/mnt/etc/locale.gen
arch-chroot /mnt locale-gen
@ -261,7 +298,7 @@ echo
echo "Setting locale and keyboard layout."
arch-chroot /mnt localectl --no-convert set-keymap de-latin1-nodeadkeys &&
cat << EOF > /mnt//etc/X11/xorg.conf.d/00-keyboard.conf &&
cat << EOF > /mnt/etc/X11/xorg.conf.d/00-keyboard.conf &&
# Written by systemd-localed(8), read by systemd-localed and Xorg. It's
# probably wise not to edit this file manually. Use localectl(1) to
# instruct systemd-localed to update it.
@ -278,9 +315,8 @@ echo
# Editing mkinitcpio.conf.
echo "Editing /etc/mkinitcpio.conf."
echo
sed -i '7s/.*/MODULES=(ext4)/' /mnt/etc/mkinitcpio.conf &&
sed -i '52s/.*/HOOKS=(base udev autodetect modconf block keyboard keymap encrypt lvm2 filesystems fsck shutdown)/' /mnt/etc/mkinitcpio.conf &&
sed -i '7s/.*/MODULES=(ext4)/' /mnt/etc/mkinitcpio.conf
sed -i '52s/.*/HOOKS=(base udev autodetect modconf block keyboard keymap encrypt lvm2 filesystems fsck shutdown)/' /mnt/etc/mkinitcpio.conf
echo "Done."
echo
@ -304,7 +340,7 @@ echo
# Install bootloader.
echo "Installing systemd-boot."
arch-chroot /mnt bootctl --path=/boot install &&
arch-chroot /mnt bootctl install &&
echo "Done."
echo
@ -316,9 +352,8 @@ linux /vmlinuz-linux-zen
#initrd /amd-ucode.img
#initrd /intel-ucode.img
initrd /initramfs-linux-zen.img
options cryptdevice=/dev/$main:main
options root=/dev/mapper/main rw
options rootflags=subvol=@root
options cryptdevice=/dev/$main:lvm
options root=/dev/mapper/main-root rw
options lang=de locale=de_DE.UTF-8
options init=/usr/lib/systemd/systemd
#options loglevel=3
@ -329,9 +364,8 @@ cat << EOF > /mnt/boot/loader/entries/arch-fallback.conf &&
title Arch Linux Fallback
linux /vmlinuz-linux
initrd /initramfs-linux-fallback.img
options cryptdevice=/dev/$main:main
options root=/dev/mapper/main rw
options rootflags=subvol=@root
options cryptdevice=/dev/$main:lvm
options root=/dev/mapper/main-root rw
options lang=de locale=de_DE.UTF-8
options init=/usr/lib/systemd/systemd
EOF
@ -347,7 +381,7 @@ echo "Adding user."
arch-chroot /mnt useradd -m $user &&
echo -en "$pwur\n$pwur" | arch-chroot /mnt passwd $user &&
arch-chroot /mnt gpasswd -a $user wheel &&
sed -i '82s/.*/%wheel ALL=(ALL) ALL/' /mnt/etc/sudoers
sed -i '82s/.*/%wheel ALL=(ALL) ALL/' /mnt/etc/sudoers &&
echo "Done."
echo
@ -365,6 +399,7 @@ echo
# Unmounting and rebooting.
echo "Unmounting system."
umount /mnt/boot &&
umount /mnt/home &&
umount /mnt &&
echo "Done."
echo
@ -372,5 +407,5 @@ echo
clear
echo "Installation finished!"
echo "Press [Enter] to shut down, then remove the installation media and start your system."
read -p "Press [Enter] to shut down, then remove the installation media and start your system."
poweroff

View File

@ -13,8 +13,6 @@
# $pwur = user password
# $pwrt = root password
# $pwcr = encryption password
# $pwfr = password first
# $pwsc = password second
# Friendly introduction.
echo "Welcome to the Arch Linux installation script!"
@ -56,14 +54,6 @@ IFS=' '
# Create new variable of selection.
array=($dev)
dev="${array[0]}"
szmn="${array[1]%?}"
# Setting partition size.
echo "Your system partition has a size of $szmn GB."
echo "What size should your root volume have (GB)?"
echo "The rest will be used for your home volume."
read szrt
echo
echo "2. ENCRYPTION"
echo
@ -82,8 +72,6 @@ then
else
echo
echo "You have entered different passwords. Try again.."
echo
continue
fi
break
done
@ -102,7 +90,7 @@ echo
# Setting root password.
echo "Choose a password for the root account:"
while [ -z "$pwrt" ]; do
while [ -z "$pwr" ]; do
echo "Please enter a password: "
read -s pwfr
read -s -p "Retype a password: " pwsc
@ -114,8 +102,6 @@ then
else
echo
echo "You have entered different passwords. Try again.."
echo
continue
fi
break
done
@ -131,7 +117,7 @@ echo
# Setting user password.
echo "Also please choose a password for your user:"
while [ -z "$pwur" ]; do
while [ -z "$pwu" ]; do
echo "Please enter a password: "
read -s pwfr
read -s -p "Retype a password: " pwsc
@ -143,8 +129,6 @@ then
else
echo
echo "You have entered different passwords. Try again.."
echo
continue
fi
break
@ -164,18 +148,15 @@ sgdisk -Z /dev/$dev &&
echo
# Creating boot partition.
#szmn="${array[1]%?}"
echo "Creating boot partition of 256 MB."
sgdisk -n 1:0:+256M /dev/$dev &&
echo
# Setting type for EFI.
echo "Marking partition as boot."
sgdisk -t 1:ef00 /dev/$dev &&
echo
# Creating system partition.
echo "Creating system partition of $szmn GB."
echo "Creating system partition."
sgdisk -n 2:0:0 /dev/$dev
echo
@ -194,58 +175,45 @@ echo -en "$pwcr\n$pwcr" | cryptsetup -c aes-xts-plain -s 512 luksFormat /dev/$ma
echo "Partition successfully encrypted."
echo
# Opening encrypted partition and mounting at /dev/mapper/lvm.
# Opening encrypted partition and mounting at /dev/mapper/main.
echo "Decrypting.. This also might take a while."
echo
echo -en "$pwcr\n$pwcr" | cryptsetup luksOpen /dev/$main lvm &&
echo -en "$pwcr\n$pwcr" | cryptsetup luksOpen /dev/$main main &&
echo "Partition successfully opened."
echo
lsblk | grep "$dev"
echo
# Creating physical volume.
echo "Creating physical volume."
pvcreate /dev/mapper/lvm &&
echo
# Creating volume group "main".
echo "Creating volume group."
vgcreate main /dev/mapper/lvm &&
echo
# Creating logical volumes.
echo "Creating logical volumes for root and home."
lvcreate -L ${szrt}G -n root main &&
lvcreate -l 100%FREE -n home main &&
echo "Logical volumes successfully created."
echo
echo "Creating the filesystem."
boot=${dev}1
mkfs.fat -F 32 -n UEFI /dev/$boot &&
echo "Filesystem for boot successfully created."
echo
mkfs.ext4 -L root /dev/mapper/main-root &&
echo "Filesystem for root successfully created."
echo
# Creating btrfs partition.
mkfs.btrfs /dev/mapper/main &&
mkfs.ext4 -L home /dev/mapper/main-home &&
echo "Filesystem for home successfully created."
echo
mount /dev/mapper/main /mnt &&
echo "Mounting.."
mount /dev/mapper/main-root /mnt &&
mkdir /mnt/boot &&
btrfs subvolume create /mnt/@root &&
btrfs subvolume create /mnt/@home &&
btrfs subvolume create /mnt/@snapshots &&
umount /mnt &&
echo "Mounting.." &&
mount -o compress=zstd,subvol=@root /dev/mapper/main /mnt &&
mkdir /mnt/home &&
mount -o compress=zstd,subvol=@home /dev/mapper/main /mnt/home &&
mkdir /mnt/.snapshots &&
mount -o compress=zstd,subvol=@snapshots /dev/mapper/main /mnt/.snapshots &&
mkdir /mnt/boot &&
mount /dev/$boot /mnt/boot &&
mount /dev/mapper/main-home /mnt/home &&
echo "Mounting complete."
echo "Mounting complete." &&
echo
#lsblk | grep "$dev"
lsblk
lsblk | grep "$dev"
echo
# Updating mirrors using reflector.
@ -255,22 +223,17 @@ reflector --verbose --latest 10 --country Germany --age 24 --protocol https --so
echo "Done."
echo
echo "Updating keyring.."
pacman -Sy archlinux-keyring --noconfirm &&
echo "Done."
echo
# Installing base system.
echo "Installing basic packages.."
#pacstrap /mnt base base-devel firefox konsole linux linux-firmware linux-zen lvm2 networkmanager nano plasma-desktop sddm sddm-kcm &&
pacstrap /mnt base firefox konsole linux linux-firmware linux-zen lvm2 nano networkmanager plasma-desktop sddm sddm-kcm sudo &&
pacstrap /mnt base btrfs-progs firefox konsole linux linux-firmware linux-zen lvm2 nano networkmanager plasma-desktop sddm sddm-kcm sudo &&
echo "Base system installed."
echo
# Generating fstab.
echo "Generating fstab."
genfstab -Up /mnt > /mnt/etc/fstab &&
echo "Done."
echo "Installed fstab."
echo
# Setting hostname.
@ -282,9 +245,9 @@ echo
# Setting locale.
echo "Setting and generating locale."
#localegen=$(cat /mnt/etc/locale.gen)
cat <<EOF > /mnt/etc/locale.gen
cat <<EOF >/mnt/etc/locale.gen
en_US.UTF-8 UTF-8
de_DE.UTF-8 UTF-8
#de_DE.UTF-8 UTF-8
EOF
#echo "${localegen}" >>/mnt/etc/locale.gen
arch-chroot /mnt locale-gen
@ -298,7 +261,7 @@ echo
echo "Setting locale and keyboard layout."
arch-chroot /mnt localectl --no-convert set-keymap de-latin1-nodeadkeys &&
cat << EOF > /mnt/etc/X11/xorg.conf.d/00-keyboard.conf &&
cat << EOF > /mnt//etc/X11/xorg.conf.d/00-keyboard.conf &&
# Written by systemd-localed(8), read by systemd-localed and Xorg. It's
# probably wise not to edit this file manually. Use localectl(1) to
# instruct systemd-localed to update it.
@ -315,8 +278,9 @@ echo
# Editing mkinitcpio.conf.
echo "Editing /etc/mkinitcpio.conf."
sed -i '7s/.*/MODULES=(ext4)/' /mnt/etc/mkinitcpio.conf
sed -i '52s/.*/HOOKS=(base udev autodetect modconf block keyboard keymap encrypt lvm2 filesystems fsck shutdown)/' /mnt/etc/mkinitcpio.conf
echo
sed -i '7s/.*/MODULES=(ext4)/' /mnt/etc/mkinitcpio.conf &&
sed -i '52s/.*/HOOKS=(base udev autodetect modconf block keyboard keymap encrypt lvm2 filesystems fsck shutdown)/' /mnt/etc/mkinitcpio.conf &&
echo "Done."
echo
@ -340,7 +304,7 @@ echo
# Install bootloader.
echo "Installing systemd-boot."
arch-chroot /mnt bootctl install &&
arch-chroot /mnt bootctl --path=/boot install &&
echo "Done."
echo
@ -352,8 +316,9 @@ linux /vmlinuz-linux-zen
#initrd /amd-ucode.img
#initrd /intel-ucode.img
initrd /initramfs-linux-zen.img
options cryptdevice=/dev/$main:lvm
options root=/dev/mapper/main-root rw
options cryptdevice=/dev/$main:main
options root=/dev/mapper/main rw
options rootflags=subvol=@root
options lang=de locale=de_DE.UTF-8
options init=/usr/lib/systemd/systemd
#options loglevel=3
@ -364,8 +329,9 @@ cat << EOF > /mnt/boot/loader/entries/arch-fallback.conf &&
title Arch Linux Fallback
linux /vmlinuz-linux
initrd /initramfs-linux-fallback.img
options cryptdevice=/dev/$main:lvm
options root=/dev/mapper/main-root rw
options cryptdevice=/dev/$main:main
options root=/dev/mapper/main rw
options rootflags=subvol=@root
options lang=de locale=de_DE.UTF-8
options init=/usr/lib/systemd/systemd
EOF
@ -381,7 +347,7 @@ echo "Adding user."
arch-chroot /mnt useradd -m $user &&
echo -en "$pwur\n$pwur" | arch-chroot /mnt passwd $user &&
arch-chroot /mnt gpasswd -a $user wheel &&
sed -i '82s/.*/%wheel ALL=(ALL) ALL/' /mnt/etc/sudoers &&
sed -i '82s/.*/%wheel ALL=(ALL) ALL/' /mnt/etc/sudoers
echo "Done."
echo
@ -399,7 +365,6 @@ echo
# Unmounting and rebooting.
echo "Unmounting system."
umount /mnt/boot &&
umount /mnt/home &&
umount /mnt &&
echo "Done."
echo
@ -407,5 +372,5 @@ echo
clear
echo "Installation finished!"
read -p "Press [Enter] to shut down, then remove the installation media and start your system."
echo "Press [Enter] to shut down, then remove the installation media and start your system."
poweroff