Arch Linux - a trial



This entry walks the reader through the process of installing Arch Linux. It basically re-presents the steps defined in the Beginner's Guide to Installing Arch Linux—with me contributing only minor edits and comments to improve clarity and to help me more quickly re-deploy a system if I bungle it.

  1. Installing Arch Linux from USB *.iso
    a. Establish an internet connection

A Personal Note Detailing Why I Like Arch Linux

I am new to Linux.
I have been using Ubuntu for just over a year now—mostly to help me work with a data and knowledge management system for my very tiny consulting firm.

When I first started using Ubuntu, I felt disappointed. I had an experience as a college junior involving a team of geeks not getting RedHat Linux to work on a Gateway laptop. The two hours I spent listening to the geek-speak of "tweaking the kernel" conjured in my mind a mystery of what Linux is and how insanely technical it must. When years later I finally was re-encouraged into trying Ubuntu (actually, Linux Mint at first, which I kept for about a week), I found it to look, act and feel just the same as Windows and MacOSX: just a horse of different color (and one that couldn't support MS Office—tool of my trade). Why all the fuss?

Over the course of the last year, I learned a lot about what Linux "is" and what distinguishes it from other operating systems. During my year of working with Ubuntu, I deleted and re-installed the OS about 20 times--each time looking up some esoteric setting to get the desktop situated the way I like. It was a steep learning curve of researching and re-researching minor tweaks, box-dependent bugs and the like. [I finally decided I should keep track of all of this for the next occasion I make a mess of my system and have to wipe it... something that advanced users seem never to need to do, but is the only routine I know in times of egregious folly.]

But why start this post on ArchLinux by speaking of Ubuntu?

Because Arch is different.

In a way, Arch "is" what Linux "is". It is remarkably simply, light, and yet versatile operating systems intended to give user total control over their environment. Arch dispenses with all the trickery of trying to be an "easy to intuit" system, and instead asks you why you're even on the computer in the first place. You start from the command line—the base layer of user–machine interaction—and decide from there what you want to do and how to get it done. It's a step closer to the high wizardry of the super-geek, and it offers none of the frills and bloat of the other systems, nor does it start you out in a desktop environment meant to replicate the look and feel of either Mac or MSWindows. Here's how another blogger puts it.

Unfortunately, Arch brings me no closer to being able to ditch MSOffice (which tethers me to MSWindows in one form or another), but that's a different post.


Installing Arch Linux from USB *.iso

Localize

The default keyboard layout us. If you have a non-US keyboard layout, run:
# loadkeys layout

...where layout can be fr, uk, dvorak, be-latin1, etc. Use the command localectl list-keymaps to list all available keymaps.

Also, for languages using more the 26 English letter glyphs, it's necssart to change teh font—otherwise some foreign characters may show up as white squares or as other symbols.

Note that the name is case-sensitive:
# setfont Lat2-Terminus16

If you would like to change the language for the install process (German, in this example), remove the # in front of the locale you want from /etc/locale.gen, along with English (US).

Please choose the UTF-8 entry.

# nano /etc/locale.gen
en_US.UTF-8 UTF-8
de_DE.UTF-8 UTF-8
# locale-gen
# export LANG=de_DE.UTF-8

Establish an internet connection

Wired

The dhcpcd network daemon starts automatically during boot and it will attempt to start a wired connection. Try to ping a server to see if a connection was established.

For example, Google's webservers:
# ping -c 3 www.google.com

If you're not connected, disable the dhcpcd service:

# systemctl stop dhcpcd.service

Use the command ip link to discover the names of your interfaces. Example output will looks something like this":

1: lo: 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: 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: 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

In this example, the Ethernet interface is enp2s0f0. If you are unsure, your Ethernet interface is likely to start with the letter "e", and unlikely to be "lo" or start with the letter "w".

Activate the connected Ethernet interface (e.g. enp2s0f0):
# ip link set enp2s0f0 up

Add the address:
# ip addr add ip_address/mask_bits dev interface_name

For example:
# ip addr add 192.168.1.2/24 dev enp2s0f0

For more options, run man ip.

Add your gateway like this, substituting your own gateway's IP address:
# ip route add default via ip_address

For example:
# ip route add default via 192.168.1.1

Edit resolv.conf, substituting your name servers' IP addresses and your local domain name:

# nano /etc/resolv.conf

nameserver 61.23.173.5
nameserver 61.95.849.8
search example.com

Note: Currently, you may include a maximum of three nameserver lines. Should you need to overcome this limitation, you can use a locally caching nameserver like Dnsmasq.

Once all these settings are configured, you should now have a working network connection. If not, try troubleshooting by by referencing the Arch Linux network configuration page.

Wireless

must be repeated from the actual installed system after booting into it.

The basic procedure will be:

  • Identify the wireless interface:

# lspci | grep -i net

  • Ensure udev has loaded the driver, and that the driver has created a usable wireless kernel interface with iwconfig:

Note: If you do not see output similar to this, then your wireless driver has not been loaded. If this is the case, you must load the driver yourself. Please see Wireless Setup for more detailed information.

# iwconfig

enp2s0f0 no wireless extensions.
wlp3s0  IEEE 802.11bgn ESSID:"NETGEAR97"
Mode:Managed Frequency:2.427 GHz Access Point: 2C:B0:5D:9C:72:BF
Bit Rate=65 Mb/s Tx-Power=16 dBm
Retry long limit:7 RTS thr:off Fragment thr:off
Power Management:on
Link Quality=61/70 Signal level=-49 dBm
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:430 Missed beacon:0
lo      no wireless extensions.

In this example, wlp3s0 is the available wireless interface.

  • Bring the interface up with:

# ip link set wlp3s0 up

A small percentage of wireless chipsets also require firmware, in addition to a corresponding driver. If the wireless chipset requires firmware, you are likely to receive this error when bringing the interface up:

Next, use netcfg's wifi-menu to connect to a network:

# wifi-menu wlp3s0

Warning: At the moment, netcfg's wifi-menu, when executed without arguments, will look for "wlan0". Execute wifi-menu with your interface as the argument in order to use it.

You should now have a working network connection. If you do not, check the detailed Wireless Setup page.

Prepare the storage drive

MBR GPT

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

If you have made a partition dedicated to swap (code 82), don't forget to format and activate it with:

# mkswap /dev/sdaX
# swapon /dev/sdaX

Then mount the home partition and any other separate partition (/boot, /var, etc), if you have any:

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

In case you have a UEFI motherboard, mount the UEFI partition:

# mkdir /mnt/boot/efi
# mount /dev/sdaX /mnt/boot/efi

Select a mirror

Before installing, you may want to edit the mirrorlist file and place your preferred mirror first. A copy of this file will be installed on your new system by pacstrap as well, so it's worth getting it right.

# nano /etc/pacman.d/mirrorlist
##
## Arch Linux repository mirrorlist
## Sorted by mirror score from mirror status page
## Generated on 2012-MM-DD
##

Server = http://mirror.example.xyz/archlinux/$repo/os/$arch
...

Install the base system

The base system is installed using the pacstrap script.

The -i switch can be omitted if you wish to install every package from the base and base-devel groups without prompting.

# pacstrap -i /mnt base base-devel

Note: If pacman fails to verify your packages, check the system time with cal. If the system date is invalid (e.g. it shows year 2010), signing keys will be considered expired (or invalid), signature checks on packages will fail and installation will be interrupted. Make sure to correct the system time, either by doing so manually or with the ntp client, and retry running the pacstrap command. Refer to Time page for more information on correcting system time.

Note: If pacman complains about invalid signatures during the pacstrap phase (error: failed to commit transaction (invalid or corrupted package)) run the following command below.

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

  • base: Software packages from the [core] repo to provide the minimal base environment.
  • base-devel: Extra tools from [core] such as make, and automake. Most beginners should choose to install it, as it will likely be needed to expand the system. The base-devel group will be required to install software from the Arch User Repository.

This will give you a basic Arch system. Other packages can be installed later using pacman.

Generate an fstab

Generate an fstab file with the following command. UUIDs will be used because they have certain advantages (see fstab#Identifying filesystems). If you would prefer to use labels instead, replace the -U option with -L.

Note: If you encounter errors running genfstab or later in the install process, do not run genfstab again; just edit the fstab file.

# genfstab -U -p /mnt | sed 's/rw,relatime,data=ordered/defaults,relatime/' >> /mnt/etc/fstab
# nano /mnt/etc/fstab

Warning: The fstab file should always be checked after generating it. If you made an EFI system partition earlier, then genfstab has incorrectly added options to your EFI system partition. This will in fact prevent your computer from booting from that drive, so you need to remove all options for the EFI partition except for noatime. For the other partitions that use it, be sure to replace "codepage=cp437" with "codepage=437" or else when you next reboot, any mounts with this option will fail and systemd will halt and drop into recovery mode. This should be fixed by linux 3.8

A few considerations:

  • Only the root (/) partition needs 1 for the last field. Everything else should have either 2 or 0 (see fstab#Field definitions).

Chroot and configure the base system

Next, we chroot into our newly installed system:

# arch-chroot /mnt

Note: Use arch-chroot /mnt /bin/bash to chroot into a bash shell.

At this stage of the installation, you will configure the primary configuration files of your Arch Linux base system. These can either be created if they do not exist, or edited if you wish to change the defaults.

Closely following and understanding these steps is of key importance to ensure a properly configured system.

Locale

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.

There are two files that need editing: locale.gen and locale.conf.

  • The locale.gen file is empty by default (everything is commented out) and you need to remove the # in front of the line(s) you want. You may uncomment more lines than just English (US), as long as you choose their UTF-8 encoding:

# nano /etc/locale.gen

en_US.UTF-8 UTF-8
de_DE.UTF-8 UTF-8

# locale-gen

This will run on every glibc upgrade, generating all the locales specified in /etc/locale.gen.

  • The locale.conf file doesn't exist by default. Setting only LANG should be enough. It will act as the default value for all other variables.

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

Note: If you set some other language than English at the beginning of the install, the above commands would be something like:

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

To use other LC_* variables, first run locale to see the available options. An advanced example can be found here.

Warning: Using the LC_ALL variable is strongly discouraged because it overrides everything. Console font and keymap

If you set a keymap at the beginning of the install process, load it now, as well, because the environment has changed. For example:

# loadkeys de-latin1
# setfont Lat2-Terminus16

To make them available after reboot, edit vconsole.conf:

# nano /etc/vconsole.conf

KEYMAP=de-latin1
FONT=Lat2-Terminus16
  • KEYMAP – Please note that this setting is only valid for your TTYs, not any graphical window managers or Xorg.
  • FONT – Available alternate console fonts reside in /usr/share/kbd/consolefonts/. The default (blank) is safe, but some foreign characters may show up as white squares or as other symbols. It's recommended that you change it to Lat2-Terminus16, because according to /usr/share/kbd/consolefonts/README.Lat2-Terminus16, it claims to support "about 110 language sets".
  • Possible option FONT_MAP – Defines the console map to load at boot. Read man setfont. Removing it or leaving it blank is safe.

See Console fonts and man vconsole.conf for more information.
Time zone

Available time zones and subzones can be found in the /usr/share/zoneinfo/<Zone>/<SubZone> directories.

To view the available <Zone>, check the directory /usr/share/zoneinfo/:

# ls /usr/share/zoneinfo/

Similarly, you can check the contents of directories belonging to a <SubZone>:

# ls /usr/share/zoneinfo/Europe

Create a symbolic link /etc/localtime to your zone file /usr/share/zoneinfo/<Zone>/<SubZone> using this command:

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

Example:

# ln -s /usr/share/zoneinfo/Europe/Minsk /etc/localtime

Hardware clock

Set the hardware clock mode uniformly between your operating systems. Otherwise, they may overwrite the hardware clock and cause time shifts.

You can generate /etc/adjtime automatically by using one of the following commands:

  • UTC (recommended)

Note: Using UTC for the hardware clock does not mean that software will display time in UTC.

# hwclock --systohc --utc

To synchronize your "UTC" time over the internet, see NTPd.

  • localtime (discouraged; used by default in Windows)

Warning: Using localtime may lead to several known and unfixable bugs. However, there are no plans to drop support for localtime.

# hwclock --systohc --localtime

If you have (or planning on having) a dual boot setup with Windows:

  • Recommended: Set both Arch Linux and Windows to use UTC. A quick registry fix is needed. Also, be sure to prevent Windows from synchronizing the time on-line, because the hardware clock will default back to localtime.

Not recommended: Set Arch Linux to localtime and disable any time-related services, like NTPd . This will let Windows take care of hardware clock corrections and you will need to remember to boot into Windows at least two times a year (in Spring and Autumn) when DST kicks in. So please don't ask on the forums why the clock is one hour behind or ahead if you usually go for days or weeks without booting into Windows.

Hostname

Set the hostname to your liking (e.g. arch):

# echo myhostname > /etc/hostname

Note: You no longer need to edit /etc/hosts. The nss-myhostname package will provide host name resolution, and is installed on all systems by default.

Configure the network

You need to configure the network again, but this time for your newly installed environment. The procedure and prerequisites are very similar to the one described above, except we are going to make it persistent and automatically run at boot.

Note: For more in-depth information on network configration, visit Configuring Network and Wireless Setup.

Wired
Dynamic IP

If you only use a single fixed wired network connection, you do not need a network management service and can simply enable the dhcpcd service. Where <interface> is your wired interface:

# systemctl enable dhcpcd@<interface>.service

Alternatively, you can use netcfg's net-auto-wired, which gracefully handles dynamic connections to new networks:

Install ifplugd, which is required for net-auto-wired:

# pacman -S ifplugd

Set up the dhcp profile and enable the net-auto-wired service:

# cd /etc/network.d
# ln -s examples/ethernet-dhcp .
# systemctl enable net-auto-wired.service

Static IP

Install ifplugd, which is required for net-auto-wired:

# pacman -S ifplugd

Copy a sample profile from /etc/network.d/examples to /etc/network.d:
# cd /etc/network.d # cp examples/ethernet-static .

Edit the profile as needed:
# nano ethernet-static

Edit /etc/conf.d/netcfg and modify the network interface name, most likely it is not eth0. You can find out more about the naming in the warning above.

WIRED_INTERFACE="<interface>"

Enable the net-auto-wired service:

# systemctl enable net-auto-wired.service

Wireless

You will need to install additional programs to be able to configure and manage wireless network profiles for netcfg.

NetworkManager and Wicd are other popular alternatives.

Install the required packages:
# pacman -S wireless_tools wpa_supplicant wpa_actiond dialog

If your wireless adapter requires a firmware (as described in the above Establish an internet connection section and also here), install the package containing your firmware. For example: # pacman -S zd1211-firmware

  • After finishing the rest of this installation and rebooting, you can connect to the network with wifi-menu <interface>(where <interface> is the interface of your wireless chipset), which will generate a profile file in /etc/network.dnamed after the SSID. There are also templates available in /etc/network.d/examples/ for manual configuration.

    # wifi-menu <interface>
    

Warning: If you're using wifi-menu, this must be done after your reboot when you're no longer chrooted. The process spawned by this command will conflict with the one you have running outside of the chroot. Alternatively, you could just configure a network profile manually using the templates previously mentioned so that you don't have to worry about using wifi-menu at all.

  • Enable the net-auto-wireless service, which will connect to known networks and gracefully handle roaming and disconnects:

# systemctl enable net-auto-wireless.service

Note: Netcfg also provides net-auto-wired, which can be used in conjunction with net-auto-wireless.

  • Make sure that the correct wireless interface (e.g. wlp3s0) is set in /etc/conf.d/netcfg:

    # nano /etc/conf.d/netcfg
    WIRELESS_INTERFACE="wlp3s0"
    

It is also possible to define a list of network profiles that should be automatically connected, using the AUTOPROFILESvariable in /etc/conf.d/netcfg. If AUTOPROFILES is not set, all known wireless networks will be tried.

xDSL (PPPoE), analog modem or ISDN

For xDSL, dial-up and ISDN connections, see Direct Modem Connection.

Configure pacman

Pacman is the Arch Linux package manager. It is highly recommended to study and learn how to use it. Read man pacman, have a look at the pacman article, or check out the Pacman Rosetta article for a comparison to other popular package managers.

For repository selections and pacman options, edit pacman.conf:
# nano /etc/pacman.conf

Most people will want to use [core], [extra] and [community].

If you installed Arch Linux x86_64, it's recommended that you enable the [multilib] repository, as well (to be able to run both 32 bit and 64 bit applications):

Note: When choosing repos, be sure to uncomment both the [repo_name] header lines, as well as the lines below. Failure to do so will result in the selected repository being omitted! This is a very common error. A correct example for the multilib repository is found below.

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

You will then need to update the package list by running pacman with the -Sy switch. Failing to do so will generate "warning: database file for 'multilib' does not exist" error when next using pacman.

See Official Repositories for more information, including details about the purpose of each repository.

For software unavailable directly through pacman, see Arch User Repository.

Create an initial ramdisk environment

Tip: Most users can skip this step and use the defaults provided in mkinitcpio.conf. The initramfs image (from the /boot folder) has already been generated based on this file when the linux package (the Linux kernel) was installed earlier with pacstrap.

Here you need to set the right hooks if the root is on a USB drive, if you use RAID, LVM, or if /usr is on a separate partition.

Edit /etc/mkinitcpio.conf as needed and re-generate the initramfs image with: # mkinitcpio -p linux

Note: Arch VPS installations on QEMU (e.g. when using virt-manager) may need virtio modules in mkinitcpio.confto be able to boot.

# nano /etc/mkinitcpio.conf
MODULES="virtio virtio_blk virtio_pci virtio_net"

Set the root password and add a regular user

Set the root password with: # passwd

Warning: Linux is a multi-user operating system. You should not perform everyday tasks using the root account. It is considered a very poor practice and could be extremely dangerous. The root account should only be used for administrative tasks.

Then add a normal user account. The user archie is just an example.

# useradd -m -g users -G wheel -s /bin/bash archie
# passwd archie

If you wish to start over, use userdel. The -r option will remove the user's home directory and its content, along with the user's settings (the so-called "dot" files).

# userdel -r archie

For more information, read Users and Groups.

Install and configure a bootloader

For BIOS motherboards

For BIOS systems, there are three bootloaders - Syslinux, GRUB, and LILO. Choose the bootloader as per your convenience. Below only Syslinux and GRUB are explained.

  • Syslinux is (currently) limited to loading only files from the partition where it was installed. Its configuration file is considered to be easier to understand. An example configuration can be found here.
  • GRUB is more feature-rich and supports more complex scenarios. Its configuration file(s) is more similar to a scripting language, which may be difficult for beginners to manually write. It is recommended that they automatically generate one.

Note: Some BIOS systems may have issues with GPT. See http://mjg59.dreamwidth.org/8035.html andhttp://rodsbooks.com/gdisk/bios.html for more info and possible workarounds.

Syslinux

Install the syslinux package and then use the syslinux-install_update script to automatically install the files (-i), mark the partition active by setting the boot flag (-a), and install the MBR boot code (-m):

Note: If you have partitioned the drive as GPT, install gptfdisk package, as well (pacman -S gptfdisk), because it contains sgdisk, which will be used to set the GPT-specific boot flag.

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

Configure syslinux.cfg to point to the right root partition. This step is vital. If it points to the wrong partition, Arch Linux will not boot. Change /dev/sda3 to reflect your root partition (if you partitioned your drive as in the example, your root partition is sda1). Do the same for the fallback entry.

# nano /boot/syslinux/syslinux.cfg
...
LABEL arch
        ...
        APPEND root=/dev/sda3 ro
        ...

For more information on configuring and using Syslinux, see Syslinux.
GRUB

Install the grub-bios package and then run grub-install:

Note: Change /dev/sda to reflect the drive you installed Arch on. Do not append a partition number (do not use sdaX).

Note: For GPT-partitioned drives on BIOS motherboards, GRUB needs a 2 MiB "BIOS Boot Partition".

# 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

While using a manually created grub.cfg is absolutely fine, it's recommended that beginners automatically generate one:

Tip: To automatically search for other operating systems on your computer, install os-prober (pacman -S os-prober) before running the next command.

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

For more information on configuring and using GRUB, see GRUB.

GRUB

Note: In case you have a system with 32-bit EFI, like pre-2008 Macs, install grub-efi-i386 instead, and use --target=i386-efi.

# pacman -S grub-efi-x86_64 efibootmgr
# grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=arch_grub --recheck
# cp /usr/share/locale/en\@quot/LC_MESSAGES/grub.mo /boot/grub/locale/en.mo

The next command creates a menu entry for GRUB in the UEFI boot menu. However, as of grub-efi-x86_64 version 2.00, grub-install tries to create a menu entry, so running efibootmgr may not be necessary. See UEFI#efibootmgr for more info.

# efibootmgr -c -g -d /dev/sdX -p Y -w -L "Arch Linux (GRUB)" -l '\EFI\arch_grub\grubx64.efi'

Next, while using a manually created grub.cfg is absolutely fine, it's recommended that beginners automatically generate one:

Tip: To automatically search for other operating systems on your computer, install os-prober (pacman -S os-prober) before running the next command.

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

For more information on configuring and using GRUB, see GRUB.

Unmount the partitions and reboot

Exit from the chroot environment: # exit

Since the partitions are mounted under /mnt, we use the following command to unmount them: # umount /mnt/{boot,home,}

Reboot the computer: # reboot

Tip: Be sure to remove the installation media, otherwise you will boot back into it.

Of course, configuration can be difficult...


View or Post Comments