Skip to content

Install Arch Linux

This guide will help you install Arch Linux. This is a quickstart guide. For a more explained version refer to the official Arch Linux installation guide. This guide assumes you have a cable internet connected to the machine.

Pre-install

1. Set Keyboard layout

When you are in the root shell type loadkeys de_CH-latin1 to load the swiss keyboard layout. Standard is US.

2. Verify the boot mode

Archiso uses systemd-boot for booting in UEFI mode and syslinux for booting in BIOS mode.

To verify the boot mode, list the efivars directory:

ls /sys/firmware/efi/efivars

If the command shows the directory without error, then the system is booted in UEFI mode. If the directory does not exist, the system may be booted in BIOS (or CSM) mode. If the system did not boot in the mode you desired, refer to your motherboard's manual.

3. Update the system clock

Use timedatectl to ensure the system clock is accurate:

timedatectl set-ntp true

To check the service status, use timedatectl status.

4. Partition Disks

Next up you want to partition your disk(s). Start fdisk by typing:

fdisk

This program is pretty selfexplanatory, just press m for help. Start by setting a Partition table. You can either choose MBR, or GPT. Choose MBR if you start in BIOS mode, and GPT for UEFI mode.

For BIOS mode you just need a main partition with the boot flag set, and for GPT you need a 260-512MB EFI system partition at the beginning of your drive. A swap partition is optional, we can also do a swapfile later.

5. Format partitions

Once the partitions have been created, each must be formatted with an appropriate file system. For example, if the root partition is on /dev/sdX1 and will contain the Ext4 file system, run:

mkfs.ext4 /dev/sdX1

If you created a partition for swap, initialize it with mkswap:

mkswap /dev/sdX2
swapon /dev/sdX2

6. Mount filesystems

Mount the file system on the root partition to /mnt, for example:

mount /dev/sdX1 /mnt

Create any remaining mount points (such as /mnt/efi) using mkdir and mount their corresponding partitions. genfstab will later detect mounted file systems and swap space.

Installation

7. Select the mirrors

Packages to be installed must be downloaded from mirror servers, which are defined in /etc/pacman.d/mirrorlist. On the live system, after connecting to the internet, reflector updates the mirror list by choosing HTTPS mirrors that have synchronized in the last hour and sorting them by download rate.

The higher a mirror is placed in the list, the more priority it is given when downloading a package. You may want to inspect the file to see if it is satisfactory. If it is not, edit the file accordingly, and move the geographically closest mirrors to the top of the list, although other criteria should be taken into account.

This file will later be copied to the new system by pacstrap, so it is worth getting right.

8. Install essential packages

Use the pacstrap script to install the base package, Linux kernel and firmware for common hardware:

pacstrap /mnt base linux linux-firmware

Tip: - You can substitute linux for a kernel package of your choice, or you could omit it entirely when installing in a container. - You could omit the installation of the firmware package when installing in a virtual machine or container.

The base package does not include all tools from the live installation, so installing other packages may be necessary for a fully functional base system. In particular, consider installing:

  • userspace utilities for the management of file systems that will be used on the system,
  • utilities for accessing RAID or LVM partitions,
  • specific firmware for other devices not included in linux-firmware,
  • software necessary for networking,
  • a text editor,
  • packages for accessing documentation in man and info pages: man-db, man-pages and texinfo.

To install other packages or package groups, append the names to the pacstrap command above (space separated) or use pacman while chrooted into the new system. For comparison, packages available in the live system can be found in packages.x86_64.

9. Configure the system

Fstab

Generate an fstab file (use -U or -L to define by UUID or labels, respectively):

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

Check the resulting /mnt/etc/fstab file, and edit it in case of errors.

Chroot

Change root into the new system:

arch-chroot /mnt

Time zone

Set the time zone:

ln -sf /usr/share/zoneinfo/Region/City /etc/localtime

Run hwclock(8) to generate /etc/adjtime:

hwclock --systohc

This command assumes the hardware clock is set to UTC. See System time#Time standard for details.

Localization

Edit /etc/locale.gen and uncomment en_US.UTF-8 UTF-8 and other needed locales. Generate the locales by running:

locale-gen

Create the locale.conf file, and set the LANG variable accordingly: /etc/locale.conf:

LANG=en_GB.UTF-8

If you set the keyboard layout, make the changes persistent in vconsole.conf: /etc/vconsole.conf:

KEYMAP=de_CH-latin1

Network configuration

Create the hostname file: /etc/hostname:

myhostname

Add matching entries to hosts: /etc/hosts:

127.0.0.1   localhost
::1     localhost
127.0.1.1   myhostname.localdomain  myhostname

If the system has a permanent IP address, it should be used instead of 127.0.1.1.

Complete the network configuration for the newly installed environment, that includes installing your preferred network management software.

Initramfs

Creating a new initramfs is usually not required, because mkinitcpio was run on installation of the kernel package with pacstrap.

For LVM, system encryption or RAID, modify mkinitcpio.conf and recreate the initramfs image:

mkinitcpio -P

Root password

Set the root password:

passwd

10. Boot loader

Choose and install a Linux-capable boot loader. If you have an Intel or AMD CPU, enable microcode updates in addition.

The following settings are for GRUB, since thats the bootloader i went with, and is probably the most used one.

BIOS systems

GUID Partition Table (GPT) specific instructions

On a BIOS/GPT configuration, a BIOS boot partition is required. GRUB embeds its core.img into this partition.

Note: - Before attempting this method keep in mind that not all systems will be able to support this partitioning scheme. Read more on Partitioning#GUID Partition Table. - The BIOS boot partition is only needed by GRUB on a BIOS/GPT setup. On a BIOS/MBR setup, GRUB uses the post-MBR gap for the embedding the core.img. On GPT, however, there is no guaranteed unused space before the first partition. - For UEFI systems this extra partition is not required, since no embedding of boot sectors takes place in that case. However, UEFI systems still require an EFI system partition.

Create a mebibyte partition (+1M with fdisk or gdisk) on the disk with no file system and with partition type GUID 21686148-6449-6E6F-744E-656564454649.

  • Select partition type BIOS boot for fdisk.
  • Select partition type code ef02 for gdisk.
  • For parted set/activate the flag bios_grub on the partition.

This partition can be in any position order but has to be on the first 2 TiB of the disk. This partition needs to be created before GRUB installation. When the partition is ready, install the bootloader as per the instructions below.

The space before the first partition can also be used as the BIOS boot partition though it will be out of GPT alignment specification. Since the partition will not be regularly accessed performance issues can be disregarded, though some disk utilities will display a warning about it. In fdisk or gdisk create a new partition starting at sector 34 and spanning to 2047 and set the type. To have the viewable partitions begin at the base consider adding this partition last.

Master Boot Record (MBR) specific instructions

Usually the post-MBR gap (after the 512 byte MBR region and before the start of the first partition) in many MBR partitioned systems is 31 KiB when DOS compatibility cylinder alignment issues are satisfied in the partition table. However a post-MBR gap of about 1 to 2 MiB is recommended to provide sufficient room for embedding GRUB's core.img (FS#24103). It is advisable to use a partitioning tool that supports 1 MiB partition alignment to obtain this space as well as to satisfy other non-512-byte-sector issues (which are unrelated to embedding of core.img). Installation

Install the grub package. (It will replace grub-legacyAUR if that is already installed.) Then do:

grub-install --target=i386-pc /dev/sdX

where /dev/sdX is the disk (not a partition) where GRUB is to be installed. For example /dev/sda or /dev/nvme0n1, or /dev/mmcblk0. See Device file#Block device names for a description of the block device naming scheme.

Now you must generate the main configuration file.

If you use LVM for your /boot, you can install GRUB on multiple physical disks.

Tip: See GRUB/Tips and tricks#Alternative installation methods for other ways to install GRUB, such as to a USB stick.

See grub-install and GRUB Manual for more details on the grub-install command.

UEFI systems

Note: - It is recommended to read and understand the Unified Extensible Firmware Interface, Partitioning#GUID Partition Table and Arch boot process#Under UEFI pages. - When installing to use UEFI it is important to boot the installation media in UEFI mode, otherwise efibootmgr will not be able to add the GRUB UEFI boot entry. Installing to the fallback boot path will still work even in BIOS mode since it does not touch the NVRAM. - To boot from a disk using UEFI, an EFI system partition is required. Follow EFI system partition#Check for an existing partition to find out if you have one already, otherwise you need to create it.

Installation

Note: - UEFI firmwares are not implemented consistently across manufacturers. The procedure described below is intended to work on a wide range of UEFI systems but those experiencing problems despite applying this method are encouraged to share detailed information, and if possible the workarounds found, for their hardware-specific case. A GRUB/EFI examples article has been provided for such cases. - The section assumes you are installing GRUB for x86_64 systems. For IA32 (32-bit) UEFI systems (not to be confused with 32-bit CPUs), replace x86_64-efi with i386-efi where appropriate.

First, install the packages grub and efibootmgr: GRUB is the bootloader while efibootmgr is used by the GRUB installation script to write boot entries to NVRAM.

Then follow the below steps to install GRUB:

  1. Mount the EFI system partition and in the remainder of this section, substitute esp with its mount point.
  2. Choose a bootloader identifier, here named GRUB. A directory of that name will be created in esp/EFI/ to store the EFI binary and this is the name that will appear in the UEFI boot menu to identify the GRUB boot entry.
  3. Execute the following command to install the GRUB EFI application grubx64.efi to esp/EFI/GRUB/ and install its modules to /boot/grub/x86_64-efi/.
grub-install --target=x86_64-efi --efi-directory=esp --bootloader-id=GRUB

After the above install completed the main GRUB directory is located at /boot/grub/. Note that grub-install also tries to create an entry in the firmware boot manager, named GRUB in the above example.

Remember to #Generate the main configuration file after finalizing the configuration.

Tip: If you use the option --removable then GRUB will be installed to esp/EFI/BOOT/BOOTX64.EFI (or esp/EFI/BOOT/BOOTIA32.EFI for the i386-efi target) and you will have the additional ability of being able to boot from the drive in case EFI variables are reset or you move the drive to another computer. Usually you can do this by selecting the drive itself similar to how you would using BIOS. If dual booting with Windows, be aware Windows usually places an EFI executable there, but its only purpose is to recreate the UEFI boot entry for Windows. Note: - --efi-directory and --bootloader-id are specific to GRUB UEFI, --efi-directory replaces --root-directory which is deprecated. - You might note the absence of a device_path option (e.g.: /dev/sda) in the grub-install command. In fact any device_path provided will be ignored by the GRUB UEFI install script. Indeed, UEFI bootloaders do not use a MBR bootcode or partition boot sector at all. - Make sure to run the grub-install command from the system in which GRUB will be installed as the boot loader. That means if you are booting from the live installation environment, you need to be inside the chroot when running grub-install. If for some reason it is necessary to run grub-install from outside of the installed system, append the --boot-directory= option with the path to the mounted /boot directory, e.g --boot-directory=/mnt/boot.

See UEFI troubleshooting in case of problems. Additionally see GRUB/Tips and tricks#UEFI further reading.

Configuration

On an installed system, GRUB loads the /boot/grub/grub.cfg configuration file each boot. You can follow #Generated grub.cfg for using a tool, or #Custom grub.cfg for a manual creation.

Generated grub.cfg

This section only covers editing the /etc/default/grub configuration file. See GRUB/Tips and tricks for more information.

Note: Remember to always generate the main configuration file after making changes to /etc/default/grub and/or files in /etc/grub.d/.

Generate the main configuration file

After the installation, the main configuration file /boot/grub/grub.cfg needs to be generated. The generation process can be influenced by a variety of options in /etc/default/grub and scripts in /etc/grub.d/.

If you have not done additional configuration, the automatic generation will determine the root filesystem of the system to boot for the configuration file. For that to succeed it is important that the system is either booted or chrooted into.

Note: - The default file path is /boot/grub/grub.cfg, not /boot/grub/i386-pc/grub.cfg. - If you are trying to run grub-mkconfig in a chroot or systemd-nspawn container, you might notice that it does not work: grub-probe: error: failed to get canonical path of /dev/sdaX. In this case, try using arch-chroot as described in the BBS post. - If you are installing GRUB in chroot environment using LVM and the grub-mkconfig hangs indefinitely, see #Device /dev/xxx not initialized in udev database even after waiting 10000000 microseconds.

Use the grub-mkconfig tool to generate /boot/grub/grub.cfg:

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

By default the generation scripts automatically add menu entries for all installed Arch Linux kernels to the generated configuration.

Tip: - After installing or removing a kernel, you just need to re-run the above grub-mkconfig command. - For tips on managing multiple GRUB entries, for example when using both linux and linux-lts kernels, see GRUB/Tips and tricks#Multiple entries.

To automatically add entries for other installed operating systems, see #Detecting other operating systems.

You can add additional custom menu entries by editing /etc/grub.d/40_custom and re-generating /boot/grub/grub.cfg. Or you can create /boot/grub/custom.cfg and add them there. Changes to /boot/grub/custom.cfg do not require re-running grub-mkconfig, since /etc/grub.d/41_custom adds the necessary source statement to the generated configuration file.

Tip: /etc/grub.d/40_custom can be used as a template to create /etc/grub.d/nn_custom, where nn defines the precedence, indicating the order the script is executed. The order scripts are executed determine the placement in the GRUB boot menu. nn should be greater than 06 to ensure necessary scripts are executed first.

See #Boot menu entry examples for custom menu entry examples.

Detecting other operating systems

To have grub-mkconfig search for other installed systems and automatically add them to the menu, install the os-prober package and mount the partitions that contain the other systems. Then re-run grub-mkconfig.

MS Windows

Often, partitions containing Windows will be automatically discovered by os-prober. However, NTFS partitions may not always be detected when mounted with the default Linux drivers. If GRUB is not detecting it, try installing NTFS-3G and remounting.

Encrypted Windows partitions may need to be decrypted before mounting. For BitLocker, this can be done with dislockerAUR. This should be sufficient for os-prober to add the correct entry.

Additional arguments

To pass custom additional arguments to the Linux image, you can set the GRUB_CMDLINE_LINUX + GRUB_CMDLINE_LINUX_DEFAULT variables in /etc/default/grub. The two are appended to each other and passed to kernel when generating regular boot entries. For the recovery boot entry, only GRUB_CMDLINE_LINUX is used in the generation.

It is not necessary to use both, but can be useful. For example, you could use GRUB_CMDLINE_LINUX_DEFAULT="resume=UUID=uuid-of-swap-partition quiet" where uuid-of-swap-partition is the UUID of your swap partition to enable resume after hibernation. This would generate a recovery boot entry without the resume and without quiet suppressing kernel messages during a boot from that menu entry. Though, the other (regular) menu entries would have them as options.

By default grub-mkconfig determines the UUID of the root filesystem for the configuration. To disable this, uncomment GRUB_DISABLE_LINUX_UUID=true.

For generating the GRUB recovery entry you have to ensure that GRUB_DISABLE_RECOVERY is not set to true in /etc/default/grub.

See Kernel parameters for more info.

11. Reboot

Exit the chroot environment by typing exit or pressing Ctrl+d.

Optionally manually unmount all the partitions with umount -R /mnt: this allows noticing any "busy" partitions, and finding the cause with fuser(1).

Finally, restart the machine by typing reboot: any partitions still mounted will be automatically unmounted by systemd. Remember to remove the installation medium and then login into the new system with the root account.

Post-Installation

Now you are booted into your freshly made Arch installation. You can login with root and the password you have set. Now we finish up the isntallation.

12. Enable NetworkManager

After installation, you should start/enable NetworkManager.service. Once the NetworkManager daemon is started, it will automatically connect to any available "system connections" that have already been configured. Any "user connections" or unconfigured connections will need nmcli or an applet to configure and connect.

systemctl enable NetworkManager
systemctl start NetworkManager

You can check that the Network manager is runnnign by typing this:

systemctl status NetworkManager

13. Add user

To add a new user named archie, creating its home directory and otherwise using all the defaults in terms of groups, folder names, shell used and various other parameters:

useradd -m archie

Tip: The default value used for the login shell of the new account can be displayed using useradd --defaults. The default is Bash, a different shell can be specified with the -s/--shell option; see /etc/shells for valid login shells.

Although it is not required to protect the newly created user archie with a password, it is highly recommended to do so:

passwd archie