“There’s no more trusted observer than someone who suspects you.” – Sora (No Game No Life)

Arch Linux VirtualBox Install

Updated February 20, 2022 • Published November 7, 2021
4 minutes read • By MarsRon

Arch Linux is a Linux distribution that is popular among Linux users. “I use Arch btw.” is what you always hear from Arch Linux users. Today I’ll show you how I installed Arch Linux inside VirtualBox from a Windows machine. If you have any suggestions feel free to contact me at https://marsron.ml/contact.

The target installation is Arch Linux with no desktop environment/window manager, just a minimal install plus a SSH server.


Download and install VirtualBox.

Download a ArchLinux ISO file from the official website.

Creating a virtual machine

Open up VirtualBox and create a new machine.

Creating a new virtual machine in VirtualBox

Switch into Expert Mode.

Select Expert Mode when creating a new machine

I named it arch-linux, and set the Machine Folder option to my D drive because I have more free space on it. Make sure that Type and Version are set to Linux and Arch Linux (64-bit). I’ve set the memory to 2GB (2048MB) because that’s all I can afford, give it more RAM if possible. Don’t forget to select “Create a virtual hard disk now”. Now, click “Create” and it’s time to setup the virtual hard drive.

Configure options for new machine

For the disk size, 8GB is enough, but I’ll choose 16GB because why not? Afterwards just click “Create” and the VM is ready for a Arch Linux install.

Configure disk options

Booting into the virtual machine

Now, I need to mount the ISO file that I downloaded just now. Select the VM from the list and click on Settings.

Open virtual machine settings

Go to the Settings tab. Select “Empty” under “Controller”. Then, select “Choose a disk file…” as shown in the image below. Now navigate through your files and select the ISO file. Click “OK” and it’s ready to boot.

Mount Arch Linux ISO file to the virtual machine

Now, click “Start” to start the VM.

Arch Linux boot menu

This menu will pop up, just hit Enter to select the default option.

Installing Arch Linux

Now that I have a terminal to work with I don’t need to constantly screenshot lmao. Anyways, I’m mostly just following the Installation guide from ArchWiki. The following are the commands I used to set up the VM.

Update system clock

Use timedatectl to ensure the system clock is accurate:

$ timedatectl set-ntp true

Partitioning the disk

As suggested by the ArchWiki, I’m going for 1GB as swap partition and the remainder as root partition.

Mount pointPartitionTypeSize
[SWAP]/dev/sda1Linux Swap1GB
/mnt/dev/sda2LinuxRemainder of disk
$ fdisk /dev/sda

These are what I entered to fdisk if you are wondering:

# Add swap partition
n # Add new partition
e # Extended partition type
*blank* # Partition number: 1 (default)
*blank* # First sector: 2048 (default)
+1G # Last sector: 1GB from first sector
t # Change partition type
82 # Hex code for Linux swap / Solaris

# Add root partition
n # Add new partition
p # Primary partition type
*blank* # Partition number: 2 (default)
*blank* # First sector: default
*blank* # Last sector: use rest the entire disk
a # Make partition bootable
2 # Select root partition

w # Finally save and quit

Formatting the partitions

Here I’m formatting the partitions with a file system.

$ mkfs.ext4 /dev/sda2 # root partition
$ mkswap /dev/sda1 # swap partition

Mounting the partitions

I’m mounting the partitions so I can actually read and write to them.

$ mount /dev/sda2
$ swapon /dev/sda1

Cool, now I have a partitioned disk to install Arch Linux on. But before that I have to select mirror servers for pacman.

Select pacman mirrors using reflector

Since I’m closest to Singapore, I’ll use the mirrors from Singapore.

$ reflector --verbose -c "Singapore" -l 200 -n 20 -p https,http --sort rate --save /etc/pacman.d/mirrorlist

Install essential packages using pacstrap

After that’s done, I can now install essential packages plus some additional packages to the installation. I’ve also added grub, nano, dhcpcd, sudo, openssh and neofetch, because I’ll need them in the final installation.

$ pacstrap /mnt base linux grub nano dhcpcd sudo openssh neofetch

Now I have a Arch Linux installation ready, but I still need to set up a few stuff here and there.

Configure Arch Linux installation

First, I’ll generate a fstab file and put it inside the installation.

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

Then chroot (change root) into the installation.

$ arch-chroot /mnt

And set the timezone:

$ ln -sf /usr/share/zoneinfo/Malaysia/Kuala_Lumpur /etc/localtime
$ hwclock --systohc

As for locale, I’ll edit /etc/locale.gen and uncomment en_US.UTF-8 UTF-8, then run the following commands:

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

Now, the hostname of the installation.

$ echo "arch-linux" > /etc/hostname

I’ll also set the root account’s password.

$ passwd

Since Arch Linux doesn’t include DHCP by default, I’ll configure it to start on boot here.

$ systemctl enable dhcpcd.service

And finally, I’ll install GRUB to the system.

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

Cool, now the installation is fully configured. Now enter the following commands to exit chroot, unmount the disk and shutdown.

$ exit
$ umount -R /mnt
$ shutdown now

Now, open the Settings tab of the VM from VirtualBox, and remove the ISO file. Just undoing what I did before.

Remove ISO file from virtual machine

Finally, woooh, I can now boot into the new Arch Linux installation!

Enjoying Arch Linux

Start the virtual machine and select the first boot option from GRUB. Login as root and enter the password.

Wow poggers wooooo! Arch Linux is installed, now can I confidently say “I use Arch btw” to anyone and everyone I come across muahaAHAHAHA. Now run neofetch and flex on everybody!

Creating normal user account

For now, there’s only root on this system, and I want to use a normal user account. So, I’ll create a user with access to sudo, called marsron by running the following commands.

$ useradd -m -G wheel marsron
$ passwd marsron

But for sudo to work correctly, there’s something that needs to be changed in the sudoers file. You should always use visudo to run this command instead of a normal text editor. Run the following command, then find and uncomment %wheel ALL=(ALL) ALL.

$ EDITOR=nano visudo

Now type exit or press CTRL+D to return to the login screen, and login using the new user.

Running OpenSSH server

Since I initially want to SSH into this VM, I’ll set up a OpenSSH server. I’ve already installed openssh using pacstrap, so I don’t need to install it now.

$ sudo systemctl enable sshd
$ sudo systemctl start sshd

Now the server is running, but the VM is inside a NAT and I can’t access it. So how? I followed this straightforward blog to fix the problem, and now I can access the VM from my Windows machine.

P.S. I’m just too lazy to do a bunch of screenshots again.

Final Arch Linux flexing

Ubuntu peasants, I’m coming MUAHAHAHA.

Neofetch of the Arch Linux installation

Hope this article helped, probably didn’t though lol. Have a great day/night flexing Arch Linux on your friends!

Also if you have anything that you as a Arch Linux master think is wrong or not suggested, feel free to contact me.

← Back to blogs

© MarsRon 2021-2022