Arch Linux install

Important

Please refer to the Arch Wiki for the official guide on how to install Arch Linux.

Setup disk partitions

parted /dev/sda
(parted) mklabel gpt
(parted) mkpart primary fat32 1MiB 512MiB
(parted) set 1 esp on
(parted) mkpart primary ext4 512MiB 100%
(parted) quit

Or you can wrap that all into one line:

parted --script /dev/sda mklabel gpt mkpart primary fat32 1MiB 512MiB set 1 esp on \
    mkpart primary ext4 512MiB 100%

Format partitions

mkfs.fat -F32 /dev/sda1
mkfs.ext4 /dev/sda2

Mount partitions

mount /dev/sda2 /mnt
mkdir /mnt/boot
mount /dev/sda1 /mnt/boot

Install the base system and enter chroot

pacstrap /mnt base linux openssh sudo neovim
genfstab -U /mnt >> /mnt/etc/fstab
arch-chroot /mnt

Set local timezone and create /etc/adjtime

ln -sf /usr/share/zoneinfo/America/Los_Angeles /etc/localtime
hwclock --systohc

Set and generate locale

echo "en_US.UTF-8 UTF-8" > /etc/locale.gen
locale-gen
echo "LANG=en_US.UTF-8" > /etc/locale.conf

Set the host name

hostnamectl set-hostname <hostname>

Adjust the hosts file

cat << EOF > /etc/hosts
127.0.0.1    localhost.localdomain   localhost
::1          localhost6.localdomain   localhost6
192.168.1.250 $myhostname.$mydomain   $myhostname
2001:470:8050::250 $myhostname.$mydomain  $myhostname
EOF

Enable NTP daemon

timedatectl set-ntp true

Set the root password

passwd

To bootload or not to bootload

systemd-boot

mkdir -p /boot/loader/entries

cat << EOF > /boot/loader/loader.conf
default arch
console-mode max
timeout 5
EOF

cat << EOF > /boot/loader/entries/arch.conf
title Arch Linux
linux /vmlinuz-linux
initrd /initramfs-linux.img
options root=/dev/sda2 net.ifnames=0
EOF

bootctl --path=/boot install

EFIStub

efibootmgr --create --disk /dev/sda --part 1 --label "Arch Linux" -u -l /vmlinuz-linux \
    'root=/dev/sda2 net.ifnames=0 initrd=\initramfs-linux.img'

Configure networking

DHCP

cat << EOF > /etc/systemd/network/eth0.network
[Match]
Name=eth0

[Network]
DHCP=yes
EOF

Static

cat << EOF > /etc/systemd/network/eth0.network
[Match]
Name=eth0

[Network]
Address=192.168.1.250/24
Gateway=192.168.1.1
DNS=192.168.1.1

Address=2001:470:8050::250/64
Gateway=2001:470:8050::1
DNS=2001:470:8050::1
EOF

Enable networking on boot

systemctl enable systemd-networkd
systemctl enable systemd-resolved
systemctl enable sshd

Exit chroot and reboot

exit
reboot