arch installation - seintzx/dotfiles GitHub Wiki

Arch Linux Installation

Introduction

This is my archlinux installation guide both for single and dual boot with windows

If you want a more in-depth guide read the Arch Installation Guide, it's the best starting point to understand what I'll do here

Thanks to fam4r for the help

If you want to single-boot simply skip to archlinux's part

Download

Download the latest iso here and create a bootable USB drive

For a *nix system you can run:

$ dd bs=16M if=<image.iso> of=/dev/sdX status=progress && sync

Disk Preparation

Use gparted live iso to clear old disk, create GPT partition's table and those partition:

  • 60% windows (NTFS)
  • 40% arch (unallocated or ext4)

boot partition will be create by windows during installation process

NOTE: Partition's percentage depends on your need note that on arch I keep root and home together

Install windows

  • Install windows through installation's media
  • Install all updates from control panel
  • Disable secure boot from BIOS
  • Disable fastboot (Control Panel -> Hardware -> Power Options -> System)

Install Archlinux

Fire up arch installation's media

Set font

$ setfont ter-132n

Create partitions

NOTE: Do not create EFI partition if dual-booting

$ cgdisk /dev/nvme0n1
1 512MB EFI partition # Hex code ef00
2 100% size partiton # (to be encrypted) Hex code 8300

Format to EFI

$ mkfs.vfat -F32 -n EFI /dev/nvme0n1pY

NOTE: Y is the number of the EFI partition where you want to install boot or the one already create by windows

Setup encryption

Note: Many NVMe drives can exceed 2GB/s, consider your crypto algorithm wisely, review cryptsetup benchmark, the defaults are viewable at end of cryptsetup --help, defaults are commonly the fastest with good security from my experience with cryptsetup (AES 256, sha256, 2000ms)

$ cryptsetup --use-random -v luksFormat --type luks2 /dev/nvme0n1pX
$ cryptsetup luksOpen /dev/nvme0n1pX luks

NOTE: X is the number of the partition where you want to install arch

Create encrypted partitions

This creates one partions for both root and home

If you want /home and /root into differents partition do it now

$ pvcreate /dev/mapper/luks
$ vgcreate vg0 /dev/mapper/luks
$ lvcreate -l +100%FREE vg0 --name root
$ mkfs.ext4 -L root /dev/mapper/vg0-root

Mounting partition

$ mount /dev/mapper/vg0-root /mnt
$ mkdir /mnt/boot
$ mount /dev/nvme0n1pY /mnt/boot

Connect to internet

$ iwctl

Install the system

$ pacstrap /mnt base base-devel \
    zsh neovim git \
    efibootmgr \
    dialog wpa_supplicant networkmanager \
    intel-ucode linux linux-firmware lvm2

It includes editor, boot manager, driver for intel and lvm compatibility, software for network connection

Generate mount configuration's file

$ genfstab -pU /mnt | tee -a /mnt/etc/fstab

Change relatime to noatime on all non-boot partitions (reduces wear if using an SSD)

Make /tmp a ramdisk

$ nvim /mnt/etc/fstab
--------------------------------------------------------------------------------

...

#tmpfs  /tmp    tmpfs   defaults,noatime,mode=1777  0   0

Uncomment the line if you know what you are doing

Enter the new system

$ arch-chroot /mnt /bin/bash

Setup system clock

$ ln -s /usr/share/zoneinfo/Europe/Rome /etc/localtime
$ hwclock --systohc

Set the hostname

$ echo <MYHOSTNAME> /etc/hostname

Hosts

$ nvim /etc/hosts
--------------------------------------------------------------------------------

127.0.0.1        localhost
::1              localhost
127.0.1.1        myhostname.localdomain        myhostname

Generate locale

Uncomment wanted locales in /etc/locale.gen

$ nvim /etc/locale.gen
$ locale-gen
$ localectl set-locale LANG=en_US.UTF-8

NOTE: To avoid problems with gnome-terminal set locale system wide do NOT set LC_ALL=C. It overrides all the locale vars and messes up special characters. Pay attention to the .UTF-8 Capital letters!

$ echo LANG=en_US.UTF-8 >> /etc/locale.conf
$ echo LC_ALL= >> /etc/locale.conf

Set password for root

$ passwd

Add user

$ groupadd MYUSERNAME
$ useradd -m -G wheel,storage,power,network,uucp -s /bin/zsh MYUSERNAME
$ passwd MYUSERNAME
$ EDITOR=nvim visudo
--------------------------------------------------------------------------------

...

%wheel ALL=(ALL) ALL

...

Configure boot loader

$ bootctl --path=/boot install
$ nvim /boot/loader/loader.conf
--------------------------------------------------------------------------------

default arch.conf
timeout 5
editor no
$ nvim /boot/loader/entries/arch.conf
--------------------------------------------------------------------------------

title archlinux
linux /vmlinuz-linux
initrd /intel-ucode.img
initrd /initramfs-linux.img
options cryptdevice=UUID=<UUID>:vg0:allow-discards
    root=/dev/mapper/vg0-root
    rw quiet
    nvme_core.default_ps_max_latency_us=5500
    mem_sleep_default=deep
    psmouse.synaptics_intertouch=1

NOTE: use blkid to find the <UUID> of the raw encrypted device (/dev/nvme0n1pX)

Windows boot loader

DUAL BOOT ONLY

$ ls /boot/EFI/Microsoft/Boot
$ mkdir /mnt/winboot
$ mount /dev/nvme0n1pY /mnt/winboot
$ cp -r /mnt/winboot/EFI/Microsoft /boot/EFI

Above step may be unnecessary

$ nvim /boot/loader/entries/windows.conf
--------------------------------------------------------------------------------

title windows
efi /EFI/Microsoft/Boot/bootmgfw.efi

Check with bootctl list

Install grub

$ pacman -S grub
$ grub-install --target=x86_64-efi --efi-directory=boot /dev/nvme0n1pY

Modify config

$ nvim /etc/default/grub
--------------------------------------------------------------------------------

...

# GRUB_CMDLINE_LINUX="<copy paramenters from entries's options row>"
GRUB_CMDLINE_LINUX="cryptdevice=UUID=<UUID>:vg0:allow-discards ..."

GRUB_PRELOAD_MODULES="... lvm"

...

Save config

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

Configure mkinitcpio

$ nvim /etc/mkinitcpio.conf
--------------------------------------------------------------------------------

...

MODULES=(... ext4)

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

...

NOTE: Order is important, do not change it unless you know what you are doing

Generate initrd image

$ mkinitcpio -p linux

If the command fails because there's no space left on partition, remove fallback image

$ nvim /etc/mkinitcpio.d/linux.preset
--------------------------------------------------------------------------------

...

PRESETS=('default')

...

Enable TRIM (SSD only)

$ cat /etc/lvm/lvm.conf | grep issue_discards
$ sed -i 's/issue_discards = 0/issue_discards = 1/g' /etc/lvm/lvm.conf
$ cat /etc/lvm/lvm.conf | grep issue_discards
$ systemctl enable --now fstrim.timer

Ultimate installation

$ exit
$ umount -R /mnt
$ reboot

Links

⚠️ **GitHub.com Fallback** ⚠️