Skip to content

arch linux for dummies

Jiéverson edited this page Sep 21, 2016 · 12 revisions

Welcome to arch linux for dummies. I hope this tutorial can help new folks (like me) getting things working.

Note: This tutorial is based on Arch Linux Beginners' Guide. But I will try to make things easier for you dummies.

Arch

A basic installation with all base packages should take less than 800 MB of disk space. The last arch linux version can be downloaded at archlinux.org/download (BitTorrent download recommended). The image can be burned to a CD, mounted as an ISO file, or be directly written to a USB stick using a utility like dd (Win32DiskImager on Windows). If arch is been installed in a virtual machine (like VirtualBox), just create your disc, and start it from the ISO file. The ISO image supports both 32bit and 64bit systems.

After booting into the installation media, you will be automatically logged in as the root user and presented with a zsh shell prompt. For modifying or creating configuration files, nano will be used. Fell free to use vim in case you have experience with it.

UEFI mode

This tutorial will consider that you have a UEFI motherboard with UEFI mode enabled. To verify you are booted in UEFI mode, check that the following directory is populated:

# ls /sys/firmware/efi/efivars

Note: If arch is been installed in a VM, remember to change the motherboard settings to support UEFI/efivars.

Preparation

Make sure your internet connection is working (it probably should):

# ping google.com

If no connection is available, see Network configuration. You can also use the wifi-menu command to connect to WiFi.

Make sure your system clock is accurate:

# timedatectl set-ntp true
# timedatectl status

Partitioning

This section is based on Partitioning, GPT, GNU Parted, EFI and Swap. Identify the devices where the new system will be installed:

# lsblk

!Note: In this section, the "sdxy" notation will be used, where x represents device and y represents partition (eg. sda1, sda2, sdb1, etc...).

Let's start partitioning our device (eg. sda, sdb, etc...):

# parted /dev/sdx

If you run a print, you will see the partition label is not defined. Let's set the partition label to gpt:

(parted) mklabel gpt

If you print again, you will now be able to see an empty partition table. In this tutorial, we are going to create a basic gpt with 3 partitions (first for boot, second for swap, and third for our data). The boot partition can have a size between 260Mb and 512Mb. The swap partition needs to have at least your RAM size (it's recomemnded to have 2x RAM size). The remaning space is going to be allocated to your data. Let's format:

(parted) mkpart ESP fat32 1MiB 513MiB
(parted) set 1 boot on
(parted) mkpart primary linux-swap 513M 3G
(parted) mkpart primary ext4 3G 100%

You can print again to check if your partition table is ok. Exit from parted with:

(parted) quit

Formatting

You need to format each of your partitions, except for swap. All available partitions on device can be listed with the following command:

# lsblk /dev/sdx

Format the boot partition to fat32:

# mkfs.fat -F32 /dev/sdx1

Set up swap partition:

# mkswap /dev/sdx2
# swapon /dev/sdx2

Then, format your data partition:

# mkfs.ext4 /dev/sdx3

If you want, you can check your partitions with lsblk again.

Mount the partitions

Mount the root partition to the /mnt directory of the live system:

# mount /dev/sdx3 /mnt

Now, mount the boot partition:

# mkdir /mnt/boot
# mount /dev/sdx1 /mnt/boot

Installation

Execute the pacstrap script to install base packages:

# pacstrap /mnt

Generate an fstab file, to define how disk partitions should be mounted into the filesystem:

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

The next installation steps needs to be running from a bash inside the new system, so change root to the new system:

# arch-chroot /mnt /bin/bash

Edit the location file with nano (or vi, if you want):

# nano /etc/locale.gen

Uncomment en_US.UTF-8 UTF-8 in /etc/locale.gen, save and quit the file, and generate new location:

# locale-gen

Now set system locale:

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

Select a time zone:

# tzselect

Go to /usr/share/zoneinfo and find your Zone:

# cd /usr/share/zoneinfo
# ls

Go to your zone folder, and find your Subzone:

# cd MY_ZONE
# ls

Create the symbolic link /etc/localtime, to your Zone and Subzone:

ln -s /usr/share/zoneinfo/MY_ZONE/MY_SUBZONE /etc/localtime

It is recommended to adjust the time skew, and set the time standard to UTC:

# hwclock --systohc --utc

Boot loader

Install the packages grub and efibootmgr:

# pacman -S grub efibootmgr

The following steps install the GRUB UEFI application to /boot/EFI/grub, install its modules to /boot/grub/x86_64-efi, and place the bootable grubx64.efi stub in /boot/EFI/grub:

# grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=grub

UEFI firmware workaround: Some UEFI firmware requires that the bootable .efi stub have a specific name and be placed in a specific location: /boot/EFI/boot/bootx64.efi:

# mkdir /boot/EFI/boot
# cp /boot/EFI/grub/grubx64.efi /boot/EFI/boot/bootx64.efi

If you have an Intel CPU, in addition to installing a boot loader, install the intel-ucode package:

# pacman -S intel-ucode

After installing the intel-ucode package, regenerate the GRUB config to activate loading the microcode update:

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

Network configuration

Set the hostname by adding an entry to /etc/hostname, where MY_HOSTNAME is the desired host name:

# echo MY_HOSTNAME > /etc/hostname

old way [deprecated]

Run ip link to find your ethernet interface name (it should starts with en, eg. enp0s25).

# ip link

When only requiring a single wired connection, enable the dhcpcd service, where MY_EN is your ethernet interface:

# systemctl enable dhcpcd@MY_EN.service

For wireless, install the iw, wpa_supplicant and dialog packages:

# pacman -S iw wpa_supplicant dialog

Additional firmware packages may also be required. See Wireless Management for other available methods.

better way

# pacman -S networkmanager
# systemctl enable NetworkManager.service
# nmtui-connect

Change root password and reboot

Set the root password with:

# passwd

Exit from the chroot environment:

# exit

Reboot into the new system:

# reboot

Note: Remember to remove the CD (or ISO in case of VM)

After reboot, log in using the user root.

User management

Install the package sudo:

# pacman -S sudo

Create an user for you, where MY_USERNAME is your username:

# useradd -m -G wheel MY_USERNAME
# passwd MY_USERNAME

To grant your user's group sudo access, run visudo and uncomment the required line.

# export EDITOR=nano && visudo

Logout as root, and start using your new user.

# logout

Install shell: zsh

For this tutorial, I will be using zsh as my users shell (Feel free to choose a different one)

# sudo pacman -S zsh
# chsh -s /bin/zsh
# logout

When you login again, zsh will be running, and you will be asked for a few configurations (you can actually skip it).

Install various common packages

From here you can install your common packages. I will just install some of mine:

$ sudo pacman -S gcc make wget tar tmux

Install X

Xorg is the most popular display server among Linux users. Xorg can be installed with the xorg-server package. Additionally, you can install this packages too: xorg-server-utils and xorg-apps.

$ sudo pacman -S xorg-server xorg-server-utils

Driver installation

First, identify your card:

$ lspci | grep -e VGA -e 3D

Then install an appropriate driver. You can search the package database for a complete list of open-source video drivers:

$ pacman -Ss xf86-video

VirtualBox Settings

Skip this if arch is not installed in a VM.

$ sudo pacman -S virtualbox-guest-utils
$ sudo modprobe -a vboxguest vboxsf vboxvideo

Window Manager: BSPWM

bspwm is a tiling window manager. Install bspwm, sxhkd, xorg-xinit and a terminal emulator (like rxvt-unicode):

$ sudo pacman -S bspwm sxhkd xorg-xinit rxvt-unicode

We will be getting default config files from the Github.

$ mkdir ~/.config
$ echo export XDG_CONFIG_HOME="$HOME/.config" >> ~/.zshrc
$ mkdir ~/.config/bspwm
$ cp /usr/share/doc/bspwm/examples/bspwmrc ~/.config/bspwm/
$ mkdir ~/.config/sxhkd
$ cp /usr/share/doc/bspwm/examples/sxhkdrc ~/.config/sxhkd/
$ chmod +x ~/.config/bspwm/bspwmrc

Look at ~/.config/sxhkd/sxhkdrc and learn the key bindings. To start bspwm on login, add the following to ~/.xinitrc

exec bspwm