19 June 2013

Swapnil Bhartiya's picture
Posted by Swapnil Bhartiya on April 04, 2013

Arch Linux is one of the the most tempting GNU/Linux based operating systems. I always wanted to use Arch due to its rolling release model, and I have explained in detail why I jumped ship and switched from Ubuntu to Arch.

Arch is more or less like building your own house on your own land. You own it, but you are also responsible for it. That makes things a bit tricky, you don't just move in, you have to build it first. As I said I always wanted to use Arch, but the only thing that was coming between me and Arch was installation.

If you are trying to install Arch on your system the Beginner’s Guide is an awesome resource, but there is so much information that it can be intimidating at times. If you are someone like me who wants to use Arch but is afraid of its official wiki, this article will help you. It's more or less a documentation of the steps I took to install Arch on my systems.

I have migrated 7 machines to Arch so these steps are fool-proof and will work for everyone, other than three tiny issues – graphics, wireless and UEFI. But none of this is deal-breaker, the Arch wiki was helpful enough to help me find solutions to those answers as well.

Before you follow this tutorial, I would suggest that you also open the Beginner’s Guide and compare the steps I mentioned in this article with those in the wiki. The goal of this article is to make you comfortable with the Arch Wiki. Use my tutorial to understand the official guide.

So, let’s take a dive in the warm waters of Arch

My hardware
CPU: 64 bit Intel
Hard Drive: 128GB SSD
RAM: 8GB
Nvidia GTX 470
BIOS

Arch Linux installation Image Gallery

Getting Arch

You can download the latest image of Arch from the download page. I will recommend the Bittorent method. Once installed put it on a USB with the dd command:

sudo dd if=/path_to_arch_.iso of=/dev/sdX

(Here sdX is the USB drive. Please remember don’t use any numbers, for example, if your drive is detected as sde, don’t use sde1, instead just use ‘sde’). Once the USB is ready, plug it into your computer and boot into Arch.

Arch Installation

It is recommended that you use the Ethernet connection for installation as your PC might need drivers for the wirelss chip and it will only complicate things. To keep it simple, plug the ethernet cable and check if you have the internet connectivity. Run this command:

ping -c 3 www.google.com

Preparing hard drive

We need to first prepare the hard-drive for the fresh install. It is usually recommended that you create the partition or format the hard-drive from live CD of openSUSE or any other distribution. However, I do it from within Arch it self. In my case I was wiping the parting where Ubuntu was installed and installing Arch on it. There was other data on the same hard-drive on different partitions.

If this is the first time you are installing Arch on your system I would recommend using live CD/USB of openSUSE or Linux Mint to create partitions. It's just to make it easier for you and also to keep this tutorial as simple and easy as possible.

So I ran this command:

cfdisk /dev/sda

[Here sda is the hard-drive on which I wanted to install Arch.]

Name    Flags     Part Type    FS Type          [Label]       Size (MB)
-----------------------------------------------------------------------
sda1    Boot    Primary     Linux                          15360
sda2               Primary     Linux                            3000
sda3               Primary     Linux                        133000*

[sda1 is where I will create root of Arch, sda2 will be swap and sda3 is where I will create home.]

1. Choose the partition you want to format and select 'Delete' - In this case, it's sda1.
2. Choose the free space and then select 'New" and hit enter.
3. Choose 'Primary'
4. Size
5. Beginning
6. Choose 'bootable'
7. Write [It will ask you whether you want to save the changes and you can type 'yes']
8. Quit

Now select the partition which you want to use as SWAP

1. Choose the partition you want to format and select 'Delete' - In this case, it's sda2.
2. Choose the free space and then select 'New" and hit enter.
3. Choose 'Primary'
4. Size
5. Beginning
6. Write
7. Quit

It's time to create home partition (this will delete all data from home, so pleae make a back-up of your data saved in home)

1. Choose the partition you want to format and select 'Delete' - In this case, it's sda3.
2. Choose the free space and then select 'New" and hit enter.
3. Choose 'Primary'
4. Size
5. Beginning
6. Choose 'bootable'
7. Write [It will ask you whether you want to save the changes and you can type 'yes']
8. Quit

It's now time to format these partitions and we are going to use ext4 file system. Run the following command for root:

# mkfs.ext4 /dev/sda1
# mkfs.ext4 /dev/sda3

[make sure to select the appropriate partition instead of sda1 or sda3]

Now let's format SWAP

# mkswap /dev/sda2
# swapon /dev/sda2

[make sure to select the appropriate partition instead of sda2]

In order to make sure everything is correct check your partitions with this command:

# lsblk /dev/sda

Installing base system

If everything looks fine, it's time to install Arch. First we need to create home partition and then mount home and root partitions.

Let's create the home directory:

# mkdir /mnt/home

Now mount home and root. The command is:

# mount /dev/sda1 /mnt
# mount /dev/sda3 /mnt/home

Before we initiate the install process let's select the closest mirror so that you get the best speed while downloading packages. To edit the mirror list run this command:

# nano /etc/pacman.d/mirrorlist

Which will open the looong list of mirrors. You can select the one closest to you. If you want to search the name of the location hit Ctrl+W and type the location you are looking for, once found. Go to the url of the mirror and hit Alt+6 to copy the line. Now use 'Page Up' key to go on top and then hit Ctrl+U to paste that line on top.

Hit Ctrl+x to exit and then type Y for yes.

Now we are about to install base and devel packages (which you will need when compiling applications). Run this command:

# pacstrap -i /mnt base base-devel

Once all these packages are installed you need to configure your fstab. Run:

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

(NOTE: Run the above command only once even if there are any issues. If there are problems, edit fstab manually)

You must always check if fstab entry is correct of you won't boot into your system. Run:

# nano /mnt/etc/fstab

This command will show you the root partition mounted.

Now it's time configure your system. Chroot into your newly installed system

# arch-chroot /mnt

Language and location settings

We are going to configure the language of the new system. Since I am using English I am choosing "en_US.UTF-8". You can choose the language that you use.

Run the following command:

# nano /etc/locale.gen

It will open a huge list of locales, go and uncomment the one you need. In my case I uncommented:

en_US.UTF-8 UTF-8

Now set the locale

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

It's time now to configure the time zone for your system. If you don't know the exact name of your sub-time zone (for example in my case it Zone is Europe and sub-zone is Brussels).

To find your zone and sub-zone you can run this command:

# ls /usr/share/zoneinfo/

Now you can configure the zone

# ln -s /usr/share/zoneinfo/<Zone>/<SubZone> /etc/localtime

Now its time to configure the hardware clock. It is recommended to use UTC instead of localtime.

# hwclock --systohc --utc

Configure repositories

We are done with language and time zone, now it's time to configure repositories. Open the pacman.conf file:

# nano /etc/pacman.conf

If you are using 64 bit system you should go ahead and enable (un-comment) the "multilib" repo:

[multilib]
Include = /etc/pacman.d/mirrorlist

Then hit Ctrl+X and then type 'y' when asked.

Now it's time to updae the repositories by running this command:

pacman -Sy

Create users and password

We first need to give a root password so we can perform administrative tasks. But we will also create a user for the system as it's not a good idea to run as root.

First set root password. Run this command and give the password:

# passwd

Now it's time to create a user for the system and also add some groups to it. So run the following command and replace 'muktware' with your user-name.

useradd -m -g users -G wheel,storage,power -s /bin/bash muktware

Then give the password for this new user (which in my case was muktware). When you run this command it will again ask you to enter new password:

passwd muktware

Letting this user to perform administrative tasks as sudo. So, let's install sudo

pacman -S sudo
pacman -Ss sudo

Once that is done, we will now allow the users in wheel group to be able to performance administrative tasks with sudo. Run the following command to edit the sudoers:

EDITOR=nano visudo

It will open the sudoers file where you have to uncomment this line:

%wheel ALL=(ALL) ALL

I will also recommend installing bash-completion so that Arch auto-complete commands of names of packages:

pacman -S bash-completion

Install boot loader

Installing grub and configure the boot loader. In my case I have a system with BIOS (if you have UFI then check out the appropriate Arch Wiki page).

Let's first install grub for bios and configure it. Run these commands:

# pacman -S grub-bios
# grub-install --target=i386-pc --recheck /dev/sda
# cp /usr/share/locale/en\@quot/LC_MESSAGES/grub.mo /boot/grub/locale/en.mo

I have other operating systems installed on the same system (namely openSUSE and Kubuntu) so I wanted Arch to show these systems in the grub menu so I can select at the boot. Even if you don't have other OSes installed I would recommend installing OS Prober:

pacman -S os-prober

Once it is installed update the grub so Arch knows about other operating systems. Run this command:

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

We are now done with the installation and configuration of Arch Linux. That leaves us with installed display manager (X server) the desktop environment and appropriate graphics drivers. But we need to boot out of this system and restart the PC. So first exit from the chroot environment:

# exit

And now unmount the root, home and reboot the system:

# umount /mnt/home
# umount /mnt
# reboot

Booting into your new Arch system

Now boot into your new system with the user you created. Since you are not logged in as root you will need to use sudo in order to perform administrative tasks.

Getting network back to work

Since Arch has switched to systemd the name of the network will change after reboot. Earler it used to be simple (yet at times troubling eth0 or wlan0) to find the new name of your appropriate network card run this command:

ip link

Note the name of the ethernet connection and enable/start the network:

# sudo systemctl enable dhcpcd@<interface>.service
# sudo systemctl start dhcpcd@<interface>.service

Check if the network is working run

ping -c 3 www.google.com

Now comes the part where we are going to install x server, video drivers and desired desktop environment.

Let's install X

# sudo pacman -S xorg-server xorg-xinit xorg-server-utils

Now we will also install mesa for 3D support:

# pacman -S mesa

It's time to install video drivers. I assume you know which GPU you are using. In my case I have Nvidia GTX 470 on my system so I installed the non-free Nvidia driver.

# sudo pacman -S nvidia lib32-nvidia-utils

Arch wiki has done a great job at documenting which drivers you need to install for your hardware.

Brand

Type

Driver

Multilib Package

(for 32-bit applications on Arch x86_64)

Documentation

AMD/ATI

Open source

xf86-video-ati

lib32-ati-dri

ATI

 

Proprietary

catalyst-dkms

lib32-catalyst-utils

AMD Catalyst

Intel

Open source

xf86-video-intel

lib32-intel-dri

Intel Graphics

Nvidia

Open source

xf86-video-nouveau

lib32-nouveau-dri

Nouveau

   

xf86-video-nv

(legacy driver)

 

Proprietary

nvidia

lib32-nvidia-libgl

NVIDIA

   

nvidia-304xx

lib32-nvidia-304xx-utils

 

If you are using a laptop you need to install the drivers for input devices like touchpad

# pacman -S xf86-input-synaptics

Now install the default environment before we move to install the prefered desktop environment:

# pacman -S xorg-twm xorg-xclock xterm

You can now test if X is working by running this command:

startx

If everything works fine, it will open x windows, you can exit it by clicking on the first window and type 'exit'.

Now it's time to install your favourite desktop environment. I am using KDE so I went ahead and installed KDE packages:

sudo pacman -S kde

It will ask you to choose the prefered phonon as well as default fonts.

Once it is installed you need to configure KDM

# systemctl enable kdm.service
# systemctl start kdm.service

It will boot your system into KDE.

Tuning your KDE install: Managing Network

There are certain things you would like to get a polished KDE experience. Now you can also configure the wireless for your system if you need wireless. First check if your wireless chip is already detected, run
ip link and if you see the wireless

wlp10s2 in my case is the wirelss.

If wireless is not detected you may need to install the appropriate wireless driver (which is beyond the scope of this article as there are hundres of wireless chips. Please consult this page https://wiki.archlinux.org/index.php/Wireless_Setup#Identify_and_Discover_if_Supported)

If your wireless device is detected let's install a wireless manager, run this command:

sudo pacman -S kdeplasma-applets-networkmanagement

Once installed enable and start the NetworkManager:

# systemctl enable NetworkManager
# systemctl start NetworkManager

To make life easier you can add the network manager to the bottom panel so that you can manage connections easily.

Managing Audio

KDE handles audio in a smarter manner, but it can be tricky at times. So let's tame the pulseaudio. Install following packages:

pacman -S pulseaudio pulseaudio-alsa pavucontrol

Once installed, go to pavucontrol and configure the appropriate input output devices.

Manage 3rd party or AUR packages or applications. One of the greatest advantages of using Arch is that you have access to almost ever package or application available for any GNU/Linux distribution. The Arch User Repository aka AUR has thousands of packages, including Steam client. It's actually very easy to install any package from AUR.

1. Visit the AUR search for the packages and download the PKGBUILD tarball.
2. Extract the tarball
3. cd to the extracted directory
4. Run  "makepkg -s", which will compile and prepare the package and you will get the compiled packages as package_name.tar.xz
5. Install the packages by running sudp packan -U /path_to_compiled.tar.xz

However you can make it easier to install packages from AUR by installing Packer.

Download packer tarball.

Now extract the tarball and cd to packer directory (in my case, I downloaded and extracted in Downloads folder)

cd Downloads/packer/
makepkg -s

Let it compile the package and when done, stay in the same directory and install it by running this command:

sudo pacman -U packer_VERSION.pkg.tar.xz

Now since packer is installed it's very, very easy to install packages from AUR as well as main Arch repositories. To install any package, run this command:

packer package_name

If the package is available it will list it, you can give the number of the package and if it's in main repo yaourt will ask your password and install it and if it's in AUR it will start compiling it. It will ask if you want to edit the PKGBUILD files, you can simply type 'n' to continue compilation.

Some useful commands:

To update the repositories

sudo pacman -Sy

To update system

sudo pacman -Syu

To remove any package

sudo pacman -Rns

To update packages from AUR

packer -Syu

Hope you will enjoy your Arch install.

Tags: 

Swapnil Bhartiya

A free software fund-a-mental-ist and Charles Bukowski fan, Swapnil also writes fiction and tries to find cracks in a proprietary company's 'paper armours'. He is a big movie buff and prefers listening to music at such high volumes that he's gone partially deaf when it comes to identifying anything positive about proprietary companies. You can follow him on Twitter, Google+ & Facebook. You can write to him on editor at muktware dot com