Skip to content

Latest commit

 

History

History
275 lines (205 loc) · 6.69 KB

File metadata and controls

275 lines (205 loc) · 6.69 KB

How to install Arch Linux: The TL;DR

Overview

This guide is meant to be an opinionated and to the point guide on installing Arch Linux. Power users with different opinions should refer to the official Arch Linux installation guide.

Requirements

  • These steps are best done on a Linux or OSX computer to run early steps.
    • Windows users may use WSL (Windows Subsystem for Linux)
    • Or can use an Ubuntu live CD
  • A blank flash drive, 1GB+
  • Target computer
    • Known to be compatible with Linux
    • Supports UEFI boot
    • Has wireless card
    • Does not require proprietary "out of tree" drivers

Goals

  • Full disk encryption
  • Passwordless: Use GPG Smartcard for login, sudo, ssh
  • Simple partitioning scheme

Steps

  1. Download latest Arch Linux ISO image file
  2. Install torrent client such as aria2
  3. Get latest .iso.torrent URL from Arch Linux releases
  4. Download ISO with aria2.
Example:
```
aria2c --on-download-complete=exit https://YOUR_TORRENT_URL_HERE
```
  1. Write latest ISO to flash drive
  2. List current storage devices with lsblk
  3. Insert flash drive
  4. List current storage devices with lsblk again
  5. Take note of new drive. Example: /dev/sdX
  6. Use dd to write ISO image to drive
```
sudo dd \
  bs=4M \
  if=archlinux-DATE-x86_64.iso \
  of=/dev/sdX \
  status=progress \
  oflag=sync
```
  1. Remove flash drive

  2. Boot flash drive of target laptop

  3. Insert flash drive

  4. Boot laptop to BIOS screen * e.g. F1, F2, F10, Delete, Escape while computer starts booting

  5. Check that 'secure boot' is Disabled

  6. Ensure USB drives will boot by default

  7. Boot on installation medium

  8. Adjust rotation, fonts, keyboard layout

  9. Change rotation if needed

```
echo 1 > /sys/class/graphics/fbcon/rotate_all
```

Note: May need to use 2 or 3 depending on starting state

  1. Increase font size if needed
```
setfont /usr/share/kbd/consolefonts/latarcyrheb-sun32.psfu.gz
```
Note: This is the current largest font
  1. Set desired keyboard layout (if not US standard)
Example: German
```
loadkeys de-latin1
```
  1. Connect to the internet

  2. Select and join a wireless network with wifi-menu

  3. Verify connection with ping 1.1.1.1

  4. Update system clock

    timedatectl set-ntp true
    
  5. Set up encrypted disk

  6. Determine target root device with lsblk. Example: /dev/mmcblk0

  7. Create all partitions

TL:DR;
```
sgdisk -Zo -n 1:2048:+512M -t 1:EF00 -c 1:boot -N 2 -t 2:8300 -c 2:root /dev/mmcblk0
```

Explanation:
```
sgdisk \
   -Zo             `# zero out any existing partitions` \
   -n 1:2048:+512M `# create new 512M partition for boot` \
   -t 1:EF00       `# set type to EFI` \
   -c 1:boot       `# set comment/label to "boot"` \
   -N 2            `# create second new partition filling rest of disk` \
   -t 2:8300       `# set type Linux` \
   -c 2:root       `# set comment/label to "root"` \
   /dev/mmcblk0     # writing to your target drive
 ```

Note: As an alternative, you can graphically partition using `cgdisk`
  1. Format the EFI boot partition as FAT32

    mkfs.vfat -F32 /dev/mmcblk0p1
    
  2. Encrypt and format the root partition

    # encrypt root partition with passphrase
    cryptsetup -y -v luksFormat --type luks2 /dev/mmcblk0p2
    
    # decrypt drive and expose as /dev/mapper/cryptroot
    cryptsetup open /dev/mmcblk0p2 cryptroot
    
    # make journaled ext4 partition in decrypted root device
    mkfs.ext4 -j /dev/mapper/cryptroot
    
  3. Mount the file systems

mount /dev/mapper/cryptroot /mnt
mkdir /mnt/boot
mount /dev/mmcblk0p1 /mnt/boot
  1. Select the Mirrors
pacman -Sy pacman-contrib
curl https://www.archlinux.org/mirrorlist/all/https/ \
| sed 's/^#Server/Server/g' \
| rankmirrors -n 0 - \
> /etc/pacman.d/mirrorlist

Note: This avoids manual mirror sorting. Native script does not yet exist.

  1. Install the base packages
pacstrap /mnt base
  1. Configure the System
  2. Fstab: Generate 'File System TABle' of contents
genfstab -U /mnt >> /mnt/etc/fstab
  1. Chroot: login to new arch installation by changing root
arch-chroot /mnt
  1. Set time zone
timedatectl set-timezone Region/City
hwclock --systohc
  1. Localization: setting your preferred language
# Uncomment preferred language in /etc/locale.gen
sed -i 's/^#en_US/en_US/g' /etc/locale.gen

# Create /etc/locale.conf and set default language
echo "LANG=en_US.UTF-8" > /etc/locale.conf

# Non-US keyboard users can set their default layout
echo "KEYMAP=de-latin1" > /etc/vconsole.conf
  1. Name your computer!
# Create the hostname file
hostnamectl set-hostname computername

# Specify new hostname for the network
echo "127.0.0.1 computername.localdomain computername localhost" > /etc/hosts
echo "::1 computername.localdomain computername localhost" >> /etc/hosts
  1. Initramfs: install system initialization bundle
# Enable encryption support in initramfs
sed -i 's/ filesystems/ encrypt filesystems/g' /etc/mkinitcpio.conf

# Generate new initramfs
mkinitcpio -p linux
  1. Create a user with super user rights
pacman -S sudo
echo "%wheel ALL=(ALL) ALL" >> /etc/sudoers
useradd -m -G wheel -s /bin/bash janedoe
passwd janedoe
  1. Configure and install bootloader
bootctl --path=/boot install
echo "default arch" > /boot/loader/loader.conf
echo "title Arch Linux" >> /boot/loader/entries/arch.conf
echo "linux /vmlinuz-linux" >> /boot/loader/entries/arch.conf
echo "initrd /initramfs-linux.img" >> /boot/loader/entries/arch.conf
echo "options cryptdevice=UUID=$(blkid -o value /dev/mmcblk0p2 | head -n1):cryptroot root=/dev/mapper/cryptroot rw" >> /boot/loader/entries/arch.conf
  1. Install critical packages
pacman -S dialog wpa_supplicant iw
  1. Boot into Arch 1. Shutdown with

    exit
    shutdown -h now
    
2. Remove flash drive

3. Boot computer

Recovery

If you need to resume from a broken or partial install, perform steps 3-5 then:

cryptsetup open /dev/mmcblk0p2 cryptroot
mount /dev/mapper/cryptroot /mnt
mount /dev/mmcblk0p1 /mnt/boot
arch-chroot /mnt

References