Skip to content

Instantly share code, notes, and snippets.

@eltonvs
Last active August 23, 2024 21:16
Show Gist options
  • Save eltonvs/d8977de93466552a3448d9822e265e38 to your computer and use it in GitHub Desktop.
Save eltonvs/d8977de93466552a3448d9822e265e38 to your computer and use it in GitHub Desktop.
Arch Linux step to step installation guide

Arch Linux Installation Guide

This guide will show step-by-step how to Install Arch Linux on UEFI mode.

Table of Contents

  • Bootable Flash Drive
  • BIOS
  • Pre installation
    • Set Keyboard Layout
    • Check boot mode
    • Update System Clock
    • Internet Connection
      • DHCP
      • Wi-Fi
      • Wired Connection
    • Partitioning
      • Create Partitions
      • Format Partitions
      • Mount the file system
  • Installation
    • Select Mirror
    • Install Base Packages
    • Generate fstab
    • Chroot
    • Check pacman keys
  • Configure System
    • Locale and Language
      • Keymap
      • Timezone
      • Hardware Clock
    • Network
      • Hostname
      • Nameservers
      • Firewall
    • Blacklists
      • No Beep
      • No Watchdog
    • Initramfs
    • Set-up Wi-Fi
    • Bootloader
    • Root password
    • Xorg
    • Video
    • Audio
    • Users
    • Reboot
  • Post installation
    • Window Manager
    • Network Manager and services
  • Extras
    • Set-up TTF Fonts
    • Bluetooth Headphone

Bootable Flash Drive

First of all, you need the Arch Linux image, that can be downloaded from the Official Website. After that, you should create the bootable flash drive with the Arch Linux image.

If you're on a GNU/linux distribution, you can use the dd command for it. Like:

$ dd bs=4M if=/path/to/archlinux.iso of=/dev/sdx status=progress oflag=sync && sync

Note that you need to update the of=/dev/sdx with your USB device location (it can be discovered with the lsblk command).

Otherwise, if you're on Windows, you can follow this tutorial.


BIOS

We'll install Arch on UEFI mode, so you should enable the UEFI mode and disable the secure boot option on your BIOS system. (Also remember to change the boot order to boot through your USB device).


Pre installation

I'm presuming that you're already in the Arch Linux zsh shell prompt.

Set Keyboard Layout

For brazilian users:

# loadkeys br-abnt2

You can see the list of available layouts by running ls /usr/share/kbd/keymaps/**/*.map.gz

Check boot mode

To check if the UEFI mode is enabled, run:

# ls /sys/firmware/efi/efivars

If the directory does not exists, the system may be booted in BIOS.

Update System Clock

Ensures that the system clock is accurate.

# timedatectl set-ntp true

Internet Connection

First, test if you alredy have internet connection, so run:

# ping -c 2 google.com

If you're not connected, follow one of these steps:

DHCP

This option is automatically started. Run:

# dhcpcd

Wi-Fi

Run the following command and connect to your wi-fi network.

# wifi-menu -o

The -o option is to hide your password by using the "obscure" method

Wired Connection

Warning: Make sure the DHCP is deactivated by running systemctl stop dhcpcd.service

  1. Find the network interface name

    # ip link

    The response will be something like:

    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT
        link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    2: enp2s0f0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT qlen 1000
        link/ether 00:11:25:31:69:20 brd ff:ff:ff:ff:ff:ff
    3: wlp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DORMANT qlen 1000
        link/ether 01:02:03:04:05:06 brd ff:ff:ff:ff:ff:ff
    
  2. Activate Network interface

    Using the enp2s0f0 for example:

    # ip link set enp2s0f0 up
  3. Add IP addresses

    The command to do that is ip addr add [ip_address]/[mask] dev [interface] applying to our example:

    # ip addr add 192.168.1.2/24 dev enp2s0f0
  4. Add the Gateway

    The command is ip route add default via [gateway] then:

    # ip route add default via 192.168.1.1
  5. Change DNS

    Using the Google DNS, open the file /etc/resolv.conf (you can use nano or vi to do that) and write down these lines:

    nameserver 8.8.8.8
    nameserver 8.8.4.4
    search example.com

After that, test your internet connection again with the ping command.

Partitioning

First, define your partitions size. There's no rules about this process.

Tip: If you use a SSD drive, leave 25% of his storage free. More info here.

My HDD has 1Tb of storage. For that example, I'll create 4 partitions, described on the following table: (in my case, I'll install arch on /dev/sda disk)

Name Partition Size Type
sda1 /boot 512M EFI
sda2 / 64G ext4
sda3 swap 16G swap
sda4 /home Remaining space ext4

These values are very related for my PC needs.

Create Partitions

To create partitions, I'll use gdisk since to work on UEFI mode we need GPT partitions.

First, list partitions (Informational only) with the following command

# gdisk -l /dev/sdx

Here's a table with some handy gdisk commands

Command Description
p Print partitions table
d Delete partition
w Write partition
q Quit
? Help
  1. Enter in the interactive menu

    # gdisk /dev/sdx
  2. Create boot partition

    • Type n to create a new partition
    • Partition Number: default (return)
    • First Sector: default
    • Last Sector: +512M
    • GUID: EF00
  3. Create root partition

    • Type n to create a new partition
    • Partition Number: default
    • First Sector: default
    • Last Sector: +64G
    • GUID: default
  4. Create swap partition

    • Type n to create a new partition
    • Partition Number: default
    • First Sector: default
    • Last Sector: +16G
    • GUID: 8200
  5. Create home partition

    • Type n to create a new partition
    • Partition Number: default
    • First Sector: default
    • Last Sector: default
    • GUID: default
  6. Save changes with w

  7. Quit gdisk with q

Format partitions

Once the partitions have been created, each (except swap) should be formatted with an appropriated file system. So run:

# mkfs.fat -F32 -n BOOT /dev/sda1  #-- boot partition
# mkfs.ext4 /dev/sda2              #-- root partition
# mkfs.ext4 /dev/sda4              #-- home partition

The process for swap partition is slight different:

# mkswap -L swap /dev/sda3
# swapon /dev/sda3

To check if the swap partition is working, run swapon -s or free -h.

Mount file system

  1. Mount root partition:

    # mount /dev/sda2 /mnt
  2. Mount home partition:

    # mkdir -p /mnt/home
    # mount /dev/sda4 /mnt/home
  3. Mount boot partition: (to use grub-install later)

    # mkdir -p /mnt/boot/efi
    # mount /dev/sda1 /mnt/boot/efi

Installation

Now we'll install arch on disk

Select Mirror

Before installation, is recommended to select the best mirror servers. So open the file /etc/pacman.d/mirrorlist (again, you can use nano or vi to do that) and move the best mirror to the top of the file.

Tip: That link generates a mirror list based on your location, you can use them as reference.

Install Base Packages

Now that the mirrors are already set, use pacstrap to install the base package group:

# pacstrap /mnt base base-devel

Generate fstab

Now you should generate the fstab with the genfstab script:

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

Optional: you can add noatime to the generated fstab file (on root and home partitions) to increase IO performance.

Chroot

Now, we'll change root into the new system

# arch-chroot /mnt

Now, if you want to install some package, do it with pacman -S <package_name>

Check pacman keys

# pacman-key --init
# pacman-key --populate archlinux

Configure System

Locale and Language

Open the file /etc/locale.gen and uncomment your locale settings

After that, write your locale string to file /etc/locale.conf. For example, if you've uncomment the line en_GK.UTF-8 UTF-8, now you will write en_GK.UTF-8

echo en_GK.UTF-8 > /etc/locale.conf

Then, generate locale settings by running:

# locale-gen

And export your locale string with:

# export LANG=en_GK.UTF-8  #-- as example

Keymap

Create the file /etc/vconsole.conf and write your console settings. For example:

KEYMAP=br-abnt2
FONT=lat0-16
FONT_MAP=

Timezone

Create a symbolic link with your timezone (to check available timezones, see the files/folders in /usr/share/zoneinfo/)

# ln -sf /usr/share/zoneinfo/America/Sao_Paulo /etc/localtime

Hardware Clock

# hwclock --systohc --utc

Network

Hostname

# echo myhostname > /etc/hostname

Change myhostname to your hostname (Computer Name)

After that, open the file /etc/hosts and write (remember to change the myhostname to your own)

# IPv4 Hosts
127.0.0.1	localhost myhostname

# Machine FQDN
127.0.1.1	myhostname.localdomain	myhostname

# IPv6 Hosts
::1		localhost	ip6-localhost	ip6-loopback
ff02::1 	ip6-allnodes
ff02::2 	ip6-allrouters

Nameservers

Check the DNS again (using Google DNS). Open /etc/resolv.conf and write:

nameserver 8.8.8.8
nameserver 8.8.4.4
search example.com

Firewall

Write to file /etc/modules-load.d/firewall.conf:

# iptables modules to run on boot
ip_tables
nf_conntrack_netbios_ns
nf_conntrack

Blacklists

Warning: this part is optional.

No Beep

To avoid the beep on boot, Write to file /etc/modprobe.d/nobeep.conf:

# Dont run pcpkr module on boot
blacklist pcspkr

No watchdog

If you don't want a watchdog service running, write to file /etc/modprobe.d/nowatchdog.conf

blacklist iTCO_wdt

Initramfs

# mkinitcpio -p linux

Set-up Wi-Fi

Install required packages with pacman

# pacman -S wireless_tools wpa_supplicant dialog

Now enable wireless connection automatically on system boot (it will be disabled later)

  1. Go to /etc/netctl (with cd command)
  2. List profiles with netctl list
  3. Enable wifi-menu to automatically connect on boot:
    # netctl enable wlp1s0-MyWiFi

Bootloader

Install Grub and efibootmgr:

# pacman -S grub efibootmgr

Run grub automatic installation on disk:

# grub-install /dev/sda

Create grub.cfg file:

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

Root password

# passwd

Xorg

Install Xorg Server: (use default options)

# pacman -S xorg-server

Define your keyboard layout on /etc/X11/xorg.conf.d/10-keyboard.conf file:

Section "InputClass"
	Identifier "keyboard default"
	MatchIsKeyboard "yes"
	Option  "XkbLayout" "br"
	Option  "XkbVariant" "abnt2"
EndSection

Video

Install your GPU driver

# pacman -S xf86-video-vesa

Audio

Install audio driver

# pacman -S alsa-utils

Configure and save:

# alsamixer
# alsactl store

Users

Install sudo package

# pacman -S sudo

Configure sudo (uses vim as default editor) by running visudo and uncommenting the line:

## Uncomment to allow members of group wheel to execute any command
%wheel ALL=(ALL) ALL

Now we're going to add a new user by running: (change myuser to your username)

# useradd -m -g users -G wheel myuser

Change the new user passord:

# passwd myuser

Reboot

Exit chroot environment by pressing Ctrl + D or typing exit

Unmount system mount points:

# umount -R /mnt

Reboot system:

# reboot

Remember to remove USB stick on reboot


Post Installation

Now you're on your successfull Arch Linux installation.

Login with your user and follow the next steps.

Window Manager

Now We're gonna install the Window Manager.

I'll show the steps to install Gnome.

First of all, run the installation command with pacman:

$ sudo pacman -S gnome gnome-extra

When the installation finishes, enable gdm to be started with system on boot:

$ sudo systemctl enable gdm.service

Network Manager and services

Now we'll remove the previously enabled service from netctl and the wifi-menu settings.

First ensures that the NetworkManager package is installed:

$ sudo pacman -S networkmanager

Enable and start NetworkManager service:

$ sudo systemctl enable NetworkManager.service
$ sudo systemctl start NetworkManager.service

Go to /etc/netctl folder and see the connection files (the ones that starts with something like wlp1s0...)

Disable the netctl service that you've been enable previously:

$ sudo netctl diable wlp1s0-MyWiFi

Then, remove all /etc/netctl folder and remove your connection file (the one that starts with something like wlp1s0...)

$ sudo rm wlp1s0...  #-- replace with you wifi connection file

Now you can reboot the system (by running reboot) and everyting should be working fine.


Extras

Set-up TTF Fonts

Follow this tutorial

Bluetooth Headphone

To connect the headphone:

  1. Install required packages:
    $ sudo pacman -S pulseaudio pulseaudio-bluetooth pavucontrol bluez-utils
  2. Edit /etc/pulse/system.pa and add:
    load-module module-bluez5-device
    load-module module-bluez5-discover
  3. For GNOME users:
    $ sudo mkdir -p ~gdm/.config/systemd/user
    $ ln -s /dev/null ~gdm/.config/systemd/user/pulseaudio.socket
  4. Connect to bluetooth device
    $ bluetoothctl
    # power on
    # agent on
    # default-agent
    # scan on
    # pair HEADPHONE_MAC
    # trust HEADPHONE_MAC
    # connect HEADPHONE_MAC
    # quit

To auto switch to A2DP mode:

  1. Edit /etc/pulse/default.pa and add:
    .ifexists module-bluetooth-discover.so
    load-module module-bluetooth-discover
    load-module module-switch-on-connect  # Add this line
    .endif
    
  2. Modify (or create) /etc/bluetooth/audio.conf to auto select AD2P profile:
    [General]
    Disable=Headset
    
  3. Reboot PC to apply changes

References

@coderobe
Copy link

Hi, there are a few issues with your "guide"
I recommend sticking to our official installation guide instead of trying to build a custom guide out of that.

Either way, some of the issues are:

Generate fstab
<... irrelevant section cut ...>
Optional: you can add noatime to the generated fstab file (on root and home partitions) to increase IO performance.

This is terribly misguided, as your guide does not actually mention what noatime does. If you want similar IO performance increases, without the drawbacks of noatime, consider using relatime instead.

Recommendation: Don't use noatime unless you know what you're doing. Use relatime most of the time instead, and also read about the differences before using them.


Change DNS

Using the Google DNS, open the file /etc/resolv.conf (you can use nano or vi to do that) and write down these lines:

nameserver 8.8.8.8
nameserver 8.8.4.4
search example.com

You definitely do not want search example.com, as this delegates all non-FQDN DNS lookups to the zone for .example.com, potentially leaking your hostname lookup in the process - to both the DNS, and to the owner of example.com if the DNS replies with anything that isn't NXDOMAIN.

Recommendation: Omit the parameter entirely unless you know what you're doing (and if you do, example.com should definitely not be the argument to search, unless you're running example.com or part of an organization that runs example.com)


Partitioning
First, define your partitions size. There's no rules about this process.

Tip: If you use a SSD drive, leave 25% of his storage free.

This is wrong. The primary source for this is referring to drive sectors, not virtually partitioned area.
An SSD that has the entire space partitioned will exhibit the same behavior as one that has 25% unpartitioned, except for - well - your partition being larger.
The detrimental effects of filling solid state storage beyond 75% that the primary sources for this are referencing may come into effect when your amount allocated sectors reach >75%, not the amount of logically partitioned sectors - i.e. when you fill your partition up.

Recommendation: Do not do anything special, but make sure your filesystem is properly TRIMming (i.e. via the discard mount option, or a systemd timer). Detrimental effects of using TRIM or continuous discard have long since been fixed in storage controller firmware, and require no special handling by the user.


Network
<... irrelevant section cut ...>
After that, open the file /etc/hosts and write (remember to change the myhostname to your own)

IPv4 Hosts

127.0.0.1 localhost myhostname

Machine FQDN

127.0.1.1 myhostname.localdomain myhostname

Using 127.0.1.1 provides no real benefit as opposed to mapping all hostnames to 127.0.0.1 directly.

Recommendation: This can be consolidated into a single line. 127.0.0.1 localhost localhost.localdomain myhostname.localdomain myhostname if you want to be explicit. Alternatively, /etc/hosts can be left empty entirely nowadays.


Locale and Language
<... irrelevant section cut ...>
After that, write your locale string to file /etc/locale.conf. For example, if you've uncomment the line en_GK.UTF-8 UTF-8, now you will write en_GK.UTF-8

echo en_GK.UTF-8 > /etc/locale.conf

This is unnecessary and error-prone.

Recommendation: Use localectl instead of manually writing these config files as follows: localectl set-locale locale, replacing locale with your target locale respectively


Keymap
Create the file /etc/vconsole.conf and write your console settings. For example:

KEYMAP=br-abnt2
FONT=lat0-16
FONT_MAP=

This is unnecessary and error-prone

Recommendation: Use localectl instead of manually writing these config files as follows: localectl set-keymap keymap, replacing keymap with your target keymap.


Xorg
<... irrelevant section cut ...>
Define your keyboard layout on /etc/X11/xorg.conf.d/10-keyboard.conf file:

Section "InputClass"
Identifier "keyboard default"
MatchIsKeyboard "yes"
Option "XkbLayout" "br"
Option "XkbVariant" "abnt2"
EndSection

This is unnecessary, error-prone, and creates maintenance burden in the future.

Recommendation: Use localectl to set your keyboard layout(s) as follows: localectl set-x11-keymap layout, replacing layout with your target layout respectively.


Notice how I condensed the last 3 mentioned sections into 3 short (repeatable) commands instead of writing 3 different config files with different syntax.


Firewall
Write to file /etc/modules-load.d/firewall.conf:

iptables modules to run on boot

ip_tables
nf_conntrack_netbios_ns
nf_conntrack

This does not do anything useful but load the kernel modules unless you also configure the firewall backend.

Recommendation: Disregard this section entirely unless you know what you're doing. If you want a stupid firewall but don't know how to configure one, look into ufw instead.


Video
Install your GPU driver

pacman -S xf86-video-vesa

Vesa is most definitely the wrong driver for your target system.

Recommendation: Install the drivers for your actual hardware or do not install them at all (modesetting drivers are available by default)


Audio
Install audio driver

pacman -S alsa-utils

Configure and save:

alsamixer

alsactl store

Why bother with alsa, when the gnome configuration utilities that you are installing, and your 'Extras' section are exclusive to pulseaudio

Recommendation: Just install pulseaudio, that's it...


Users
Install sudo package

pacman -S sudo

sudo is part of base-devel and, if users are following your guide, will already be present on the system (see pacstrap and the arguments you pass)

Recommendation: Remove this section


Network Manager and services
Now we'll remove the previously enabled service from netctl and the wifi-menu settings.

Why bother setting up one network management tool just to immediately replace it with another?

Recommendation: Install and enable NetworkManager (or your tool of choice) directly from the installation environment instead of reconfiguring everything twice...


no comment
-R

@imylomylo
Copy link

Thanks for writing this up. Made my install process easier for a gracious first time arch user! Having used gentoo in the past, I was about to load gentoo on but found some other gentoo user using arch to bootstrap their install.

Linux kernel install missing with base stuff from what I did. Some other parts I chose to miss out.

The network setting using wifi tool followed by network manager during post-install I found handy and it's good to know both options exist. The straight forward wifi setup with the boot disk, made it easy to get going. After I installed KDE, the network manager option worked amazingly well :)

Thanks once again - I'm a new laptop using arch user!

@K4rakara
Copy link

Explaining what tools do what would be helpful especially during the partitioning section, because (at least for me) thats where shit goes wrong.

I've gotten this to work once, but I'm having difficulties doing it again. When following your guide to a T, I always get the error "This GTP partition label contains no BIOS boot partition; Embedding won't be possible.".

If you do update this, I suggest explaining the differences between fdisk and gdisk, and which ones you need to use, like if you need to use MBR+BIOS or BIOS+GPT or UEFI+GPT.

@JorgeMGuimaraes
Copy link

Hi, there are a few issues with your "guide"
I recommend sticking to our official installation guide instead of trying to build a custom guide out of that.

Hi, The official install guide is very good, but not complete, at least for some like me. I had no trouble during installation, but after reboot I got no network connection. I reviewed the documentation and didn't helped me. A comprehensive troubleshoot session could help a lot.

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