Skip to content

Instantly share code, notes, and snippets.

@Zayon
Last active August 18, 2021 13:33
Show Gist options
  • Save Zayon/afc3d9fd83cbfc6e63ded6887eb9b5fc to your computer and use it in GitHub Desktop.
Save Zayon/afc3d9fd83cbfc6e63ded6887eb9b5fc to your computer and use it in GitHub Desktop.

Arch installation

Disk Partitionning

fdisk -l or lsblk to identify disks

Determine the main disk where /boot partition will reside. We need two partitions: the one for /boot and the other for LVM group.

Open partitioning tool fdisk /dev/sda

sda1 512M Boot partition (type 4)
sda2 512M EFI Partition (type 1)
sda3 100%Free Linux LVM Partition (type 30)

Now you have to go through a couple of steps to prepare partitions:

  • Press 'g' and Enter keys to create a new GPT disk label
  • Press 'n' and Enter keys to create a new partition
  • "Partition number (1-128, default 1):" -- just hit Enter
  • "First sector ..." -- just hit Enter
  • "Last sector ..." -- "+512M"
  • Press 't' and Enter
  • Choose partition 1
  • Press '4' and Enter (this will set a partition type to 'Boot partition')
  • Press 'n' and Enter keys to create a new partition
  • "Partition number (1-128, default 2):" -- just hit Enter
  • "First sector ..." -- just hit Enter
  • "Last sector ..." -- "+512M"
  • Press 't' and Enter
  • Choose partition 2
  • Press '1' and Enter (this will set a partition type to 'EFI System')
  • Now we have to create a partition for a part of the disk that will be handled by LVM. Press 'n' and Enter.
  • "Partition number ..." -- just hit Enter
  • "First sector ..." -- just hit Enter
  • "Last sector ..." -- just hit Enter
  • Press 't' and Enter
  • Choose partition 3
  • Type in '30' and Enter
  • The reader should see "Changed type of partition 'Linux filesystem' to 'Linux LVM
  • Press 'p' and Enter. Verify that partition table looks about right.
  • Press 'w' and Enter

Encryption of the system partition

Create the LUKS encrypted container at the "system" partition. Enter the chosen password twice.

cryptsetup luksFormat --type luks1 /dev/sda3

Open the container:

cryptsetup open /dev/sda3 cryptlvm

The decrypted container is now available at /dev/mapper/cryptlvm.

Preparing the logical volumes

Create a physical volume on top of the opened LUKS container:

pvcreate /dev/mapper/cryptlvm

Create the volume group named MyVolGroup (or whatever you want), adding the previously created physical volume to it:

vgcreate MyVolGroup /dev/mapper/cryptlvm

Create all your logical volumes on the volume group:

lvcreate -L 8G MyVolGroup -n swap
lvcreate -l 100%FREE MyVolGroup -n root

Format your filesystems on each logical volume:

mkfs.ext4 /dev/MyVolGroup/root
mkswap /dev/MyVolGroup/swap

Mount your filesystems:

mount /dev/MyVolGroup/root /mnt
swapon /dev/MyVolGroup/swap

Preparing the boot partition

Format the boot partition in ext4: mkfs.ext4 /dev/sda1 Create the directory /mnt/boot: mkdir /mnt/boot Mount the partition to /mnt/boot: mount /dev/sda1 /mnt/boot

Format the efi partition in FAT32: mkfs.fat -F32 /dev/sda2 Create the directory /mnt/efi: mkdir /mnt/efi Mount the partition to /mnt/boot: mount /dev/sda2 /mnt/efi

Base installation

Connect to the internet

Either:

  • Plug an eternet cable
  • Wi-Fi—authenticate to the wireless network using iwctl

iwctl

Connect to a network

First, if you do not know your wireless device name, list all Wi-Fi devices:

[iwd]# device list

Then, to scan for networks:

[iwd]# station device scan

You can then list all available networks:

[iwd]# station device get-networks

Finally, to connect to a network:

[iwd]# station device connect SSID or iwctl --passphrase passphrase station device connect SSID

Set mirrors for faster installation

run reflector --verbose --country France --latest 5 --sort rate --save /etc/pacman.d/mirrorlist

Install base packages

Install base packages and bootstrap the system. That will download the kernel and all other packages to make your Arch installation working afterwards (hopefully :D): pacstrap /mnt base base-devel linux-lts linux-firmware

pacstrap /mnt zip unzip p7zip vim bash-completion lvm2

Configure the system

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

pacstrap /mnt grub os-prober efibootmgr

Chroot into a freshly bootstrapped system

arch-chroot /mnt

Locale

vim /etc/locale.gen => Uncomment en_US.UTF-8 UTF-8 then run locale-gen

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

Time zone

Set the time zone:

ln -sf /usr/share/zoneinfo/Europe/Paris /etc/localtime

Run hwclock to generate /etc/adjtime:

hwclock --systohc --utc

Change hostname

vim /etc/hostname

/etc/hosts

127.0.0.1	  localhost
::1		      localhost

Configuring mkinitcpio

vim /etc/mkinitcpio.conf

HOOKS=(base udev keyboard autodetect keymap consolefont modconf block encrypt lvm2 filesystems resume fsck)

Then, Recreate Initramfs image for LVM:

mkinitcpio -p linux

Set the root password

passwd

Bootloader (grub)

Check efivars mountpoints /sys/firmware/efi/efivars

Exit chroot with ALT+F2 then:

modprobe efivarfs
mount -t efivarfs efivarfs /sys/firmware/efi/efivars
## mount --bind /sys/firmware/efi/efivars /mnt/sys/firmware/efi/efivars

Switch back to your first terminal ALT+F1

mount -t efivarfs efivarfs /sys/firmware/efi/efivars

grub-install --target=x86_64-efi --efi-directory=/efi --bootloader-id=grub --recheck

Use blkid to know the UUID of parition containing the LUKS container (TYPE="crypto_LUKS")

blkid | vim - enter visual mode (v) then select the uuid and yank it (y). Exit visual mode press :e! /etc/default/grub and paste the uuid to write the following line:

GRUB_CMDLINE_LINUX_DEFAULT="resume=/dev/MyVolGroup/swap ..."
GRUB_CMDLINE_LINUX="cryptdevice=UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx:cryptlvm root=/dev/MyVolGroup/root"

/!\ May need to add vsyscall=emulate in GRUB_CMDLINE_LINUX_DEFAULT for docker.

Also add lvm to preload modules: GRUB_PRELOAD_MODULES="... lvm"

grub-mkconfig -o /boot/grub/grub.cfg

Install & Enable NetworkManager

pacman -Syy networkmanager

User creation

useradd -m -G wheel,docker,video,input -s /bin/bash username passwd username

Sudo

pacman -S sudo vi

visudo the uncomment the %wheel ALL=(ALL) ALL line

Continue to normal installation process (reboot, install )...

Graphical setup

sudo pacman -S xorg xorg-server mate mate-extra lightdm lightdm-gtk-greeter sudo systemctl enable lightdm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment