Skip to content

Instantly share code, notes, and snippets.

@dixiedream
Last active August 31, 2024 07:36
Show Gist options
  • Save dixiedream/55ad623c8ccc914b6adeb646584a86d8 to your computer and use it in GitHub Desktop.
Save dixiedream/55ad623c8ccc914b6adeb646584a86d8 to your computer and use it in GitHub Desktop.
Arch installation

Arch installation steps

Change var noted with {{ VAR }} notation to your setup and taste.

1 Install setup

1.1 Keyboard layout skippable

# set italian keyboard layout
loadkeys it

1.2 Internet connection

1.2.1 Wired

Check if you have an ip address

ip a

1.2.2 Wi-Fi

If you're running an Archlinux live

iwctl
device list
station {{ DEVICE }} scan
station {{ DEVICE }} get-networks
station {{ DEVICE }} connect {{ SSID }}
quit
ip a

If you're running an Artix Linux live follow the 20.2 Runit-Connman chapter

1.3 SSH connection skippable

On the remote (target) machine

passwd

Now check that PermitRootLogin yes is present (and uncommented) in /etc/ssh/sshd_config.

systemctl start sshd

2 Drive partition and file system

2.1 Partitioning

# Example of devices: sda, vda, nvme0n1
fdisk -l
fdisk /dev/{{ DEVICE }}

2.1.1 EFI GPT

  • Create a partition of type GPT with g
  • Create a 300Mb partition EFI type with n, press Enter for 0 as first/starting sector then select +300M as last/ending sector
  • Set the type for this partition as EFI with t then 1 for selecting the EFI type
  • Create another partition for the file system with n, this time press Enter two times (we need every remaining space as storage)
  • The type of this partition should be already set as Linux or Linux filesystem*

2.1.2 BIOS DOS MBR legacy vbox-qemu

  • Create a partition of type DOS with o
  • Create a new partition for the file system with n, then press Enter two times (we need every remaining space as storage)
  • The type of this partition should be already set as Linux or Linux filesystem*
  • Make the partition bootable by press a

* If not the case, press t to select the partition type menu, press L to list all types then insert the number corrisponding to Linux filesystem

FROM NOW ON MAKE SURE TO SKIP UNREQUIRED STEPS FOR YOUR PARTITION SCHEME

2.2 Formatting

2.2.1 Format EFI partition

# Examples of EFI partition: sda1, vda1, nvme0n1p1
mkfs.vfat -F 32 /dev/{{ EFI_PARTITION }}

2.2.2 Disk encryption skippable

# Examples of root partition: sda2 vda2 nvme0n1p2
cryptsetup -y -v luksFormat /dev/{{ ROOT_PARTITION }}
cryptsetup open /dev/{{ ROOT_PARTITION }} cryptroot

2.2.3 Create root file system

# WITH encryption
mkfs.ext4 /dev/mapper/cryptroot
# WITHOUT encryption
mkfs.ext4 /dev/{{ ROOT_PARTITION }}

2.3 Mounting

2.3.1 Mount root

# WITH encryption
mount /dev/mapper/cryptroot /mnt
# WITHOUT encryption
mount /dev/{{ ROOT_PARTITION }} /mnt

2.3.2 Mount EFI partition

mkdir /mnt/boot
mount /dev/{{ EFI_PARTITION }} /mnt/boot

3 Bootstrap the system

Change neovim with your editor of choice (vim, nano, vi, micro)

# Archlinux
pacman -Sy archlinux-keyring
pacstrap /mnt base base-devel linux linux-firmware wpa_supplicant git neovim

# Artix Linux
basestrap /mnt base base-devel linux linux-firmware runit elogind-runit connman connman-runit wpa_supplicant git neovim

4 Generate fstab non encrypted skippable

# Archlinux
genfstab -U -p /mnt >> /mnt/etc/fstab

# Artix linux
fstabgen -U /mnt >> /mnt/etc/fstab

5 Chroot

# Archlinux
arch-chroot /mnt
# Artix linux
artix-chroot /mnt

6 Initramfs Archlinux skippable

nvim /etc/mkinitcpio.conf
# WITH encryption
HOOKS=(base systemd autodetect microcode keyboard sd-vconsole modconf kms block sd-encrypt filesystems fsck)
# WITHOUT encryption
HOOKS=(base systemd autodetect microcode modconf kms keyboard sd-vconsole block filesystems fsck)

7 Locales skippable

ln -sf /usr/share/zoneinfo/Europe/Rome /etc/localtime
#timedatectl set-ntp true # TODO: need to move to Ansible
hwclock --systohc
nvim /etc/locale.gen
locale-gen
echo "LANG=en_US.UTF-8" > /etc/locale.conf
echo "KEYMAP=it" > /etc/vconsole.conf

Choose hostname

nvim /etc/hostname

Edit the /etc/hosts file

127.0.0.1	localhost
::1		localhost
127.0.1.1	{{ HOSTNAME }}.local	{{ HOSTNAME }}

8 Build

mkinitcpio -p linux

9 Setup root password

passwd

10 Bootloader

10.1 Single boot

10.1.1 Systemd boot EFI skippable systemd

bootctl install
echo "editor no" >> /boot/loader/loader.conf
nvim /boot/loader/entries/arch.conf

This is the content of arch.conf file

# /boot/loader/entries/arch.conf
title Archlinux
linux /vmlinuz-linux
initrd /initramfs-linux.img
# WITH encryption
options rw rd.luks.name={{ device-UUID }}=cryptroot root=/dev/mapper/cryptroot
# WITHOUT encryption
options rw root=UUID={{ device-UUID }}

Override {{ device-UUID }} with output command of :r !blkid corrisponding to your dev/{{ ROOT_PARTITION }} UUID (sda2 or nvme0n1p2 for ex... even when encrypted!)

bootctl update
bootctl list

10.1.2 Syslinux BIOS-MBR skippable

syslinux-install_update -i -m -a

Edit the /boot/syslinux/syslinux.cfg file checking the root partition matches with your /dev/{{ ROOT_PARTITION }}

10.1.3 Refind BIOS-MBR EFI skippable runit

pacman -S refind
refind-install

# Check the configuration file and eventually setup the root partition
nvim /boot/refind_linux.conf

10.2 Dual boot skippable

If dual boot is needed try to use separate drives for the installations.

10.2.1 Windows OS

It's advisable to set the Windows installation first than the Linux one, as Windows tends to overwrite boot priority or mess your disk.

First follow 10.1.1 then mount Windows EFI partition and copy the Microsoft folder inside your EFI folder at /boot, here is an example

# use the MOUNTPOINT you prefer
mount /dev/sdb1 /{{ MOUNTPOINT }}
cp -ax /{{ MOUNTPOINT }}/EFI/Microsoft /boot/EFI/

10.2.2 Linux

If the other Linux installation is on the same hard drive just add a second entry like you did in 10.1.1 and you're done.

In case you have a dedicated linux install (bootloader + root) on another hard drive just follow the Arch wiki

TL;DR

pacman -S edk2-shell
cp /usr/share/edk2-shell/x64/Shell.efi /boot/shellx64.efi

Then create a new loader like this

# /boot/loader/entries/mySecondLinux.conf
title   MySecondLinux
efi     /shellx64.efi
options -nointerrupt -nomap -noversion {{ EFI_HD_MAP }}:{{ EFI_PATH }}

Where the EFI_HD_MAP variable points to the result of the map command from the UEFI Shell provided by the edk2-shell package installation (ex: HD0b, FS1 or BLK1) and the EFI_PATH is the path for the second linux bootloader, you can find that using the efibootmgr command.

17. Create user skippable

useradd -m -g users -G wheel {{ USERNAME }}
passwd {{ USERNAME }}
EDITOR=nvim visudo

18. Create swap file skippable

change the count number as you wish (default 4G)

dd if=/dev/zero of=/swapfile bs=1G count=4 status=progress
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
echo "/swapfile none swap defaults 0 0" >> /etc/fstab

19. Microcodes and display drivers

20. Network

20.1 Systemd - systemd-networkd skippable

20.1.1 Wired

Create these files

# /etc/systemd/network/en.network
[Match]
Name=en*

[Network]
DHCP=yes

[DHCP]
RouteMetric=10

20.1.2 Wi-Fi

# /etc/systemd/network/wl.network
[Match]
Name=wl*

[Network]
DHCP=yes

[DHCP]
RouteMetric=20

Setup Wi-Fi connection

Get a wifi interface name with

ip a

Create this file

# /etc/wpa_supplicant/wpa_supplicant-{{ WIFIINTERFACE }}.conf
ctrl_interface=/run/wpa_supplicant
ctrl_interface_group=wheel
update_config=1

ap_scan=1

# Begin network section

Then use this command to connect

wpa_passphrase {{ SSID }} >> /etc/wpa_supplicant-{{ WIFIINTERFACE }}.conf

When you need to connect to a WPA-ENTERPRISE or others add this block to the conf file

WIFI

# /etc/wpa_supplicant/wpa_supplicant-{{ WIFIINTERFACE }}.conf
network={
    ssid="{{ SSID }}"
    key_mgmt=WPA-EAP
    eap=PEAP
    identity="{{ USERNAME }}"
    password="{{ PASSWORD }}"
    phase2="autheap=GTC"
  }

WIRED

# /etc/wpa_supplicant/wpa_supplicant-wired-{{ ETHINTERFACE }}.conf
network={
    ssid="{{ SSID }}"
    key_mgmt=WPA-EAP
    eap=PEAP
    identity="{{ USERNAME }}"
    password="{{ PASSWORD }}"
    phase2="autheap=GTC"
  }

Enable services

systemctl enable systemd-networkd
systemctl enable systemd-resolved
systemctl enable wpa_supplicant@{{ WIFIINTERFACE }}

20.2 Runit - Connman skippable

Connman out of the box already setup wired connection. The only thing remain is to enable the service after the reboot

# run this after the reboot!
ln -s /etc/runit/sv/connmand /run/runit/service/

# If your network card doesn't turn on after booting...
connmanctl enable wifi

Basics steps for connecting to a wifi with connman

# make sure your wifi card is on
connmanctl
scan wifi
services
agent on
connect {{ LONG_WIFI_ID }}

Visit the arch wiki for support on connecting to wifi Connman

21. Closing and rebooting

exit
# Ignore the error if appears
umount -R /mnt
reboot

After reboot todo list:

  • Enable and start network service (systemd-networkd or connman)
  • Start some display server, install a DE or a WM... or you can continue below

22. My setup skippable

22.1 Ansible

Follow the instruction on the repo Ansible

22.2 Bash scripts unmantained

I've created my fork of LARBS

git clone https://github.com/dixiedream/LARBS.git
cd LARBS
sh larbs.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment