1 Commits
Author SHA1 Message Date
dataprolet f4abf2692a Update install.sh 2025-02-11 12:11:23 +01:00
3 changed files with 207 additions and 173 deletions
+1 -1
View File
@@ -4,7 +4,7 @@
This installation script aims for a simple (read minimal) Arch Linux installation, which is modern in the way that it uses UEFI, systemd-boot and Wayland, secure in the way that it uses full-disk encryption using LUKS as well as flexibility by using Btrfs subvolumes for the root and home partition. This installation script aims for a simple (read minimal) Arch Linux installation, which is modern in the way that it uses UEFI, systemd-boot and Wayland, secure in the way that it uses full-disk encryption using LUKS as well as flexibility by using Btrfs subvolumes for the root and home partition.
Tested and working as of **June 2026**. Tested and working as of **February 2025**.
![Post-install screenshot.](img/screenshot.png) ![Post-install screenshot.](img/screenshot.png)
Binary file not shown.

Before

Width:  |  Height:  |  Size: 393 KiB

After

Width:  |  Height:  |  Size: 489 KiB

+205 -171
View File
@@ -1,22 +1,20 @@
#!/bin/bash #!/bin/bash
# https://wizardzines.com/comics/bash-errors/bash-errors.png
set -euo pipefail set -euo pipefail
# Write log
exec >> >(tee -i /tmp/install.log) exec >> >(tee -i /tmp/install.log)
exec 2>&1 exec 2>&1
function cleanup() {
umount /mnt/boot
umount /mnt/home
umount /mnt
cryptsetup close /dev/mapper/main
}
trap cleanup EXIT
clear clear
# Friendly introduction # Check root
if [[ $(id -u) -ne 0 ]]; then
echo "This script needs to be run as root!"
exit 1
fi
# Friendly introduction.
echo "0. WELCOME" echo "0. WELCOME"
echo "Welcome to the Arch Linux installation script!" echo "Welcome to the Arch Linux installation script!"
echo "This script will ERASE ALL DATA on the partition you will choose next!" echo "This script will ERASE ALL DATA on the partition you will choose next!"
@@ -28,49 +26,62 @@ if [[ ! $REPLY =~ ^[Yy]$ ]]; then
fi fi
clear clear
########## # Selecting disk.
# Selecting disk
echo "1. PARTITIONING" echo "1. PARTITIONING"
echo "Please select a disk to partition:" echo "Please select a disk to partition:"
echo echo
# Don't separate values by space # Don't separate values by space.
IFS=$'\n' IFS=$'\n'
# Set variable containing name and size of all disks # Set variable containing name and size of all disks.
declare -a dsks=( $(lsblk -d | tail -n+2 | awk '{print $1" "$4}') ) declare -a dsks=( $(lsblk -d | tail -n+2 | awk '{print $1" "$4}') )
# Select value on array # Select value on array.
select dev in "${dsks[@]}"; do select dev in "${dsks[@]}"
do
break break
done done
echo echo
# Separate values by spaces # Separate values by spaces.
IFS=' ' IFS=' '
# Create new variable of selection # Create new variable of selection.
array=(${dev}) array=(${dev})
dev="${array[0]}" dev="${array[0]}"
clear # TODO Check disk size
# Disk auswählen (Variable `dev` muss gesetzt sein)
#disk="/dev/${dev}"
########## # Festplattengröße in Gigabyte berechnen
#disk_size=$(lsblk -b -n -o SIZE "$disk" | awk '{print $1 / 1024 / 1024 / 1024}')
# Prüfen, ob die Festplatte größer als 10 GB ist
#if (( $(echo "$disk_size >= 10" | bc -l) )); then
# echo "✅ Die Festplatte hat $disk_size GB und ist größer als 10 GB."
#else
# echo "❌ Fehler: Die Festplatte ist zu klein ($disk_size GB). Bitte eine größere auswählen."
# exit 1
#fi
clear
echo "2. ENCRYPTION" echo "2. ENCRYPTION"
echo echo
# Setting encryption password. # Setting encryption password.
echo "Choose a strong password for encrypting the primary partition:" echo "Choose a strong password for encrypting the primary partition:"
pwcr="" password_encrypt=""
while [[ -z "${pwcr}" ]]; do while [[ -z "${password_encrypt}" ]]; do
echo "Please enter a password: " #echo "Please enter a password: "
read -rs pwfr read -rs -p "Please enter a password: " password_first
read -rs -p "Retype a password: " pwsc read -rs -p "Retype a password: " password_second
if [[ "${pwfr}" == "${pwsc}" ]]; if [[ "${password_first}" == "${password_second}" ]];
then then
pwcr="${pwfr}" password_encrypt="${password_first}"
echo echo
echo "Both passwords are the same. Continuing.." echo "Both passwords are the same. Continuing.."
break break
@@ -83,32 +94,32 @@ done
clear clear
##########
echo "3. HOSTNAME" echo "3. HOSTNAME"
echo echo
# Setting hostname. # Setting hostname
echo "Before installing the system, please enter a hostname:" #echo "Before installing the system, please enter a hostname:"
read -r host read -r -p "Before installing the system, please enter a hostname: " host
while [[ -z "${host}" ]]; do
echo "Hostname can not be empty!"
read -r -p "Please enter a hostname: " host
done
clear clear
##########
echo "4. ROOT PASSWORD" echo "4. ROOT PASSWORD"
echo echo
# Setting root password. # Setting root password
echo "Choose a password for the root account:" echo "Choose a password for the root account:"
pwr="" password_root=""
while [[ -z "${pwr}" ]]; do while [[ -z "${password_root}" ]]; do
echo "Please enter a password: " #echo "Please enter a password: "
read -rs pwfr read -rs -p "Please enter a password: " password_first
read -rs -p "Retype a password: " pwsc read -rs -p "Retype a password: " password_second
if [[ "${pwfr}" == "${pwsc}" ]]; then if [[ "${password_first}" == "${password_second}" ]]; then
pwrt="${pwfr}" password_root="${password_first}"
echo echo
echo "Both passwords are the same. Continuing.." echo "Both passwords are the same. Continuing.."
break break
@@ -125,21 +136,26 @@ echo "4. USER"
echo echo
# Setting username # Setting username
echo "Please enter a username:" #echo "Please enter a username:"
read -r user read -r -p "Please enter a username: " user
while [[ -z "${user}" ]]; do
echo "Benutzername darf nicht leer sein!"
read -r -p "Please enter a username: " user
done
echo echo
# Setting user password # Setting user password.
echo "Also please choose a password for your user:" echo "Also please choose a password for your user:"
pwu="" password_user=""
while [[ -z "${pwu}" ]]; do while [[ -z "${password_user}" ]]; do
echo "Please enter a password: " #echo "Please enter a password: "
read -rs pwfr read -rs -p "Please enter a password: " password_first
read -rs -p "Retype a password: " pwsc read -rs -p "Retype a password: " password_second
if [[ "${pwfr}" == "${pwsc}" ]]; if [[ "${password_first}" == "${password_second}" ]];
then then
pwur="${pwfr}" password_user="${password_first}"
echo echo
echo "Both passwords are the same. Continuing.." echo "Both passwords are the same. Continuing.."
break break
@@ -152,68 +168,62 @@ done
clear clear
##########
echo "5. INSTALLING SYSTEM.." echo "5. INSTALLING SYSTEM.."
echo echo
# Starting partitioning # Starting partitioning.
echo "Partitioning /dev/${dev}.." echo "Partitioning /dev/${dev}.."
echo echo
# Clearing partition table of selected disk # Clearing partition table of selected disk.
echo "Clearing existing partitioning table." echo "Clearing existing partitioning table."
sgdisk -Z "/dev/${dev}" sgdisk -Z "/dev/${dev}"
echo echo
# Creating boot partition # Creating boot partition.
echo "Creating boot partition of 512 MB." echo "Creating boot partition of 512 MB."
sgdisk -n 1:0:+512M "/dev/${dev}" sgdisk -n 1:0:+512M "/dev/${dev}"
echo echo
# Setting type for EFI # Setting type for EFI.
echo "Setting partition type." echo "Setting partition type."
sgdisk -t 1:ef00 "/dev/${dev}" sgdisk -t 1:ef00 "/dev/${dev}"
echo echo
# Creating system partition # Creating system partition.
echo "Creating system partition." echo "Creating system partition."
sgdisk -n 2:0:0 "/dev/${dev}" sgdisk -n 2:0:0 "/dev/${dev}"
echo echo
# Print partitions # Print partitions.
echo "This is your new partition table:" echo "This is your new partition table:"
lsblk | grep "${dev}" lsblk | grep "${dev}"
echo echo
# Get new variable # Get new variable.
if [[ "${dev}" = "nvme0n1" ]]; then if [[ "${dev}" = "nvme0n1" ]]; then
main="${dev}p2" main="${dev}p2"
else else
main="${dev}2" main="${dev}2"
fi fi
# Encrypting partition # Encrypting partition.
echo "Encrypting system partition. This might take a while." echo "Encrypting system partition. This might take a while."
echo echo
echo -en "${password_encrypt}\n${password_encrypt}" | cryptsetup -c aes-xts-plain -s 512 luksFormat "/dev/${main}"
# https://wiki.archlinux.org/title/Dm-crypt/Device_encryption#Encryption_options_for_LUKS_mode
echo -en "${pwcr}\n${pwcr}" | cryptsetup -s 512 luksFormat /dev/$main
echo "Partition successfully encrypted." echo "Partition successfully encrypted."
echo echo
# Opening encrypted partition and mounting at /dev/mapper/main # Opening encrypted partition and mounting at /dev/mapper/main.
echo "Decrypting.. This also might take a while." echo "Decrypting.. This also might take a while."
echo echo
echo -en "${pwcr}\n${pwcr}" | cryptsetup luksOpen "/dev/${main}" main echo -en "${password_encrypt}\n${password_encrypt}" | cryptsetup luksOpen "/dev/${main}" main
echo "Partition successfully opened." echo "Partition successfully opened."
echo echo
lsblk | grep "${dev}" lsblk | grep "${dev}"
echo echo
##########
echo "Creating the filesystem." echo "Creating the filesystem."
if [ "${dev}" = "nvme0n1" ]; then if [ "${dev}" = "nvme0n1" ]; then
@@ -222,12 +232,11 @@ else
boot="${dev}1" boot="${dev}1"
fi fi
# Create boot filesystem
mkfs.fat -F 32 -n UEFI "/dev/${boot}" mkfs.fat -F 32 -n UEFI "/dev/${boot}"
echo "Filesystem for boot successfully created." echo "Filesystem for boot successfully created."
echo echo
# Creating btrfs filesystem # Creating btrfs partition.
mkfs.btrfs "/dev/mapper/main" mkfs.btrfs "/dev/mapper/main"
mount "/dev/mapper/main" "/mnt" mount "/dev/mapper/main" "/mnt"
@@ -235,6 +244,7 @@ mount "/dev/mapper/main" "/mnt"
btrfs subvolume create "/mnt/root" btrfs subvolume create "/mnt/root"
btrfs subvolume create "/mnt/home" btrfs subvolume create "/mnt/home"
sync
umount "/mnt" umount "/mnt"
echo echo
@@ -250,10 +260,7 @@ echo
lsblk -a lsblk -a
echo echo
########## # Updating mirrors using reflector.
# Updating mirrors using reflector
# https://wiki.archlinux.org/title/Installation_guide#Select_the_mirrors
echo "Updating mirrors.." echo "Updating mirrors.."
reflector --verbose --latest 10 --country Germany --age 24 --protocol https --sort rate --save /etc/pacman.d/mirrorlist reflector --verbose --latest 10 --country Germany --age 24 --protocol https --sort rate --save /etc/pacman.d/mirrorlist
echo "Done." echo "Done."
@@ -267,56 +274,56 @@ if checkupdates | grep -q archlinux-keyring; then
fi fi
echo echo
# Installing base system # Installing base system.
# https://wiki.archlinux.org/title/Installation_guide#Install_essential_packages
echo "Installing basic packages.." echo "Installing basic packages.."
# Base packages # Basis-Pakete
base_packages=( base_packages=(
base # Arch Linux Base base
btrfs-progs # Btrfs btrfs-progs
firefox firefox
konsole # Terminal konsole
linux linux
linux-firmware linux-firmware
linux-zen linux-zen
nano # Editor nano
networkmanager networkmanager
plasma-login-manager sddm
sddm-kcm
sudo sudo
xorg-xwayland xorg-xwayland
plasma-desktop plasma-desktop
plasma-nm # Network manager applet plasma-nm
) )
# Necessary Plasma integrations # Notwendige Plasma-Integrationen
plasma_integrations=( plasma_integrations=(
plasma-pa # Audio applet plasma-pa
breeze-gtk # Widget theme breeze-gtk
kde-gtk-config # Syncs KDE settings to GTK applications kde-gtk-config
kdeplasma-addons # Misc addons: https://github.com/KDE/kdeplasma-addons kdeplasma-addons
kscreen # Adds screen management to settings kscreen
plasma-browser-integration plasma-browser-integration
powerdevil # Power management powerdevil
) )
# KDE Utilities # KDE Utilities
kde_utils=( kde_utils=(
ark # Archiving tool ark
bluedevil # Bluetooth bluedevil
discover # GUI package management discover
dolphin # File browser dolphin
filelight # Disk usage analyzer filelight
gwenview # Image viewer gwenview
kate # Text editor kate
kcalc # Calculator kcalc
kdeconnect # Mobile synchronisation tool kdeconnect
kinfocenter # System information kinfocenter
#kmag # Doesn't work on Wayland kmag
plasma-systemmonitor plasma-systemmonitor
okular # PDF viewer okular
partitionmanager # partitioning utility partitionmanager
spectacle # Screenshot utility spectacle
) )
# Additional default software # Additional default software
@@ -328,7 +335,7 @@ default_software=(
wireplumber wireplumber
) )
# Put all packages together # Alle Pakete zusammenführen
all_packages=( all_packages=(
"${base_packages[@]}" "${base_packages[@]}"
"${plasma_integrations[@]}" "${plasma_integrations[@]}"
@@ -336,89 +343,87 @@ all_packages=(
"${default_software[@]}" "${default_software[@]}"
) )
# Install packages # Pakete installieren
pacstrap "/mnt" "${all_packages[@]}" pacstrap "/mnt" "${all_packages[@]}"
echo "Base system installed." echo "Base system installed."
echo echo
########## # Generating fstab.
# Generating fstab
# https://wiki.archlinux.org/title/Installation_guide#Fstab
echo "Generating fstab.." echo "Generating fstab.."
genfstab -Up "/mnt" > "/mnt/etc/fstab" genfstab -Up "/mnt" > "/mnt/etc/fstab"
echo "Done." echo "Done."
echo echo
# Set hardware clock # Setting hostname.
# https://wiki.archlinux.org/title/Installation_guide#Time echo "Setting hostname.."
arch-chroot "/mnt" hwclock --systohc # Set the Hardware Clock to the current System Time echo "${host}" > "/mnt/etc/hostname"
# Generate locale
# https://wiki.archlinux.org/title/Installation_guide#Localization
echo "en_US.UTF-8 UTF-8" >> "/mnt/etc/locale.gen"
arch-chroot "/mnt" locale-gen
# Set keymap, locale, timezone and hostname
# https://wiki.archlinux.org/title/Systemd-firstboot
service_dir="/mnt/etc/systemd/system/systemd-firstboot.service.d"
mkdir "${service_dir}"
rootdir="/mnt"
keymap="de-latin1-nodeadkeys"
locale="en_US.UTF-8"
timezone="Europe/Berlin"
cat << EOF > "${service_dir}/install.conf"
[Unit]
ConditionFirstBoot=
[Service]
ExecStart=
ExecStart=/usr/bin/systemd-firstboot --root="${rootdir}" --keymap="${keymap}" --locale="${locale}" --timezone="${timezone}" --hostname="${host}" --force
[Install]
WantedBy=sysinit.target
EOF
arch-chroot "/mnt" systemctl enable systemd-firstboot.service
##########
# Editing mkinitcpio.conf
echo "Editing /etc/mkinitcpio.conf.."
sed -i '55s/.*/HOOKS=(base udev autodetect microcode modconf kms block keyboard keymap encrypt filesystems fsck shutdown)/' /mnt/etc/mkinitcpio.conf
echo "Done." echo "Done."
echo echo
# Editing taskbar # Setting locale.
echo "Setting and generating locale.."
cat << EOF > "/mnt/etc/locale.gen"
en_US.UTF-8 UTF-8
EOF
#echo "${localegen}" >>/mnt/etc/locale.gen
arch-chroot "/mnt" locale-gen
echo "LANG=en_US.UTF-8" > "/mnt/etc/locale.conf"
echo "KEYMAP=de-latin1" > "/mnt/etc/vconsole.conf"
echo "Done."
echo
# Set X locale and keyboard alyout.
echo "Setting locale and keyboard layout."
#arch-chroot /mnt localectl --no-convert set-keymap de-latin1-nodeadkeys
systemd-firstboot --root=/mnt --keymap=de-latin1-nodeadkeys
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.
Section "InputClass"
Identifier "system-keyboard"
MatchIsKeyboard "on"
Option "XkbLayout" "de"
Option "XkbModel" "pc105"
Option "XkbVariant" "deadgraveacute"
EndSection
EOF
echo "Done."
echo
# Editing mkinitcpio.conf.
echo "Editing /etc/mkinitcpio.conf.."
sed -i 's/^HOOKS=.*/HOOKS=(base udev autodetect microcode modconf kms block keyboard keymap encrypt filesystems fsck shutdown)/' /mnt/etc/mkinitcpio.conf
#sed -i '55s/.*/HOOKS=(base udev autodetect microcode modconf kms block keyboard keymap encrypt filesystems fsck shutdown)/' /mnt/etc/mkinitcpio.conf
echo "Done."
echo
# Editing taskbar.
#sed -i '65s/.*/launchers=applications:systemsettings.desktop,applications:org.kde.konsole.desktop,applications:firefox.desktop/' /mnt/home/${user}/.config/plasma-org.kde.plasma.desktop-appletsrc #sed -i '65s/.*/launchers=applications:systemsettings.desktop,applications:org.kde.konsole.desktop,applications:firefox.desktop/' /mnt/home/${user}/.config/plasma-org.kde.plasma.desktop-appletsrc
# Creating inital ramdisk # Creating inital ramdisk.
# https://wiki.archlinux.org/title/Installation_guide#Initramfs
echo "Creating inital ramdisk for linux-zen.." echo "Creating inital ramdisk for linux-zen.."
arch-chroot /mnt mkinitcpio -p linux-zen arch-chroot /mnt mkinitcpio -p linux-zen
echo "Done." echo "Done."
echo echo
# Enable network and display manager # Enable network and display manager.
echo "Enabling NetworkManager and Plasma Login Manager.." echo "Enabling Networkmanager and display manager (sddm).."
arch-chroot "/mnt" systemctl enable NetworkManager plasmalogin arch-chroot "/mnt" systemctl enable NetworkManager sddm
echo "Done." echo "Done."
echo echo
##########
# Set root password # Set root password
# https://wiki.archlinux.org/title/Installation_guide#Root_password
echo "Setting root password.." echo "Setting root password.."
echo -en "${pwrt}\n${pwrt}" | arch-chroot "/mnt" passwd echo -en "${password_root}\n${password_root}" | arch-chroot "/mnt" passwd
echo "Done." echo "Done."
echo echo
# Install bootloader # Install bootloader.
# https://wiki.archlinux.org/title/Installation_guide#Boot_loader
echo "Installing systemd-boot.." echo "Installing systemd-boot.."
arch-chroot "/mnt" bootctl --path=/boot install arch-chroot "/mnt" bootctl --path=/boot install
echo "Done." echo "Done."
@@ -427,7 +432,7 @@ echo
# Get UUID for primary partition # Get UUID for primary partition
uuid=$(ls -l /dev/disk/by-uuid | grep "${main}" | awk '{print $9}') uuid=$(ls -l /dev/disk/by-uuid | grep "${main}" | awk '{print $9}')
# Set bootloader entry # Set bootloader entry.
echo "Setting up bootloader.." echo "Setting up bootloader.."
cat << EOF > "/mnt/boot/loader/entries/arch.conf" cat << EOF > "/mnt/boot/loader/entries/arch.conf"
title Arch Linux title Arch Linux
@@ -442,7 +447,7 @@ options lang=de locale=de_DE.UTF-8
options init=/usr/lib/systemd/systemd options init=/usr/lib/systemd/systemd
EOF EOF
# Set bootloader fallback entry # Set bootloader fallback entry.
cat << EOF > "/mnt/boot/loader/entries/arch-fallback.conf" cat << EOF > "/mnt/boot/loader/entries/arch-fallback.conf"
title Arch Linux Fallback title Arch Linux Fallback
linux /vmlinuz-linux linux /vmlinuz-linux
@@ -454,31 +459,60 @@ options lang=de locale=de_DE.UTF-8
options init=/usr/lib/systemd/systemd options init=/usr/lib/systemd/systemd
EOF EOF
# Set bootloader # Set bootloader.
echo "timeout 1" >> "/mnt/boot/loader/loader.conf" echo "timeout 1" >> "/mnt/boot/loader/loader.conf"
echo "default arch.conf" >> "/mnt/boot/loader/loader.conf" echo "default arch.conf" >> "/mnt/boot/loader/loader.conf"
echo "Done." echo "Done."
echo echo
# Set username, password and group # Set username, password and group.
echo "Adding user.." echo "Adding user.."
arch-chroot /mnt useradd -m "${user}" arch-chroot /mnt useradd -m "${user}"
echo -en "${pwur}\n${pwur}" | arch-chroot /mnt passwd "${user}" echo -en "${password_user}\n${password_user}" | arch-chroot /mnt passwd "${user}"
arch-chroot /mnt gpasswd -a "${user}" wheel 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 "Done."
echo echo
# Enabling plasma login manager auto login # Enabling sddm auto-login.
echo "Enabling auto login.." echo "Enabling auto-login.."
cat << EOF > /mnt/etc/plasmalogin.conf mkdir /mnt/etc/sddm.conf.d
cat << EOF > /mnt/etc/sddm.conf.d/autologin.conf
[Autologin] [Autologin]
Session=plasma.desktop
User=${user} User=${user}
Session=plasma
EOF EOF
echo "Done." echo "Done."
echo echo
# Adding sddm config.
cat << EOF > /mnt/etc/sddm.conf.d/kde_settings.conf
[Autologin]
Relogin=false
Session=plasma
User=${user}
[General]
HaltCommand=/usr/bin/systemctl poweroff
RebootCommand=/usr/bin/systemctl reboot
[Theme]
Current=breeze
[Users]
MaximumUid=60513
MinimumUid=1000
EOF
# Unmounting and rebooting.
echo "Unmounting system.."
sync
umount "/mnt/boot"
umount "/mnt/home"
umount "/mnt"
echo "Done."
echo
clear clear
echo "Installation finished!" echo "Installation finished!"