ARCH LINUX INSTALL DEMYSTIFIED

Arch Linux is a sleek and nimble, super lightweight (it makes even CentOS minimal look bloated) Linux distribution that is wonderfully fast and constantly evolving.

On July, 22 2012 Arch Linux dropped AIF (Arch Installation Framework), It’s installer GUI, and replaced it with a command line based: Arch Install Scripts. It took me quite a few attempts to get a working system installed, but with the help of a few YouTube videos and closely reading the install guide, I learned the caveats of a successful install.

Prerequisites:

  • The Arch Linux install image, get the dual install, It comes with 32 and 64 bit on the same image. At the time of this article archlinux-2012.10.06-dual.iso is available: Arch Linux Downloads
  • Virtual machine, computer, or laptop (runs great on older laptops too) that you want to install Arch Linux on
  • Ethernet connection

This article WILL cover:

  • Partitioning for GPT (GUID Partition Table)
  • Installing Syslinux boot loader
  • Static and DHCP networking
  • Basic overview of systemd (initscripts replacement)

This article will NOT cover:

  • Wireless, there are just too many different chips
  • Partitioning MBR (Master Boot Record)
  • Dual-booting Windows or any other OS
  • Installation of GRUB
  • Installing from USB

Alright, let’s get started. Prepare your virtual machine and load the installer image or burn a CD with the image.

I’m going to be using VirtualBox: 1024MB RAM, 60GB virtual hard drive, 1 CPU, Network: Bridged Adapter.

In the Arch Linux boot menu you can choose to install x86_64 (64-bit) or i686 (32-bit), I will be choosing x86_64.

Step 1

Verifying internet connection

First of all, let’s check if we have an IP address. The command ‘ip addr’ will show us the network devices and assigned addresses. Very similar to ‘ifconfig’. By default the Arch install enables the eth0 device and it’s configured for DHCP. For the install we will be using DHCP, but I will be showing you how to assign a static IP after the install. If for some reason you need to install via static IP go here first.

root@archiso ~ # ip addr
1: lo:  mtu 16436 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0:  mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 08:00:27:3c:8e:69 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.141/24 brd 192.168.1.255 scope global eth0
    inet6 fe80::a00:27ff:fe3c:8e69/64 scope link
       valid_lft forever preferred_lft forever

And just to make sure, give a ping over to google.com.

root@archiso ~ # ping -c 3 google.com
PING google.com (74.125.224.201) 56(84) bytes of data.
64 bytes from lax02s02-in-f9.1e100.net (74.125.224.201): icmp_req=1 ttl=55 time=22.7 ms
64 bytes from lax02s02-in-f9.1e100.net (74.125.224.201): icmp_req=2 ttl=55 time=22.5 ms
64 bytes from lax02s02-in-f9.1e100.net (74.125.224.201): icmp_req=3 ttl=55 time=23.1 ms

--- google.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2004ms
rtt min/avg/max/mdev = 22.501/22.808/23.154/0.294 ms

Optional Step: If you want to install over SSH for the ease of copy\paste, we can do that by setting a root password and enabling the SSH service.

root@archiso ~ # passwd
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
root@archiso ~ # systemctl start sshd.service
root@archiso ~ #

Step 2

Creating Partitions

If this is not a brand new virtual machine or if you have data you do not want lose, make sure It’s already backed up.

We are going to be creating a basic 4 partition scheme for the new system:

  • Boot /boot 100MB
  • Linux Swap 2GB
  • Root / 20GB
  • Home /home (remaining space)

The boot partition does not need to be very big at all, 100MB will do just fine. The general rule for Linux Swap is ( 2 * RAM ), though on systems with a large amount of RAM this may not apply and may be possible to not have a Swap at all. For the simplicity of this guide we will follow the general rule.
The root will house installed packages and the base system. Home is where user files such as downloads and personal files. If this system is going to be used in a desktop environment, devote a large amount of space to this.

In the command line use: gdisk /dev/sda

With gdisk (partition tool for GPT) we will only be using 3 commands:
p – print the partition table
n – add a new partition
w – write table to disk and exit

root@archiso ~ # gdisk /dev/sda
GPT fdisk (gdisk) version 0.8.5

Partition table scan:
  MBR: not present
  BSD: not present
  APM: not present
  GPT: not present

Creating new GPT entries.

This here will show us the partition and space we have. No partitions yet, so let’s make some.

Command (? for help): p
Disk /dev/sda: 125829120 sectors, 60.0 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 28BA9C68-3CD9-436A-AC7E-471DA7CA1437
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 125829086
Partitions will be aligned on 2048-sector boundaries
Total free space is 125829053 sectors (60.0 GiB)

Number  Start (sector)    End (sector)  Size       Code  Name

First off, we create our first partition, /boot on sda1. The way we use these commands will not vary that much so after we type ‘n’ we skip through the first 2 question thus taking the defaults:
Partition number and First Sector.
Last sector, will is were the size of the partition is entered. use ‘+<Size><Unit (M or G)>’. You will see what I mean.
Hex code or GUID, will, for what we are doing, will be 8300 (Linux filesystem) default, or 8200 (Linux swap).

Command (? for help): n
Partition number (1-128, default 1):
First sector (34-125829086, default = 2048) or {+-}size{KMGTP}:
Last sector (2048-125829086, default = 125829086) or {+-}size{KMGTP}: +150M
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300):
Changed type of partition to 'Linux filesystem'

One down. Next we make our Swap, be sure to put 8200 for the Hex Code question.

Command (? for help): n
Partition number (2-128, default 2):
First sector (34-125829086, default = 309248) or {+-}size{KMGTP}:
Last sector (309248-125829086, default = 125829086) or {+-}size{KMGTP}: +2G
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): 8200
Changed type of partition to 'Linux swap'

Easy enough. Make the root partition.

Command (? for help): n
Partition number (3-128, default 3):
First sector (34-125829086, default = 4503552) or {+-}size{KMGTP}:
Last sector (4503552-125829086, default = 125829086) or {+-}size{KMGTP}: +20G
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300):
Changed type of partition to 'Linux filesystem'

Last partition were can dump the remaining space is for home. Don’t enter in anything, take all the defaults.

Command (? for help): n
Partition number (4-128, default 4):
First sector (34-125829086, default = 46446592) or {+-}size{KMGTP}:
Last sector (46446592-125829086, default = 125829086) or {+-}size{KMGTP}:
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300):
Changed type of partition to 'Linux filesystem'

We can check what we have created before we write.

Command (? for help): p
Disk /dev/sda: 125829120 sectors, 60.0 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 28BA9C68-3CD9-436A-AC7E-471DA7CA1437
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 125829086
Partitions will be aligned on 2048-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048          309247   150.0 MiB   8300  Linux filesystem
   2          309248         4503551   2.0 GiB     8200  Linux swap
   3         4503552        46446591   20.0 GiB    8300  Linux filesystem
   4        46446592       125829086   37.9 GiB    8300  Linux filesystem

If everything looks good, write it.

Command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/sda.
The operation has completed successfully.

Alright, we have our partitions, now we need to format them. There are many different file systems Arch supports, but we going to use ext4 for this guide.

Use the command ‘mkfs.ext4’. We will start with sda1 (boot /boot).

root@archiso ~ # mkfs.ext4 /dev/sda1
mke2fs 1.42.5 (29-Jul-2012)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
38456 inodes, 153600 blocks
7680 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67371008
19 block groups
8192 blocks per group, 8192 fragments per group
2024 inodes per group
Superblock backups stored on blocks:
        8193, 24577, 40961, 57345, 73729

Allocating group tables: done
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done

Do the same with sda3 (root /) and sda4 (home /home).

root@archiso ~ # mkfs.ext4 /dev/sda3
root@archiso ~ # mkfs.ext4 /dev/sda4

For Swap, use ‘mkswap ‘. Then turn it on ‘swapon ‘.

root@archiso ~ # mkswap /dev/sda2
Setting up swapspace version 1, size = 2097148 KiB
no label, UUID=a2c595e2-4a8b-499c-a960-76d09f0e0f37

root@archiso ~ # swapon /dev/sda2

Step 3

Mounting Partitions and Installing System

Let’s mount the partitions, create directories for ‘boot’ and ‘home’.

root@archiso ~ # mount /dev/sda3 /mnt
root@archiso ~ # cd /mnt
root@archiso /mnt # mkdir boot home
root@archiso /mnt # mount /dev/sda1 boot
root@archiso /mnt # mount /dev/sda4 home

Now on to installing the system with the ‘pacstrap’ tool. We are going to be installing the ‘base’ system package and the ‘base-devel’. The ‘base-devel’ includes compiling tools needed for building from source.

root@archiso /mnt # pacstrap /mnt base base-devel
==> Creating install root at /mnt
==> Installing packages to /mnt
warning: database file for 'core' does not exist
warning: database file for 'extra' does not exist
warning: database file for 'community' does not exist
:: Synchronizing package databases...

This may take a few minutes to finish downloading and installing.

Before we configure the our new system we need to generate the ‘fstab’ file.

root@archiso /mnt # genfstab -p /mnt >> /mnt/etc/fstab

Take a minute to check over the ‘fstab’ file.

root@archiso /mnt # nano /mnt/etc/fstab

the Arch Linux Wiki tells us that the last field for / (root) should end in a 1 and ‘data=ordered’ should be removed. I will paste in my ‘fstab’ for reference.

#
# /etc/fstab: static file system information
#
#                
tmpfs           /tmp    tmpfs   nodev,nosuid    0       0
# UUID=a917c9a7-4fa9-4c05-951b-41f342c081df
/dev/sda3               /               ext4            rw,relatime     0 1

# UUID=e5c3a393-2bd9-4900-ab2d-e4edbc4e2fb5
/dev/sda1               /boot           ext4            rw,relatime     0 2

# UUID=00ebefd0-f831-4bea-9f27-5e7860221f42
/dev/sda4               /home           ext4            rw,relatime     0 2

# UUID=a2c595e2-4a8b-499c-a960-76d09f0e0f37
/dev/sda2               none            swap            defaults        0 0

Ctrl-X to exit, yes to changes, then enter.

Step 4

Chroot and Configuring the New System

To configure our new system we have to ‘chroot’ (switching the root directory from the disk image to the new system) into it with the command: arch-chroot /mnt

root@archiso /mnt # arch-chroot /mnt
sh-4.2#

Setting Locale

sh-4.2# nano /etc/locale.gen

Un-comment these lines unless you are know you are using something else.

#en_US.UTF-8 UTF-8
#en_US ISO-8859-1

To this.

en_US.UTF-8 UTF-8
en_US ISO-8859-1

Ctrl-X to exit, yes to changes, then enter.

Generate locale

sh-4.2# locale-gen
Generating locales...
  en_US.UTF-8... done
  en_US.ISO-8859-1... done
Generation complete.

If you want to change the console font or keymap go here

Setting the time zone is done by creating a symbolic link from the ‘zoneinfo’ directory to /etc/localtime.
ln -s /usr/share/zoneinfo/<Zone>/<SubZone> /etc/localtime

For example, I’m in Phoenix, Arizona.

sh-4.2# ln -s /usr/share/zoneinfo/America/Phoenix /etc/localtime

The Arch Linux Wiki has some interesting things to say about setting the hardware clock. We will follow the recommended setting.

sh-4.2# hwclock --systohc --utc

Set the ‘hostname’, for simplicity I’m setting this one to ‘arch’.

sh-4.2# echo arch > /etc/hostname

DHCP networking is a snap, just enable the service like this.

sh-4.2# systemctl enable dhcpcd@eth0.service

Optional Step: Static IP take a little bit more. I’ll go over it briefly without too much explanation.

We need to install ‘ifplugd’.

sh-4.2# pacman -S ifplugd
resolving dependencies...
looking for inter-conflicts...

Targets (2): libdaemon-0.14-2  ifplugd-0.28-13

Total Download Size:    0.04 MiB
Total Installed Size:   0.21 MiB

Proceed with installation? [Y/n] y

Then copy the example file over.

sh-4.2# cd /etc/network.d
sh-4.2# cp examples/ethernet-static .

Configure your setting, changing ADDR and GATEWAY should be enough, however your settings and network will vary.

sh-4.2# nano ethernet-static

Enable the service

sh-4.2# systemctl enable net-auto-wired.service

Networking should be all set up now.

Step 5

Set root password and Creating a User

Set the root password.

sh-4.2# passwd
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

Create a new user, and set a password. My user is called justin, feel free to use your name.

sh-4.2# useradd -m -g users -s /bin/bash justin
sh-4.2# passwd justin
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

Step 6

Installing Syslinux

Now we need to install the boot loader, ‘syslinux’.

sh-4.2# pacman -S syslinux
resolving dependencies...
looking for inter-conflicts...

Targets (1): syslinux-4.05-7

Total Download Size:    0.77 MiB
Total Installed Size:   3.78 MiB

Proceed with installation? [Y/n] y

Change into the syslinux directory.

sh-4.2# cd /boot/syslinux/

Copy the menu, other key files into our current directory.

sh-4.2# cp /usr/lib/syslinux/menu.c32 .
sh-4.2# cp /usr/lib/syslinux/hdt.c32 .
sh-4.2# cp /usr/lib/syslinux/reboot.c32 .
sh-4.2# cp /usr/lib/syslinux/poweroff.com .

Take a moment to review the ‘syslinux.cfg’

sh-4.2# nano syslinux.cfg

Notice the line ‘APPEND root=/dev/sda3 ro’ states that our root partition is at /dev/sda3, which it is.

LABEL arch
        MENU LABEL Arch Linux
        LINUX ../vmlinuz-linux
        APPEND root=/dev/sda3 ro
        INITRD ../initramfs-linux.img

If everything looks good, install it.

sh-4.2# extlinux --install /boot/syslinux
/boot/syslinux is device /dev/sda1

And Write. Make sure you type all of this, exactly like it is:
dd bs=440 conv=notrunc count=1 if=/usr/lib/syslinux/gptmbr.bin of=/dev/sda

sh-4.2# dd bs=440 count=1 conv=notrunc if=/usr/lib/syslinux/gptmbr.bin of=/dev/sda
1+0 records in
1+0 records out
440 bytes (440 B) copied, 0.00650222 s, 67.7 kB/s

Step 7

Unmounting and Setting the GPT BIOS Attribute

Exit the ‘chroot’, change directory to /, un-mount everything we had mounted, and turn off the Swap.

sh-4.2# exit
exit
root@archiso /mnt # cd /
root@archiso / # umount /mnt/boot
root@archiso / # umount /mnt/home
root@archiso / # umount /mnt
root@archiso / # swapoff /dev/sda2

Set the BIOS attribute to boot GPT.

root@archiso / # sgdisk /dev/sda --attributes=1:set:2
The operation has completed successfully.

root@archiso ~ # reboot

Remove install media and boot into your freshly installed Arch Linux system.

Closing

Further Reading and References

Arch Linux uses pacman as it’s package manager.
How to update the system

[root@arch ~]# pacman -Syu

And to install packages, one at a time, or multiple packages.

[root@arch ~]# pacman -S python2 mongodb openssh vim

Enable, disable, start, and stop services. For example sshd.
You can find more service in: /usr/lib/systemd/system

[root@arch ~]# systemctl enable sshd.service
[root@arch ~]# systemctl start sshd.service
[root@arch ~]# systemctl stop sshd.service
[root@arch ~]# systemctl disable sshd.service

Arch Linux Wiki
Package Database
systemd
Pacman
How to install a GUI
Awesome YouTube video of an Arch Linux install by Jonathan Vasquez

I hope this guide was useful and you enjoy your brand new Arch Linux installation. Make sure to check out the well documented Arch Linux Wiki.

Justin Canington – 2012