(Written Mar 17, 2017; Re-posted Sep. 16, 2019)
This is a summary of the steps I followed to successfully install Arch Linux. Explanations aim to be minimal and concise, but do tell me if anything no longer works now.
Prepare a bootable USB stick
Download the Arch Linux ISO. If you choose a mirror close to your physical location, it may take less to download. The downloaded file is named archlinux-yyyy.mm.dd-dual.iso(according to the date compiled), about 470MB.
In the past, the default is to prepare a bootable CD-ROM. This is straightforward because an ISO is already written in the data structure of an optical disk, and such tool for burning is prevalent enough. However, USBs seem more common these days, and it can also emulate the ISO structure. To make a bootable USB, on a Windows computer for instance, download Rufus. Just drag Arch Linux ISO towards the Rufus window, and click start, and its GUI should be very straightforward. It is more convoluted to do so on a Mac. We have to format the USB first, and copy ISO into it using dd utility.
Enter the firmware interface
A firmware interface, stored in the ROM, is a bridge between software and hardware. Indeed, it is with its help that we boot a computer.
While the computer off, plug in the bootable USB. Be careful that, before the computer boots, there will be a moment the screen is shown with direction to enter the firmware interface. In the ASUS computer I am using, a notice that reads
Please press DEL or F2 to enter UEFI BIOS setting
Do that immediately, or the computer with boot with default OS as before!
Now, you will see a temporary zsh shell, with prompt root@archiso ~ #. From now on, # sign indicates the shell prompt; please don’t type it.
Partition of the Hard Disk
First list the disk blocks.
# lsblk
The largest block shall be your hard disk, which is likely listed sda. A smaller one is the bootable USB we are using. A still smaller one is the ROM (read-only memory where firmware is saved).
To partition the hard disk, invoke the command line input of utility parted.
# parted /dev/sda
From now on, the prompt (parted) will be shown for clarity (Don’t type that).
Create a partition table with the MSDOS (MBR) standard.
(parted) mklabel msdos
Meanwhile, UEFI/GPT partition is a newer standard, but not every motherboard supports. UEFI/GPT’s partitioning commands are similar; see cited notes.
Here my PC has 1TB, and I will generously allocate 40GB for /(the root directory except for the user’s home), 2GB for swap memory, and the rest for /home/(the user’s home). Now that the present day computers usually have a large RAM (mine has 4GB), 2GB of swap memory shall be more than enough.
First create partition for the root directory except for home.
(parted) mkpart primary ext4 1MiB 40GiB
Here the boot flag shall be set.
(parted) set 1 boot on
Then create the partition for swap memory.
(parted) mkpart primary linux-swap 40GiB 42GiB
Finally the partition for the root’s home, which makes up the rest of the hard disk.
(parted) mkpart primary ext4 42GiB 100%
In the steps above, if the requested partition cannot be made exactly as such, an alternative suggestion will be prompted, and if it is reasonable, say yes. You might also be asked again of the point of start and end, and again of the file system. I just typed enter to apply the default, and I hope it is okay. In addition, you may be warned that “The resulting partition is not properly aligned for best performance.” The Arch Linux Wiki suggest that we “ignore”.
Print a summary of each partition to double check the planned division.
(parted) print
The result I saw reports that sda1 is the root directory except home (used as booting process);sda2 is the swap memory; and sda3 the root’s home.
Quit if everything seems to be fine.
(parted) quit
Mounting partitions
Format partitions intended for root directory.
# mkfs.ext4 /dev/sda1
Mount the root directory.
# mount /dev/sda1 /mnt
To mount the home, we have to first create the directory, then mount it.
# mkdir /mnt/home # mount /dev/sda3 /mnt/home
Installation of system files
We will download packages, so Internet connection is required. The best situation is that you are using a PC with ethernet automatically connected. If not, you have to set it manually in CLI, which is not covered here. Alternatively, you may use a wifi (not covered here either). Anyway, beware that to access the Internet wirelessly later after reboot, all packages must be installed at this stage!
Assuming connection is established, send test packets to (for example) Google three times to test whether connection is fine.
# ping -c 3 www.google.com
Edit the list of mirrors, so that the servers physically closer to you are listed first. You may use nano if you are unfamiliar with vi.
# vi /etc/pacman.d/mirrorlist
Install the base packages. This will take quite a while, about twenty minutes in my case.
# pacstrap -i /mnt base base-devel
Generate the fstab file that specifies information about mounted partitions, and write it as the appropriate configuration file.
# genfstab -U /mnt > /mnt/etc/fstab
Language and location
In completing the remaining tasks, temporarily take /mnt to be the root directory (the root is the target partition where Arch Linux is to be installed.
# arch-chroot /mnt
I would like to work with English interface, but have to display and type Chinese. I thus choose American English to be default of system display, but furthermore install Chinese input methods. To do so, first edit the languages to be enabled. (Same, use nano if you like.)
# vi /etc/locale.gen
I shall uncomment (delete the #) before the line en_US.UTF-8 UTF-8 and zh_TW.UTF-8 UTF-8. Also uncomment other languages you want to use.
Then generate necessary information, save them, and export to terminal settings. Here locale-gen generates necessary information for all languages allowed to be used, while locale.conf specifies only the one for system’s display.
# locale-gen # echo "LANG=en_US.UTF-8" > /etc/locale.conf # export LANG=en_US.UTF-8
Next install the input method framework ibus, and the input method “Rime”. It supports several Chinese input methods.
# pacman -S ibus # pacman -S ibus-rime
To initiate it at startup, add these lines in ~/.xinitrc:
export GTK_IM_MODULE=ibus export XMODIFIERS=@im=ibus export QT_IM_MODULE=ibus ibus-daemon -drx
Select the time zone.
# tzselect
In my case this is 4) Asia, and 43) Taiwan (The very existence of this item is a reassurance!), and confirm by 1) Yes.
Create a symlink from the shared directory to the system configuration directory.
# ln -s /usr/share/zoneinfo/Asia/Taiwan > /etc/localtime
Set the hardware clock.
# hwclock --systohc --utc
Setting a boot manager
For MBR users (see above), download a boot manager and an OS-detector (possibly for the sake of dual boot).
# pacman -S grub # pacman -S os-prober
Set up the boot loader grub on the booted partition, and prepare configuration file which will be read when booting. All the same, replace sda with your partition name.
# grub-install --recheck --force --target=i386-pc /dev/sda # grub-mkconfig -o /boot/grub/grub.cfg
At this point, I encountered the error Failed to connect to lvmetad. The is due to the lvmetad service that improves performance of LVM, the Logical Volume Manager (which manages disk drives and other mass-storage devices). We have to disable it by
# vi /etc/lvm/lvm.conf
and write use_lvmetad = 0 (instead of the original use_lvmetad = 1).
Setting a host name
Set the host name for the system by writing relevant configuration file. (Replace Host-Name with your host name.)
# echo "Host-Name" > /etc/hostname
Set the root’s password. You will be prompted to enter the password twice to confirm it.
# passwd
Leave the chroot-ed environment (which was set to the target partition), unmount that partition, and schedule shutdown (will wait for about two minutes).
# exit # umount -R /mnt # shutdown
Unplug the USB, which is no longer needed, and start the computer now. After reboot is done, when you login, login as root.
Internet connection
Assuming a wired connection is available, now we set up DHCP (Dynamic Host Configuration Protocol) that requests an IP address in the present ethernet.
# ip link
The output includes several items. The first one is, in my case,
1: lo:mtu 65536 qdisk noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
Start the DHCP service from now on, and whenever the system boots.
# systemctl start dhcpcd@_______.service # systemctl enable dhcpcd@_______.service
Replace the long underscore with the name of wired device just seen above. In my case, that is lo.
The method for obtaining wireless connection is not covered in this note; please see cited notes.
Creating the daily user’s account
Create the user account to be used on a daily basis. Add the ID into the wheel group, who has sudo privileges. (I heard an advice that one ought not give the daily user sudo privilege. I tried that on a Mac for a while, and that immediately appeared overly pedantic to me!)
# useradd -m -G wheel,users -s /bin/bash violapterin # passwd violapterin
Set the daily user’s password. Again, you will be prompted to enter the password twice to confirm it.
Download the sudo package so that we are able to perform the superuser-do feature.
# pacman -S sudo
Edit the sudoers file. (Use nano if you please.)
# EDITOR=vi visudo
Uncomment this line, by deleting # in front of them:
%wheel ALL=(ALL) ALL
Downloading all stable packages
Make stable repositories available to package manager pacman, by opening:
# vi /etc/pacman.conf
and uncomment these lines:
[multilib] Include = /etc/pacman.d/mirrorlist
Update pacman, and install all refreshed packages. -Syu means respectively: install packages, refresh database for packages, and look for existing outdated packages.
# sudo pacman –Syu
A comprehensive list of packages is provided here, classified according to usage. From now on, installing packages shall be straightforward.
Besides the official repository that pacman uses, there is another Arch User Repository maintained by community. Several counterparts to pacman (called helpers) exists, including yay, pakku, pikaur, and pacaur. Note that yaourt is deprecated, which may still exist in older guides. The flag -S means the same (i.e., installation).
Graphical interface
However, it remains to set up a desktop environment. To do so we install the X-server.
# pacman -S xorg-server # pacman -S xorg-server-utils
To learn which graphic card the current system is using, run
# lspci -v
And I see that my computer has an Intel GPU. (The output for your graphic cards may look different, but I assume it is easy enough to distinguish. See also cited notes.) In my case, I have to install
# pacman -S xf86-video-intel
See Desktop environment for a list of available desktops. To install KDE, for example, use
# pacman -S plasma
To install utilities that come with KDE, use
# pacman -S kde-applications
Again this will take quite a while, nearly thirty minutes in my case. (Another package called plasma-meta seems to be a superset of plasma, but I am not sure. Similar is said of kde-applications-meta and kde-applications.)
After that, configure .xinitrc that calls KDE on startup. First, log in as the daily user’s account, and write
# echo "exec startkde" > ~/.xinitrc
Note that .xinitrc must be saved in the daily user’s home in order to be found and read.
But even with this, KDE will only be started after startx command is run. To start KDE immediately after logged in, we need
# pacman -S xorg-xinit
And then put in ~/.bashrc
if [ -z "$DISPLAY" ] && [ -n "$XDG_VTNR" ] && [ "$XDG_VTNR" -eq 1 ]; then exec startx fi
Translated, this means that start the X server, if the display variable is not a null string, and if the virtual terminal number of the X desktop group is not empty indicates there is only one terminal instance.
This guide ends here, because, in the presence of a beautiful GUI, instead of the scary black-and-white console, the readers will surely figure out themselves how to download relevant packages, thanks to the working internet connection and the well-written Arch Linux Wiki.
References
Almost all information you need can be found here!
-
- Swapnil Bhartiya, Arch Linux Tutorial
Which I relied heavily in preparing this note.
-
- Wei-Hsun Lin (signed as thus), Arch Linux: 安裝系統
In Chinese.