Install Arch Linux from Scratch in Virtualbox

Table of Contents
- Preface
- Pre-install
- Disk Management
- Installing Arch Linux
- Important Configurations
- User Management
- Postrequisites
- Post-install
Preface
Arch Linux is a distribution designed to be installed and configured from the bottom up, and so has gained notoriety in the Linux circle as being the last or first thing to show to new Linux users depending on how you see it.
I will be installing Arch Linux to a Virtual Machine in Oracle Virtualbox. A pretty strong understanding of Linux and how it works helps out a ton, but isn’t necessarily required.
There are friendlier Arch-based distros out there but if you would want to install vanilla Arch without actually doing so, I would advise using Anarchy Installer or ArchFi.
This VM was created with 2048 MB of RAM, 2 Cores, and 20GB of storage. This VM will not be using an EFI BIOS for simplicity’s sake therefore it will be using MBR. Internet connectivity is required to install Arch Linux so make sure the host is already connected to internet via Wifi or Ethernet.
This was written by shamelessly plaigarizing from both the Arch Wiki Installation Guide and “Arch Linux: A ℂ𝕠𝕞𝕗𝕪 Install Guide” by Denshi.
Pre-install
Download whatever the latest .iso is available in archlinux.org/download, and boot off of that. Proceed into the install medium until you are greeted with a command prompt.
Load Keymap
Set the keyboard mapping to the desired keymap. The default is the US keyboard layout.
Search for the US keyboard layout.
localectl list-keymaps | grep -i US
Enter loadkeys command to the keymap determined.
`loadkeys us`
Connect to Internet
Make sure the Installation Medium is receiving internet connection via output from ping.
ping https://www.archlinux.org
Disk Management
Create Partitions
Partition the disk with the dos label via cfdisk.
cfdisk
For this particular setup, I will be creating 2 partitions: My root partition /dev/sda1 will take all but 1GB at the end of the disk, which is withheld for my 1GB swap partition as /dev/sda2. Refer on how to partition disks here.
Check disk partitions via lsblk.
lsblk -l
Format Partitions
Format the root partition to ext4.
mkfs.ext4 /dev/sda1
A swap partition will be formatted to swap.
mkswap /dev/sda2
Mount partitions
Mount the root partition to /mnt.
mount /dev/sda1 /mnt
Mount the swap partition via swapon.
swapon /dev/sda2
Installing Arch Linux
Installing Packages
pacstrap will install packages to Arch using the pacman package manager during installation. I will be installing the kernel, firmware, bootloader, internet, and a couple of system tools.
pacstrap /mnt base linux linux-firmware sof-firmware bash-completion grub nano networkmanager base-devel sudo
You may modify, remove, or add any packages at your discretion.
Generating fstab
Generate and save filesystem tab (fstab) for /mnt
genfstab /mnt > /mnt/etc/fstab
Confirm task done with cat /mnt/etc/fstab
Chroot to Arch
Enter the Arch Linux system by changing root.
arch-chroot /mnt
Important Configurations
Configure Time
List all available time zones with timedatectl list-timezones. I will be using the Manila timezone in Asia.
ln -sf /usr/share/zoneinfo/Asia/Manila /etc/localtime
Run hwclock to synchronize clocks
hwclock --systohc
Configure Locale
Edit locale gen
Open /etc/locale.gen in a text editor, in my case, nano, and uncomment the needed locales. I will uncomment the Philippine locale so that it could be determined.
nano /etc/locale.gen
Find the locale # en_PH.UTF-8 UTF-8
# en_PH.UTF-8 UTF-8
Then uncomment by removing the hash
en_PH.UTF-8 UTF-8
and run locale-gen to take effect.
locale-gen
Edit locale conf
Create a file /etc/locale.conf, edit it, and set the LANG variable to the locale.
touch /etc/locale.conf && echo "LANG=en_PH.UTF-8" > /etc/locale.conf
Edit vconsole conf
Create a file /etc/vconsole.conf, edit it, and add the keymap set the KEYMAP variable to what was determined at the beginning.
touch /etc/vconsole.conf && echo "KEYMAP=us" > /etc/vconsole.conf
Edit hostname
Create a file /etc/hostname, edit it, and enter the hostname for the VM. I’ll set the hostname to archu
touch /etc/hostname && echo "archu" > /etc/hostname
User Management
Set the password of an account with passwd set password for root by simply typing passwd.
password
Adding a User
Add a user with useradd. A home directory is created, the user is designated to the wheel group, the defaut shell is BASH, and the username is named nimu.
useradd -m -G wheel -s /bin/bash nimu
Set the password for the newly created user, nimu.
passwd nimu
Configuring Sudo
The wheel group is used as a flag of sort to allow the use of sudo commands. Set the EDITOR variable to nano and run visudo, which edits the sudoers file.
EDITOR=nano visudo
Find
# %wheel ALL=(ALL) NOPASSWD: ALL
and uncomment by removing the hash.
%wheel ALL=(ALL) NOPASSWD: ALL
Postrequisites
Enable Network Manager
Enable internet functionality by enabling networkmanager service. It is case-sensitive.
systemctl enable NetworkManager
Configuring GRUB
Install the GRUB bootloader to the disk via grub-install
grub-install /dev/sda
Create GRUB config file to /boot/grub/grub.cfg via grub-mkconfig
grub-mkconfig -o /boot/grub/grub.cfg
Post-install
At this point, Arch Linux is installed. Exit chroot.
exit
reboot or poweroff your system, then detach the installation medium and log in to Arch Linux. The Arch Linux install is successful if you are greeted with the GRUB menu screen, and are able to log in.