Setup an Arch Linux VirtualBox

The following includes complementary steps when installing Arch Linux inside a VirtualBox instance.

Steps

Downloading Arch

Download the most recent Arch Linux image and signature:

Arch Linux Downloads https://archlinux.org/download/

Verify the downloaded image using:

gpg --verify <sig-file>

Prepare Virtual Machine

Create a new virtual machine inside VirtualBox to run Arch. This guide assumes working with a large disk allocated (e.g. 400+GB). Consider the the following notables when creating/configuring this virtual machine:

  • General

    • Advanced

      • Shared Clipboard: Bidirectional

  • System

    • Motherboard

      • Base Memory: 10GB+

    • Processor

      • Processors: All physical cores (green)

      • Extended Features:

        • Enable PAE/NX: Checked

  • Display

    • Screen

      • Video Memory: Maximum

      • Graphics Controller: VMSVGA

      • Extended Features:

        • Enable 3D Acceleration: Unchecked

  • Network

    • Adapter 1

      • Attached to: Bridged Adapter

    • Adapter 2

      • Attached to: Host-only Adapter

  • Shared Folders

    • Create a path to desired working directory.

Before starting the machine, attach the downloaded Arch ISO.

Starting Arch Install

Start the Arch image and wait until a terminal session is available.

If the font size is too small, increase the size by using:

setfont ter-118b

Partitions

First step is to prepare the attached disk using cfdisk utility:

cfdisk

This will open up a TUI. Select the following options:

  • Initialize disk as GPT.

  • Create the following new partitions:

    • BIOS Boot: 1MB

    • Linux Swap: 6GB

    • Linux File System: (remaining)

  • Ensure the write option is selected with a confirmation of yes.

  • Gracefully quit the application.

After changing the partitions, verify they have been created with fdisk:

fdisk -l

Create and attach the swap area:

mkswap /dev/sda2
swapon /dev/sda2

Prepare the system’s primary file system:

mkfs.ext4 /dev/sda3

Build new system

Mount the primary file system onto /mnt:

mount /dev/sda3 /mnt

Create a new system installation:

pacstrap -K /mnt base linux-lts linux-firmware linux-lts-headers \
    curl dhcpcd grub networkmanager vim wget

With the initial file system prepared, configure mounts to use when the system starts up:

genfstab -U /mnt >> /mnt/etc/fstab
cat /mnt/etc/fstab

chroot on the mount path to perform final installation steps:

arch-chroot /mnt

Configure a local timezone:

ln -sf /usr/share/zoneinfo/Region/City /etc/localtime

Prepare locale by enabling UTF-8 inside locale.gen, then generating the locale:

vim /etc/locale.gen
locale-gen

Install/configure GRUB2:

grub-install --target=i386-pc /dev/sda
grub-mkconfig -o /boot/grub/grub.cfg

Create a new administrator user:

useradd -m -G wheel <username>

Exit chroot, unmount and reboot:

exit
umount /mnt
reboot

Post-install

Login with the newly created user and start a DHCP network client:

dhcpcd

Verify an expected IP using:

ip link

Note

Users in proxy environments may need to configure their proxies now to ensure resources can be fetched from online.

(optional) Use reflector to configure an optimal mirror list:

reflector --country '<country-name>' --verbose --latest 5 --sort rate \
    --save /etc/pacman.d/mirrorlist --ipv4 --protocol https

Ensure the system is updated with the most recent versions for packages:

sudo pacman -Syu

Install the following packages:

sudo pacman -S \
    bc \
    cpio \
    docker \
    docker-buildx \
    docker-compose \
    g++ \
    gnome-control-center \
    htop \
    kdb \
    less \
    patch \
    pkg-config \
    python-build \
    python-tox \
    rsync \
    shellcheck \
    terminator \
    tk \
    virtualbox-guest-utils \
    which

Configure a vi alias for vim:

sudo ln -s /usr/bin/vim /usr/bin/vi

Configure the user to have access to Docker and VirtualBox shared paths:

sudo usermod -a -G docker <username>
sudo usermod -a -G vboxsf <username>

Configure various services to startup on boot:

sudo systemctl enable NetworkManager
sudo systemctl enable docker
sudo systemctl enable gdm
sudo systemctl enable vboxservice

Configure Git options:

git config --global user.name "<name>"
git config --global user.email "<email>"

Reboot:

sudo reboot

This virtual machine should now be in a good state.