arch install

#!/bin/bash
# idk don’t actually run this, it’s just for syntax highlighting
# ====================================================================================
# iwctl station wlan0 connect <ssid> —passphrase <pass>
## Verification

# ls /sys/firmware/efi/efivars # verify boot
# ping archlinux.org # verify internet connection
timedatectl set-ntp true # use network time
# timedatectl status # check time

## Format disks (repeat for all devices as desired)

# fdisk -l # identify devices
# lsblk -f # identify partitions
# smartctl -i /dev/sda # get serial number and other info

parted /dev/sda mklabel gpt # set /dev/sda to gpt disk
cgdisk /dev/sda # pseudographical gdisk tool for partitions
######## Example cgdisk flow #########################################################
# — Create /boot partition —
# [New]
# [enter] to set default sector size (2048)
# +512M [enter] to set a 512MiB partition size
# ef00 [enter] to set partition type as EFI System Partition
# ESP [enter] to name this partition «ESP»
# — Create swap partition (optional unless low memory) —
# Select free space at end
# [New]
# -4G [enter] to set start sector
# [enter] to set size as remaining end space
# 8200 [enter] to set partition type as Linux swap
# Swap [enter] to name this partition «Swap»
# — Create / partition —
# Select free space at end (or middle, if you created swap)
# [New]
# [enter] to set start sector at beginning of free space
# [enter] to set end sector at end of free space
# [enter] to set partition type as Linux filesystem (default / 8300)
# Root [enter] to name this partition «Root»
# — Write partition table to disk —
# [Write]
# yes [enter] to confirm partition table
# [Quit]
#####################################################################################
# fdisk /dev/sda # if you made a swap partition
# — Reorder partitions sequentially from start to end of disk —
# x [enter] to enter expert mode
# f [enter] to fix partition order
# r [enter] to return to main menu
# w [enter] to write changes
# — /dev/sda2 should now be root, /dev/sda3 should now be swap —
# fdisk -l # verify that the table is correct
mkfs.fat /dev/sda1 -n «ESP» # format ESP as fat32 (required for ESP)
mkfs.ext4 /dev/sda2 -L «Arch» # format / as ext4 (use /dev/sda2 if no swap)
# mkswap /dev/sda3 -L «Swap» # designate swap partition (if you made one)
# swapon /dev/sda3 # turn on swap (if you made one)

## Mount partitions
mount /dev/sda2 /mnt # mount the root partition
mkdir /mnt/boot # create /boot folder
mount /dev/sda1 /mnt/boot # mount ESP inside /boot on root partition

## Update mirrorlist
pacman -Sy # sync package manager database
pacman -S reflector # install Reflector
reflector —country ‘US’ # get mirrors in US
-p http # using http protocol
—sort rate # and sort them by speed
—save /etc/pacman.d/mirrorlist # save optimal mirrorlist

## Install system
pacstrap /mnt base base-devel # bootstrap minimal system with base packages
#……………………………………# this will take a while…
#……………………………………# better go find something to do
#……………………………………# for ten minutes or so.
genfstab -U /mnt >> /mnt/etc/fstab # generate filesystem table using UUIDs
arch-chroot /mnt # start running commands inside new system
passwd # set root password

## Timezones
ln -sf /usr/share/zoneinfo/America/Chicago # symbolic link from Central Time
/etc/localtime # to the local timezone
hwclock —systohc # sync system clock with hardware clock

## Locales
echo «en_US.UTF-8 UTF-8» > /etc/locale.gen # overwrite locale generation
echo «ar_JO.UTF-8 UTF-8» >> /etc/locale.gen # append locale generation
locale-gen # generate locales from locale.gen
echo «LANG=en_US.UTF-8» > /etc/locale.conf # set specific locale

## Hostnames
echo «arch» > /etc/hostname # set hostname
echo «127.0.0.1 localhost» > /etc/hosts # loopback localhost ipv4
echo «::1 localhost» >> /etc/hosts # loopback localhost ipv6
echo «127.0.1.1 arch.localdomain arch» >> /etc/hosts # loopback hostname ipv4
systemctl enable dhcpcd # networking (example)

## Bootloader setup
pacman -S intel-ucode linux-lts # recommended
bootctl install # install systemd-boot

#### Arch Linux bootloader entry
echo «title Arch Linux» > /boot/loader/entries/arch.conf
echo «linux /vmlinuz-linux» >> /boot/loader/entries/arch.conf
echo «initrd /intel-ucode.img» >> /boot/loader/entries/arch.conf
echo «initrd /initramfs-linux.img» >> /boot/loader/entries/arch.conf
echo «options root=LABEL=Arch rw» >> /boot/loader/entries/arch.conf

#### Arch Linux bootloader entry (fallback)
echo «title Arch Linux (fallback)» > /boot/loader/entries/arch-fallback.conf
echo «linux /vmlinuz-linux» >> /boot/loader/entries/arch-fallback.conf
echo «initrd /intel-ucode.img» >> /boot/loader/entries/arch-fallback.conf
echo «initrd /initramfs-linux-fallback.img» >> /boot/loader/entries/arch-fallback.conf
echo «options root=LABEL=Arch rw» >> /boot/loader/entries/arch-fallback.conf

#### Arch Linux bootloader entry (LTS)
echo «title Arch Linux (LTS)» > /boot/loader/entries/arch-lts.conf
echo «linux /vmlinuz-linux-lts» >> /boot/loader/entries/arch-lts.conf
echo «initrd /intel-ucode.img» >> /boot/loader/entries/arch-lts.conf
echo «initrd /initramfs-linux-lts.img» >> /boot/loader/entries/arch-lts.conf
echo «options root=LABEL=Arch rw» >> /boot/loader/entries/arch-lts.conf

#### Arch Linux bootloader entry (LTS fallback)
echo «title Arch Linux (LTS fallback)» > /boot/loader/entries/arch-lts.conf
echo «linux /vmlinuz-linux-lts» >> /boot/loader/entries/arch-lts.conf
echo «initrd /intel-ucode.img» >> /boot/loader/entries/arch-lts.conf
echo «initrd /initramfs-linux-lts-fallback.img» >> /boot/loader/entries/arch-lts.conf
echo «options root=LABEL=Arch rw» >> /boot/loader/entries/arch-lts.conf

#### EFI Shell v1 entry
echo «title EFI Shell v1» > /boot/loader/entries/efi1.conf
echo «efi /EFI/shellx64_v1.efi» >> /boot/loader/entries/efi1.conf

#### EFI Shell v2 entry
echo «title EFI Shell v2» > /boot/loader/entries/efi2.conf
echo «efi /EFI/shellx64_v2.efi» >> /boot/loader/entries/efi2.conf

#### Configure loaders
echo «default arch» > /boot/loader/loader.conf
echo «timeout 3» >> /boot/loader/loader.conf
echo «editor yes» >> /boot/loader/loader.conf

## Finishing up
exit # exit chroot
cp /boot/EFI/shellx64_v1.efi /mnt/boot/EFI/shellx64_v1.efi # copy efi1 loader
cp /boot/EFI/shellx64_v2.efi /mnt/boot/EFI/shellx64_v2.efi # copy efi2 loader
umount -R /mnt # unmount partitions
reboot # reboot