Setting up an Arch Linux VM in VirtualBox
About Arch Linux
There are many Linux distributions out there. Arch Linux is our choice. Start by reading a little bit about it:
Create a VM
- Download and install VirtualBox
- Also install Oracle VM VirtualBox Extension Pack
archlinux-YYYY.MM.DD-dual.isofrom Arch Linux Downloads page
- Verify the file integrity checksum
- Create a new VM in VirtualBox
Arch Linux (32 bit)
- RAM: 1 GB minimum, 2 GB recommend (or even more, if your host machine has 8 GB)
- Hard disk: 20 GB minimum, 50 GB or more recommended. Choose “Dynamically allocated” so that the virtual disk takes up only as much space as it is currently using. Choose “VDI (VirtualBox Disk Image)”.
- Boot the VM using the live CD image you downloaded.
Install Arch Linux
Once the VM boots successfully into the Arch Live CD image, you are ready to install Arch onto your virtual hard disk. Follow the Arch Linux Beginners’ Guide carefully step-by-step. You can start at Section 4, Change the language.
The Arch Linux Beginners’ Guide – we’ll call it the Guide from now on – is very detailed and comprehensive, but sometimes it’s a bit confusing. I have listed below some additional info and directions on some of the trickier sections of the Guide.
Note that what follows is NOT the whole instruction. They are clarifications and additional help on the Arch Linux Beginners’ Guide that you are supposed to follow.
- Establish an internet connection
Assuming you have an Internet connection on your host, your guest should have it as well. If ping works, skip the rest of this section and move on to the next one.
- Prepare the storage devices
This section is a bit long and unwieldy. Skim through the section to get an idea of what it’s talking about. Basically, you should come to an understanding of what a disk partition is.
Here is what you’ll actually do. First, create a single MBR partition which fills up the entire hard disk. We will use
Once you are in
parted(you know it because the prompt changes to
(parted)), run the following commands:
mklabel msdos mkpart primary ext4 0% 100% set 1 boot on print quit
First we select “msdos” partition type, which is another name for the MBR partition type. Then we create a “primary” partition which will fill up 100% of the disk, and indicate that we will later format it as an “ext4” file system type. We then make the partition bootable. Finally run the
If you paid attention to the
After creating the partition /dev/sda1, run the following command to format the partition as an
Note that we do not create a swap partition because a swap file can be added later if necessary.
Lastly, don’t forget to mount the new partition at
/mntto begin filling it up with an Arch Linux installation:
mount /dev/sda1 /mnt
- Select a mirror
You should put the Columbia University mirror site at the top of the list.
- Install the base system
Follow the Guide’s instruction.
- Generate an fstab
Follow the Guide’s instruction.
- Chroot and configure the base system
You should carefully follow all of the steps in this section to configure your new system. Here are some additional tips:
/etc/vconsole.conf, which will make the console look much nicer.
- For configuring the network, we follow “Wired / Dynamic IP” setup, which means that all you need to do is to run
systemctl enable dhcpcd.service. Note that the Guide adds “@interface_name” after dhcpcd. You don’t need to do that.
- For the subsection, Install and configure a bootloader, follow the Guide for the “For BIOS motherboards / GRUB” setup.
- Unmount the partitions and reboot
Don’t forget to eject the virtual CD-ROM (which was mapped to the archlinux-YYYY.MM.DD-dual.iso file), so that you will reboot into the newly installed Arch Linux, not the install CD again.
At this point, you have a minimally functional Arch Linux system. There are a few more things to do before you can use the system productively.
Before we begin, however, you must understand some basic concepts about Arch Linux. Please read the following short sections in theGeneral Recommendations page:
- Section 1: System administration
- Section 2: Package management
- Section 3: Graphical user interface
After you have read the sections, move on to the post-installation setup.
- User management
Pick a name for a non-root user and add the user. For example:
useradd -m -g users -s /bin/bash archie passwd archie
At this point, you can make the non-root user a “sudoer”. A sudoer can run a command as root by passing it through the
First, install sudo:
pacman -S sudo
Then, add the following lines to
/etc/sudoers(you can omit the comments of course, and replace archie with your user name):
# The basic structure of a user spec looks like this: # who where = (as_whom) how: what archie ALL=(ALL) NOPASSWD: ALL
- Package management
This is also a good time to install some essential packages:
pacman -S net-tools pkgfile base-devel
And perhaps your favorite editors:
pacman -S vim emacs
You can also try running a full system upgrade to see if any of your installed packages have new versions:
At this point, please take a snapshot of your VM from VirtualBox so that you can come back to this point if something goes wrong in the subsequent steps.
- Install a video driver
We will be installing VirtualBox Guest Additions later, but for now, install the
vesadriver by running
pacman -S xf86-video-vesa. This will let you test X window system when you don’t have VirtualBox Guest Additions installed yet.
- Choose and install a graphical interface
Linux offers a dizzying array of choices when it comes to graphical desktop environments. You can use whatever you like.
Xfce is what I use. Here is how to install it:
# first, install Xorg pacman -S xorg-server xorg-server-utils xorg-apps # install some good fonts pacman -S ttf-dejavu ttf-droid ttf-inconsolata # install Xfce pacman -S xfce4 xfce4-goodies
You can also install a GUI version of your editor and a web browser:
pacman -S gvim firefox
Before you start your Xfce4 desktop, log in as the non-root user. You can switch to the 2nd virtual console by pressing
Ctrl-Alt-F2. After you log in as a non-root user, you can type the following to start your Xfce4 desktop:
Install VirtualBox Guest Additions
Now you should install VirtualBox Guest Additions inside the VM. The Guest Additions will enable very useful features like dynamically resizing the VM window, copy & paste between guest and host, time sync between guest & host, and accessing the host file system from the guest.
- Install packages:
sudo pacman -S virtualbox-guest-utils sudo pacman -S virtualbox-guest-modules sudo pacman -S virtualbox-guest-modules-lts sudo pacman -S virtualbox-guest-dkms
/etc/modules-load.d/virtualbox.confwhich contains the following three lines:
vboxguest vboxsf vboxvideo
- In order to synchronize time with the host machine, type the following:
sudo systemctl enable vboxservice.service
- Enable “Bidirectional” Shared Clipboard from VirtualBox Manager’s Settings / General / Advanced menu.
- Reboot the VM and type
ps ax | grep -i vbox. You should see an output like this:
139 ? Ssl 0:00 /usr/bin/VBoxService -f 402 ? Sl 0:00 /usr/bin/VBoxClient --clipboard 414 ? Sl 0:00 /usr/bin/VBoxClient --display 420 ? Sl 0:00 /usr/bin/VBoxClient --seamless 425 ? Sl 0:00 /usr/bin/VBoxClient --draganddrop
Try copy & paste between host and guest.
You can look through Arch’s documentation on VirtualBox for more detailed info.
Switch to Linux LTS kernel
The stock kernel of Arch Linux stays pretty close to the bleeding edge, so it gets updated very frequently. Arch offers a more stable alternative based on a kernel version designated as a Long-Term Support (LTS) version. The
linux package in Arch is the stock kernel and the
linux-lts package is the LTS kernel. We are going to use the LTS kernel.
- Install the LTS kernel packages.
sudo pacman -S linux-lts linux-lts-headers
- Before we update the boot menu to include the new kernel, let’s tweak the settings of GRUB (our bootloader) by modifying
First, you will find
GRUB_DEFAULT=0at the top of the file. Change it to:
so that GRUB will remember the last kernel you boosted from and make it the default entry next time you boot. Then you also need to add the following lines at the end of the file:
Optionally, while you’re editing this file, you can make your virtual console – the text-based command line before you start Xfce – a little bigger. Change
And make sure the following line is there and not commented out:
Also uncomment the following lines to have the menu screen in color:
- After you modified
/etc/default/grub, regenerate the GRUB configuration by running:
sudo grub-mkconfig -o /boot/grub/grub.cfg
- Verify that the new kernel works correctly:
uname -rto see the current kernel version you’re running
- Reboot into the new LTS kernel
uname -ragain to see the new LTS kernel version.
Fix broken VirtualBox guest modules for LTS
As of 1/19/2015, the
virtualbox-guest-modules-lts package – which provides the binary files of VirtualBox guest modules compiled for the current LTS kernel – is broken. This is why when you boot into the LTS kernel, resizing your Linux desktop stops working. (Skip this section if this is not the case – the bug might have been fixed by the time you’re reading this.)
Follow the steps below to fix it for now.
sudo pacman -R virtualbox-guest-modules-lts sudo pacman -S virtualbox-guest-dkms
Observe the output on screen. Towards the end, it says “To build and install your modules run:”. Run that command. It’s most likely this:
sudo dkms install vboxguest/4.3.20
Some recommended UI improvements
- Better terminal font
Install the Terminus font, which makes a very nice terminal font:
pacman -S terminus-font
Terminus is my favorite font for terminals because I hate anti-aliased fonts (i.e. fonts with shadows) on my terminal windows. If you don’t mind it, the Inconsolata fonts we installed previously is pretty awesome too.
- Customize your environment
The following ArchWiki pages have tons of tips on how to customize your working environment. (But be careful. You can spend infinite amount of time tweaking your working environment instead of, um, actually working.)
Congratulations! You have successfully installed and configured an Arch Linux system. Hopefully this is the beginning of a long-term relationship between Linux and you.
Last updated: 2015–01–19