How to Install Arch Linux in a Virtual Machine (VM)

How to Install Arch Linux in a Virtual Machine (VM)

Installing Arch Linux in a virtual machine (VM) is a great way to learn and experiment with this lightweight, flexible distribution without affecting your main system. While Arch is known for its DIY approach, its installation process provides deep insight into how Linux systems work. In this guide, we’ll walk through the entire process of installing Arch Linux in a VM—from downloading the ISO to having a fully functional system with a basic desktop environment.


Prerequisites

Before we begin, make sure you have the following:

  • A computer with virtualization support (Intel VT-x or AMD-V)
  • A virtualization tool installed, such as:
    • VirtualBox (Free and open-source)
    • VMware Workstation Player (Free for non-commercial use)
  • The latest Arch Linux ISO, available from the official website: https://archlinux.org/download/

We’ll use VirtualBox for this tutorial, but the process is largely similar across virtualization platforms.


Step 1: Create a New Virtual Machine

1. Launch VirtualBox

Open VirtualBox and click on “New” to start creating a virtual machine.

2. Configure Basic Settings

  • Name: Arch Linux
  • Type: Linux
  • Version: Arch Linux (64-bit)

Click Next.

3. Allocate Memory (RAM)

Allocate at least 2048 MB (2 GB). For better performance, 4096 MB or more is recommended.

4. Create a Virtual Hard Disk

  • Choose “Create a virtual hard disk now”
  • Disk size: Minimum 10 GB (recommended 20 GB+ for desktop environments)
  • Disk type: VDI (VirtualBox Disk Image)
  • Storage: Dynamically allocated (saves space on your host system)

Step 2: Load the Arch ISO and Boot

1. Mount the Arch Linux ISO

  • Select your new VM in the VirtualBox list.
  • Click Settings → Storage.
  • Under “Controller: IDE”, click the empty CD icon.
  • Click the CD icon next to “Optical Drive” and select “Choose a disk file”.
  • Load the downloaded Arch Linux ISO.

2. Start the Virtual Machine

Click Start, and the VM will boot into the Arch ISO.


Step 3: Set Up the Arch Linux Environment

Once booted, you’ll see a shell prompt like this:

root@archiso ~ #

You’re now in a live environment, ready to install Arch Linux.


Step 4: Configure the Internet Connection

1. Check Network Connectivity

For most VMs, DHCP is enabled by default.

Test connectivity:

ping archlinux.org

If you get responses, the network is working. If not, you may need to troubleshoot network settings in VirtualBox (ensure the VM uses NAT or Bridged Adapter).


Step 5: Partition the Disk

We’ll use cfdisk for a user-friendly terminal interface.

cfdisk

Choose the disk (usually /dev/sda) and create the following partitions:

  • EFI System Partition (ESP): 512MB, type: EFI System
  • Linux Filesystem: Remaining space

After creating partitions, write the changes and exit.


Step 6: Format and Mount Partitions

Assuming:

  • EFI: /dev/sda1
  • Root: /dev/sda2
mkfs.fat -F32 /dev/sda1      # Format EFI partition
mkfs.ext4 /dev/sda2          # Format root partition

mount /dev/sda2 /mnt         # Mount root
mkdir /mnt/boot
mkdir /mnt/boot/efi
mount /dev/sda1 /mnt/boot/efi

Step 7: Install Base System

Install essential packages:

pacstrap -K /mnt base linux linux-firmware vim nano networkmanager grub efibootmgr

Note: You can add other packages such as sudo, git, or base-devel as needed.


Step 8: Generate fstab

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

Check the contents:

cat /mnt/etc/fstab

Step 9: Chroot Into the Installed System

arch-chroot /mnt

Step 10: Configure System Settings

1. Set Timezone

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

Example:

ln -sf /usr/share/zoneinfo/Europe/Berlin /etc/localtime

2. Set Locale

Edit /etc/locale.gen:

nano /etc/locale.gen

Uncomment your locale (e.g., en_US.UTF-8 UTF-8), then run:

locale-gen

Create locale.conf:

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

3. Set Hostname

echo "archvm" > /etc/hostname

Edit /etc/hosts:

nano /etc/hosts

Add the following lines:

127.0.0.1   localhost
::1         localhost
127.0.1.1   archvm.localdomain archvm

4. Set Root Password

passwd

Step 11: Install Bootloader (GRUB)

Install GRUB for UEFI:

grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=GRUB
grub-mkconfig -o /boot/grub/grub.cfg

Step 12: Enable Networking

systemctl enable NetworkManager

Step 13: Exit and Reboot

exit
umount -R /mnt
reboot

Don’t forget to remove the ISO from the virtual CD drive in VirtualBox before rebooting.


Step 14: Log Into Your New Arch Installation

After rebooting, you’ll see a GRUB menu, then the login prompt. Log in as root using the password you set.


Optional: Create a New User

useradd -m -G wheel yourusername
passwd yourusername

Enable sudo for wheel group:

nano /etc/sudoers

Uncomment:

%wheel ALL=(ALL:ALL) ALL

Optional: Install a Desktop Environment

You can install a lightweight desktop environment like Xfce, GNOME, or Plasma.

Here’s an example with Xfce:

pacman -S xorg xorg-server xfce4 xfce4-goodies lightdm lightdm-gtk-greeter
systemctl enable lightdm

For GNOME:

pacman -S gnome gnome-extra gdm
systemctl enable gdm

For Plasma (KDE):

pacman -S plasma kde-applications sddm
systemctl enable sddm

Then reboot:

reboot

Now your Arch VM should boot into a full graphical desktop environment.


Final Thoughts

Installing Arch Linux in a virtual machine is not just an exercise in patience—it’s a powerful way to understand the Linux system from the ground up. While distributions like Ubuntu or Fedora handle most configuration automatically, Arch gives you full control and transparency.

This guide has taken you from creating a VM to setting up a usable desktop environment. From here, you can:

  • Customize your Arch installation
  • Try window managers like i3 or Hyprland
  • Explore the AUR using tools like yay
  • Learn system administration by configuring services manually

Because it’s a virtual machine, you’re free to experiment without fear of damaging your main system.