Arch is a flexible Linux distribution. It is updated frequently and works on a rolling release. It is setup and configured with only the software wanted, either simple or complex. However, this doesn’t come without some negatives. The flexibility to only install the software needed, requires the user to actual learn how to install and configure. It is on the “bleeding edge,” so sometimes updates can cause issues with a specific configuration. Needless to say, if you are afraid of the command line or don’t want to dig into all the details, this isn’t the distro for you.
The first step is to download an official ISO of Arch Linux from here. Scroll down to the list of mirror sites, select one, and download the appropriate version for your hardware \ virtual environment. Using older, previously download ISOs, may result in signature issues during installation, so it is best to download the latest version.
The following instructions are for a minimalistic Arch Linux installation on a Windows Hyper-V virtual machine. Note that this instructions will work on bare hardware – just omit the installation and setup of the Hyper-V integration services. In fact, unless those services are desired, they are not needed even on a Hyper-V VM. See here for configuring Hyper-V for hosting a Linux VM.
System Hardware
In this example the general configuration is:
- UEFI boot
- Swap file instead of a swap partition
- (2) Hard disks – 1 for the system and 1 for the home directory, partitioned as follows (see here for partition considerations)
- /dev/sda1 –> /boot/EFI
- /dev/sda2 –> /boot
- /dev/sda3 –> /
- /dev/sda4 –> /var
- /dev/sdb1 –> /home
Although the disks can be partitioned using the tools that are part of the live ISO, I prefer to use a GParted live ISO, which can be downloaded here. Mount the GParted ISO on the virtual DVD, boot the VM, and create and format the partitions. See here for GParted instructions.
Preparation
Mount the Arch Linux ISO and boot the system.
Since the installation from the live ISO requires downloading the components from the Arch Linux repositories, first ensure that the internet connection is operational.
root@archiso ~ # ping archlinux.org
To avoid any potential errors when verifying the signatures from the mirrors, turn on network time protocol.
root@archiso ~ # timedatectl set-ntp true
root@archiso ~ # timedatectl status
Mount the Partitions (see the partition mapping above)
Note that when creating different mounts for subdirectories, the upper level directories must be created and mounted before the subdirectories. In this example, /boot must be created and mounted before /boot/EFI.
root@archiso ~ # mount /dev/sda3 /mnt
root@archiso ~ # mkdir /mnt/boot
root@archiso ~ # mount /dev/sda2 /mnt/boot
root@archiso ~ # mkdir /mnt/boot/EFI
root@archiso ~ # mount /dev/sda1 /mnt/boot/EFI
root@archiso ~ # mkdir /mnt/var
root@archiso ~ # mount /dev/sda4 /mnt/var
root@archiso ~ # mkdir /mnt/home
root@archiso ~ # mount /dev/sdb1 /mnt/home
Create & Activate the Swap File
As the /var directory is for variable files and is expected to have frequent reads\writes, this is where I typically located the swap file.
root@archiso ~ # fallocate -l 4GB /mnt/var/swapfile
root@archiso ~ # mkswap /mnt/var/swapfile
root@archiso ~ # chmod 600 /mnt/var/swapfile
root@archiso ~ # swapon /mnt/var/swapfile
Install Base Arch Linux
Install the base Arch Linux system and associated packages. The following is a list of the core packages. Nano is not needed for a functioning installation (or if a graphical desktop will be installed), but I prefer it to vi for a command-line or tilling window manager setup. However, there are times when vi is useful, so I install both.
- base: Minimal package set to define a basic Arch Linux installation.
- linux: The current stable Linux kernel for Arch Linux.
- linux-firmware: Firmware files for Arch Linux
- linux-docs: Documentation for the Linux kernel.
- vi: The original ex/vi text editor.
- nano: Pico editor clone with enhancements.
After the drives have been mounted, the swapfile created, and the base OS is deployed, generate the File System Table.
root@archiso ~ # pacstrap /mnt base linux linux-firmware linux-docs vi nano
root@archiso ~ # genfstab -U /mnt >> /mnt/etc/fstab
Change the apparent root to install additional components and configure
root@archiso ~ # arch-chroot /mnt
Install and Enable Hyper-V Integration Services [optional]
While not necessary, the following are the minimal elements needed to use Hyper-V integration services.
- hv_fcopy_daemon: Implements a file copying service between the host and the guest
- hv_kvp_daemon: Allows setting and querying intrinsic and extrinsic key value pairs
- hv_vss_daemon: Required to create live Linux machine backups
[root@archiso /]# pacman -Syu hyperv
[root@archiso /]# systemctl enable hv_fcopy_daemon
[root@archiso /]# systemctl enable hv_kvp_daemon
[root@archiso /]# systemctl enable hv_vss_daemon
See here for more options for utilizing Hyper-V integration services.
Install and Configure the GRand Unified Bootloader
GRUB is a boot manager and boot loader (loads the operating system kernel into memory).
- efibootmgr: Linux user-space application to modify the EFI Boot Manager
- os-prober: Utility to detect other OSes on a set of drives
- grub: GNU GRand Unified Bootloader
[root@archiso /]# pacman -Syu efibootmgr os-prober grub
[root@archiso /]# grub-install /dev/sda1
For VM setups and depending on the intent of the installation, I will adjust the screen resolution from the bootloader. For instance, on a 1920 x 1080 screen, 1900 x 930 fill the monitor with room for the window borders. To do this, edit the grub file and add a video parameter to the linux default command line.
[root@archiso /]# nano /etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT=”loglevel=3 quiet video=1900×930”
Finally, make the grub configuration.
[root@archiso /]# grub-mkconfig -o /boot/grub/grub.cfg
Install & Configure Reflector
Reflector retrieves the latest mirror list from the Arch Linux Mirror Status page and is used to optimize the retrieval of standard packages. As I am located in the US, I set it up to look at mirrors in the United States and Canada. In addition, I filter the list to the 25 mirrors with the latest versions and sort them by the fastest connection. This requires editing the reflector configuration file.
- Install reflector
- Edit the reflector configuration
- Update the reflector list
- Enable the reflector service
[root@archiso /]# pacman -Syu reflector
[root@archiso /]# nano /etc/xdg/reflector/reflector.conf
–save /etc/pacmand.d/mirrorlist
–protocol https
–country ‘United States’, Canada
–latest 25
–sort rate
[root@archiso /]# reflector
[root@archiso /]# systemctl enable reflector.timer
Configure Localization
Link to the appropriate zone information file (New York shown as an example).
[root@archiso /]# ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime
To set the locale, write the LANG variable to /etc/locale.conf. For American English use en_US.UTF-8.
[root@archiso /]# nano /etc/locale.conf
LANG=en_US.UTF-8
Before a locale can be enabled on the system, it must be generated. Do this by uncommenting the applicable entries in /etc/locale.gen
and running locale-gen. For example, uncomment en_US.UTF-8 UTF-8
for American-English.
[root@archiso /]# nano /etc/locale.gen
[root@archiso /]# locale-gen
Network Setup
Create the hostname file and enter a name for the system.
[root@archiso /]# nano /etc/hostname
<host name>
Create the hosts file to setup basic networking.
[root@archiso /]# nano /etc/hosts
127.0.0.1 localhost
::1 localhost
127.0.1.1 <domain name> <host name>
Configure Networking
The systemd netwrokd service operates from the .network files located in /etc/systemd/network, as well as /usr/lib/systemd/network, /usr/local/systemd/network, and /run/systemd/network . The naming convention for these files is [priority]-[interface].network. These files are processed in alphanumeric order regardless of their location. It is recommended that the user configured files in /etc/systemd/network have a prefix smaller than 70 so the default files do not take precedence.
[root@archiso /]# nano /etc/systemd/network/69-eth0.network
If the system is going to use DHCP, then enter the following into the file.
[Match]
Name=eth0
[Network]
DHCP=yes
If a static IP address is to be used, then enter the following into the file (replacing the address, gateway, and DNS values). Note that 1 or more DNS servers can be configured.
[Match]
Name=eth0
[Network]
Address=192.168.1.2/16
Gateway=192.168.1.1
DNS=1.1.1.1
DNS=1.0.0.1
Then enable the systemd networkd and resolved services.
[root@archiso /]# systemctl enable systemd-networkd
[root@archiso /]# systemctl enable systemd-resolved
Set Root Password
Since the root user has complete and absolute rights to everything, it is best practice to set a password for the the root user.
[root@archiso /]# passwd
Create user(s) and\or a local administrator
It is generally bad practice to use the root account as the primary daily user. Because it has complete and absolute rights to everything, a simple typo can wipe out you system. Plus if the system is compromised with that account, the hacker has full control of the system. So at least 1 user account should be created.
- Install sudo (Super User DO – which allows delegation of system administrative authority).
- Create a user and make them part of the wheel group so they can use sudo.
- Assign the user a password.
- Edit the configuration file to grant access to members of the wheel group to use sudo.
[root@archiso /]# pacman -Syu sudo
[root@archiso /]# useradd -m -G wheel <username>
[root@archiso /]# passwd <username>
[root@archiso /]# nano /etc/sudoers
##Uncomment to allow members of group wheel to execute any command
%wheel ALL=(ALL:ALL) ALL
In most cases, login (or display) managers don’t allow users with low UIDs to login in. That means that the root user (UID=0) will not be able to login in. In order for a root like user (can use sudo without having to enter a password each time) to be able to login, create and admin account and make them part of the root group. Then edit the /etc/sudoers file to llow the root group to execute commands without a password.
[root@archiso /]# useradd -m -G root admin
[root@archiso /]# passwd admin
[root@archiso /]# nano /etc/sudoers
## Same thing without a password
%root ALL=(ALL:ALL) NOPASSWD: ALL
Install Midnight Commander [optional]
Midnight Commander is a 2-pane file manager with internal viewer, editor, and comparer. I find it very useful on a command-line only system.
[root@archiso /]# pacman -Syu mc
Finish Up
The lasts steps are to exit the apparent root and reboot the system.
[root@archiso /]# exit
[root@archiso /]# shutdown now -r
When the system reboots, login and set the network time protocol (this cannot be done in the chroot, so it has to be done after the restart).
[root@arch ~]# sudo timedatectl set-ntp true
Your Arch Linux system is ready to go for further software and customization. Enjoy!
References
Arch Linux Installation Guide (archlinux.org)
Arch Linux Wiki (archlinux.org)
Arch Linux Hyper-V (archlinux.org)
Arch Linux systemd network Manual Page (archlinux.org)
Manage Hyper-V Integration Services (Microsoft.com)