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

  1. Download and install VirtualBox

  2. Download archlinux-YYYY.MM.DD-dual.iso from Arch Linux Downloads page

  3. Create a new VM in VirtualBox

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 Installation guide carefully step-by-step.

The Arch Linux Installation guide – we’ll call it the Guide from now on – is 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 Installation guide that you are supposed to follow.

Required reading

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 the General Recommendations page:

After you have read the sections, move on to the post-installation setup.

Post-installation setup

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.

  1. Install packages:

    sudo pacman -S virtualbox-guest-utils
    sudo pacman -S linux-headers
    sudo pacman -S virtualbox-guest-dkms
    
  2. In order to load the VirtualBox kernel modules and synchronize time with the host machine, type the following:

    sudo systemctl enable vboxservice.service
    
  3. Enable “Bidirectional” Shared Clipboard from VirtualBox Manager’s Settings / General / Advanced menu.

  4. Reboot the VM, start your Xfce4 desktop (or whatever desktop environment you’re using), launch a terminal window, and type ps ax | grep -i vbox. You should see an output like this:

    154 ?        S<     0:00 [iprt-VBoxWQueue]
    197 ?        Ssl    0:00 /usr/bin/VBoxService -f
    392 ?        S      0:00 /usr/bin/VBoxClient --clipboard
    393 ?        Sl     0:00 /usr/bin/VBoxClient --clipboard
    401 ?        S      0:00 /usr/bin/VBoxClient --display
    402 ?        S      0:00 /usr/bin/VBoxClient --display
    409 ?        S      0:00 /usr/bin/VBoxClient --seamless
    410 ?        Sl     0:00 /usr/bin/VBoxClient --seamless
    415 ?        S      0:00 /usr/bin/VBoxClient --draganddrop
    416 ?        Sl     0:00 /usr/bin/VBoxClient --draganddrop
    531 pts/0    S+     0:00 grep -i vbox
    

    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.

  1. Install the LTS kernel packages.

    sudo pacman -S linux-lts linux-lts-headers 
    
  2. Before we update the boot menu to include the new kernel, let’s tweak the settings of GRUB (our bootloader) by modifying /etc/default/grub.

    First, you will find GRUB_DEFAULT=0 at the top of the file. Change it to:

    GRUB_DEFAULT=saved
    

    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:

    GRUB_SAVEDEFAULT=true
    GRUB_DISABLE_SUBMENU=y
    

    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 GRUB_GFXMODE=auto to:

    GRUB_GFXMODE=1024x768x32
    

    And make sure the following line is there and not commented out:

    GRUB_GFXPAYLOAD_LINUX=keep
    

    Also uncomment the following lines to have the menu screen in color:

    GRUB_COLOR_NORMAL="light-blue/black"
    GRUB_COLOR_HIGHLIGHT="light-cyan/blue"
    
  3. After you modified /etc/default/grub, regenerate the GRUB configuration by running:

    sudo grub-mkconfig -o /boot/grub/grub.cfg
    
  4. Verify that the new kernel works correctly:

    1. Type uname -r to see the current kernel version you’re running
    2. Reboot into the new LTS kernel
    3. Type uname -r again to see the new LTS kernel version.

Some recommended UI improvements

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: 2017–01–16