# Base System

## Setting up mirrors

The Arch installation environment comes with `reflector`, a tool that generates mirror lists for `pacman`. At boot time, `reflector` is executed once to include the most recently synced mirrors and sorts them by download rate. This file will be copied to the installation destination later on.

`reflector` allows for a few filtering options:

| Filter             | Description                                                                                             |
| ------------------ | ------------------------------------------------------------------------------------------------------- |
| `--age n`          | Only return mirrors that have synchronized in the last _n_ hours.                                       |
| `--country NAME`   | Restrict mirrors to selected countries, e.g. `France,Germany` (check available with `--list-countries`) |
| `--fastest n`      | Return the _n_ fastest mirrors that meet the other criteria. Do not use without filters!                |
| `--latest n`       | Limit the list to the _n_ most recently synchronized servers.                                           |
| `--score n`        | Limit the list to the _n_ servers with the highest score.                                               |
| `--number n`       | Return at most _n_ mirrors.                                                                             |
| `--protocol PROTO` | Restrict protocol used by mirrors. Either `https`, `http`, `ftp` or a combination (comma-separated)     |

To have `reflector` generate a list of mirrors from Germany, which synced in the past 12 hours and use HTTPS for transfer:

~~~bash
reflector --country Germany --age 12 --protocol https --save /etc/pacman.d/mirrorlist
~~~

## Parallel downloads

By default, `pacman` downloads packages one-by-one. If you have a fast internet connection, you can configure `pacman` to download packages in parallel, which can speed up installation significantly.

Open `/etc/pacman.conf`, uncomment the line `#ParallelDownloads = 5` and set it to a value of your preference:

~~~
...
# Misc options
#UseSyslog
#Color
#NoProgressBar
CheckSpace
#VerbosePkgLists
ParallelDownloads = 10
#DisableSandbox
...
~~~

Alternatively, replace the settings directly with `sed` (e.g. setting 10 parallel downloads at a time):

~~~bash
sed -i "/etc/pacman.conf" -e "s|^#ParallelDownloads.*|&\nParallelDownloads = 10|"
~~~

## Installing base packages

The absolute minimum set of packages required to install Arch Linux onto a machine is as follows:

~~~bash
pacstrap /mnt base linux linux-firmware
~~~

However, this selection lacks the tooling required for file systems, RAID, LVM, special firmware for devices not included with `linux-firmware`, networking software, a text editor or packages necessary to access documentation. It also lacks CPU microcode packages with stability and security updates.

The following table contains additional packages you most likely want to append to the above `pacstrap` command:

| Package          | Description                                                                                                       |
|------------------|-------------------------------------------------------------------------------------------------------------------|
| `base`           | Absolute essentials **(required)**                                                                                |
| `linux`          | Vanilla Linux kernel and modules, with a few patches applied **(required)**                                       |
| `linux-hardened` | A security-focused Linux kernel applying a set of hardening patches to mitigate kernel and userspace exploits     |
| `linux-lts`      | Long-term support (LTS) Linux kernel and modules                                                                  |
| `linux-zen`      | Result of a collaborative effort of kernel hackers to provide the best Linux kernel possible for everyday systems |
| `linux-firmware` | Device firmware files, e.g. WiFi **(required)**                                                                   |
| `intel-ucode`    | Intel CPU microcode **(required, if on Intel)**                                                                   |
| `amd-ucode`      | AMD CPU microcode **(required, if on AMD)**                                                                       |
| `btrfs-progs`    | Userspace tools to manage btrfs filesystems                                                                       |
| `dosfstools`     | Userspace tools to manage FAT filesystems                                                                         |
| `exfatprogs`     | Userspace tools to manage exFAT filesystems                                                                       |
| `f2fs-tools`     | Userspace tools to manage F2FS filesystems                                                                        |
| `e2fsprogs`      | Userspace tools to manage ext2/3/4 filesystems                                                                    |
| `jfsutils`       | Userspace tools to manage JFS filesystems                                                                         |
| `nilfs-utils`    | Userspace tools to manage NILFS2 filesystems                                                                      |
| `ntfs-3g`        | Userspace tools to manage NTFS filesystems                                                                        |
| `udftools`       | Userspace tools to manage UDF filesystems                                                                         |
| `xfsprogs`       | Userspace tools to manage XFS filesystems                                                                         |
| `lvm2`           | Userspace tools for Logical Volume Management                                                                     |
| `cryptsetup`     | Userspace tools for encrypting storage devices (LUKS)                                                             |
| `networkmanager` | Comprehensive network management and configuration suite                                                          |
| `nano`           | Console text editor                                                                                               |
| `man`            | Read documentation (**man**uals)                                                                                  |
| `sudo`           | Execute commands with elevated privileges                                                                         |

<p class="callout danger"><strong>CAUTION:</strong> If you have an AMD CPU, include the <code>amd-ucode</code> package. If you have an Intel CPU, include the <code>intel-ucode</code> package!</p>
    
<p class="callout warning"><strong>ATTENTION:</strong> Include the <code>cryptsetup</code> package if you've encrypted your disks!</p>

A desireable selection of packages for a base system with an AMD CPU, btrfs filesystem, UEFI ESP, LUKS disk encryption, a basic text editor, a network manager and tools for system maintenance as regular user would look something like this:

~~~bash
pacstrap -K /mnt base linux linux-firmware amd-ucode btrfs-progs dosfstools cryptsetup nano networkmanager sudo
~~~

Generate the `fstab` containing information about which storage devices should be mounted at boot:

~~~bash
# Generate fstab referencing UUIDs of devices/partitions
genfstab -U /mnt >> /mnt/etc/fstab
~~~

Switch into the newly installed system with `arch-chroot` and continue setting it up:

~~~bash
arch-chroot /mnt
~~~