Arch Linux Installation – Part 1

Arch Linux has been a favorite distro of mine for quite some time. This tutorial will show you how to get a lightweight system up and running in almost no time. Configuration is based on the Arch Linux Beginners’ Guide but will be less generic and more tailored to my preferences.

Arch is a rolling release distribution, so my guide may break at some point. I will do my best to keep it current. Some steps will be skipped for brevity but will be touched on and linked back to the Beginners’ Guide.

Arch Linux, my way


First and foremost, grab the .iso! If you have the option use the .torrent option as it will help with their bandwidth.https://www.archlinux.org/download/

Once you have acquired the image burn the .iso to a blank disk or throw it onto a flash drive. I prefer the flash drive method because its more cost effective and installation goes a lot quicker. If you are already on a Linux system you can just open a terminal and type

#dd if=/dev/sdc of=/archlinux.iso

to push the image to the drive. Of course you need to replace /dev/sdc with your flash drives location as dd will overwrite whatever it is pointed at. Be careful here. If you aren’t sure where it is located you can use "ls -l /dev" from term to see where things are pointing and if you just inserted the flash drive dmesg should show you where it was attached.

Reboot and configure your system to boot from the brand new CD/USB drive you just made. Reboot with the disk inserted/plugged into the computer. If things go right your system will boot from the media and you will be prompted to make a selection on how to start the disk up. I am going to select i686 for this install.

boot

Boot Menu

The system will verbose as it starts up and eventually you will be greeted with a prompt.

root@archiso ~ #

Pre-Install


Language

If you need to change your language to perform the install, here are the instructions. By default Arch uses English (us).
https://wiki.archlinux.org/index.php/Beginners%27_Guide#Change_the_language

This Link was recently broken by Arch, I’ll update it when I figure out why it wont link properly. For now Google will be your friend.


Internet Access

Check to make sure you have access to the Internet. This should work out of the box if you’re wired into your router.

# ping -c 3 google.com
...
--- google.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2043ms
rtt min/avg/max/mdev = 41.005/42.550/45.277/1.933 ms

If you don’t get a response, do a little trouble shooting… (I’ll  update this section later)

Prepare your destination drive

We will need, at least a root partition and a home partition. It is actually preferred to split your drive further than this. This would keep fragmentation to a minimum as well as allow you to secure or optimize the drive for particular use cases. For example, a webserver could have a very large /var partition. We don’t have any special needs and the base requirements are all we need.

# cfdisk /dev/sda

The tool will open, navigate to New and enter “5000M” to make a partition of that size, make it bootable. Hit New again, use the remaining space on the drive. You should adjust these numbers according to your preferences. 5000Mb is a really small partition for root but will suit my requirements. When the table looks satisfactory, hit “shift-w” and type “yes” at the warning. Before you exit, note the name of your partitions. Mine is sda1 and sda2.

partition table

partition table

You may have noticed that we didn’t create a swap partition. This is because modern systems have so much ram that it isn’t really necessary any longer. If for some reason you’re using a legacy system or just don’t have that much ram (less than 3Gb) you should look into using a swap partition to give yourself that extra buffer.

Lets confirm that our partitions were written

# cfdisk -P s /dev/sda

If everything looks good let’s go ahead and write filesystems to the partitions. I use ext4, feel free to use btrfs or whatever you fancy.

# mkfs.ext4 /dev/sda1
# mkfs.ext4 /dev/sda2

If no errors occurred lets mount these guys, in order. Root then home.

# mount /dev/sda1 /mnt
# mkdir /mnt/home
# mount /dev/sda2 /mnt/home

Mirrors
It isn’t necessary to change this but if you need or want to, adjust this to your liking. Obviously you want to use a mirror on the other side of earth. Closer is better.

# vi /etc/pacman.d/mirrorlist

Installation


Lets go ahead and pull in some packages for our system. We will need the base packages as well as base-devel. Base-devel contains all the developer tools like make and gcc. We will use these later when we need to compile a few things.

# pacstrap -i /mnt base base-devel

When prompted hit “enter” twice followed by a “y” to install all the necessary packages. Go grab a cup of coffee. Depending on your internet connection this could take a while.

Fstab
Fstab controls the mount points of your system, it is very important that these are correct. Be sure to triple check them. I like to control them with UUID, this is the equivalent of static linking to a device. Helpful if you are like me and swap you swap your drives around a lot. Especially true if you’re using a thinkpad and have a HDD in your SuperDrive slot. Trust me on this one, it will save you some headaches.

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

As noted on the Arch wiki, you can remove "data=ordered" as it will be used no matter what.

Chroot

Lets jump into our new system and do some configuration. Chroot is a tool that allows us to change our root system and make changes as if we were actually running the other device. This is a wonderful tool if you ever break your system and need to get back in.

# arch-chroot /mnt /bin/bash

Configuration


Locales

“Locales are used by glibc and other locale-aware programs or libraries for rendering text, correctly displaying regional monetary values, time and date formats, alphabetic idiosyncrasies, and other locale-specific standards.”

Edit appropriately for your language.

# vi /etc/locale.gen

Uncomment this line if you want to use English. Only use UTF-8 options.

en_US.UTF-8 UTF-8

Generate your locale.

# locale-gen

Set the locale environment variables.

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

Console Fonts

Lets set our keymaps and fonts. The default keymap is "us", only needs to be adjusted if “us” does not apply to you. I love Terminus for its legibility as a mono-spaced font. I will be setting the environment variable here.

# setfont Lat2-Terminus16

Create and edit /etc/vconsole.conf and add your preferred font.

# vi /etc/vconsole.conf

I will be adding this line.
FONT=Lat2-Terminus16

Time Zones

Find where you are in the world; drill down until you find the location closest to you.

# ls /usr/share/zoneinfo/

Link your timezone to localtime

# ln -s /usr/share/zoneinfo/US/Pacific /etc/localtime

Hardware Clock

We want our clock to stay synced up with the rest of the world. It is especially important you have an accurate clock if you use an authentication system such as Kerberos. We are eventually going to use ntp for this, but for now UTC time will be just fine. I noticed that systemd wont let you start the daemon while we are chrooted so this will have to be done later.

# hwclock -w -u

Hostname

Pick a unique name for your computer, if you are part of a larger network you might want it to be relevant to said network. Such as ‘computer1.location’

# echo vesuvius > /etc/hostname

Configure your network, again.

This is for your new system, you might just want to use the same settings you used to get you this far. I am wired and receiving my settings from a local DHCP server so I just need this one liner.  Consider looking through the options, Arch provides some handy tools to get you up and running if you are using WiFi or a more complex setup. 

Find your interface and launch these commands. Arch changed the defaults from eth0 and wlan0 so you might want to see what there names are before setting up systemctl.

# ip link
# systemctl enable dhcpcd@<interface>.service
# systemctl start dhcpcd@<interface>.service

Configure package management (pacman)

The defaults are probably what you want unless you have a need to enable multilib or have an interest in trying out Starch Linux. Look through the config to make sure everything is good, regardless.

# vi /etc/pacman.conf

Init RAM environment

Lets get our boot environment up and running. You probably don’t need to edit this file as the defaults are sane but have a look through it and adjust the HOOKS="" line to meet your systems needs. It may be prefered to leave the defaults and tailor this later when you know your box is up and running. Specify modules in here might be desired later on. In case you didn’t notice, the block hook has replaced pata and sata.

# vi /etc/mkinitcpio.conf

uncomment the line

COMPRESSION="xz"

Build the image. This command will actually generate two initramfs images, the everyday one and a fallback. Remember this line needs to be run every time you edit mkinitcpio.conf.

# mkinitcpio -p linux

Password

Set your root password. This should be a at least 8 mixed characters. If you don’t know what makes a good password, read through this wiki for a primer:http://en.wikipedia.org/wiki/Password_policy

# passwd

User and groups

We don’t use root for anything but system maintenance, so we need a daily user. It helps to know what the user is going to be used for so you can assign it to the relevant groups. A good admin needs to have an understanding of user and group concepts, I encourage you to read up on it: https://wiki.archlinux.org/index.php/Users_and_Groups

# useradd -m -g users -G audio,disk,storage,video,wheel -s /bin/bash tony
# passwd tony

Since we added our user to the group ‘wheel’ we also need the sudo package. Sudo makes administration much easier so lets pull it in.

# pacman -S sudo

use visudo and uncomment the appropriate line to allow members of wheel to act as root

# visudo

%wheel ALL=(ALL) ALL

This functionality can also be obtained by adding a user to visudo. Wheel is nice however, as we may have more admins someday.

Bootloader

Syslinux is a pretty cool project that comprises several different flavors, it is also what we are going to use to get our system to boot. Install syslinux using pacman and install it to the mbr.

# pacman -S syslinux
# syslinux-install_update -i -a -m

Edit the config and make sure syslinux knows where to find your root partition. If you are dual booting you can add an entry for your second OS. I have run into situations with my Thinkpad where using two hard drives caused /dev/sda* to change on boot. This left me unable to boot until I took the second drive out. Consider linking by UUID. Disk UUIDs can be found in /dev/disk/by-uuid/

# vi /boot/syslinux/syslinux.cfg

Edit the APPEND line on arch and fallback to suit your needs

APPEND root=/dev/sda1 ro

Umount and reboot

The step you’ve been waiting for, let’s get out of chroot, unmount and reboot!

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

Nice work! You made it! You need to adjust your BIOS to boot from your new installation. Make those changes, boot and enjoy. Hope you enjoyed part 1, part 2 will set you up with a window manager, web browser, media playback and more!

About

Tony is a system administrator from Seattle, WA. He specializes in secure, minimal, Linux installations.

Posted in Linux Tagged with: , , , , , , , , , , , , ,

What did you think?

Subscribe

Enjoy what we do? Want to stay updated? Enter a valid E-mail address, and never miss a thing.

%d bloggers like this: