June 10, 2020

How I use Linux desktop at work - Part3 - Guest additions

Part 3 of the series How I use Linux desktop at work

Just to recap, this series is describing how I leverage vagrant and VirtualBox to provision development VM on my work PCs. I’m also taking the opportunity to build them from scratch with the tools I use at home.

Previous posts:

  1. part1 - Basic setup

  2. part2 - X, and WM

In the post, I’ll cover:

  1. reasons why I ended up compiling the guest additions

  2. installing required tools

  3. mounting drive

  4. building guest additions

  5. automating the whole thing

The end result will make the X guest screen resize to the host window size.

Steps 1-4 are describing the manual process while step 5 describe how I automated this in the Vagrantfile.

Note: You can find the sources created during this post in my github devbox-arch repository.


During part 2, I spent most of my time trying to get X guest screen to resize automatically. I tried many things like, installing the dkms package, downgrading my virtualBox to the exact version of guest additions available in arch. All of this time without positive results.

Let me know if you know how to solve it without building guest additions.

Installing tools

guest additions needs which, gcc, perl, linux-headers packages in order to be compiled.

you can do so by running these commands.

pacman -S which perl gcc linux-headers

Mounting drive

From the devices menu, select the ``insert guest additions CD…'' which is the equivalent of inserting the CD in the virtualdrive

Now mount this ISO to the /mnt mount point

mount /dev/sr0 /mnt

Building guest additions

Now you just need to go to the /mnt path and run the installer:

cd /mnt

Accept the installation.

Then reboot and voila!

Automating the whole thing

Now, we do not want to do this manually every time, lets automate this.

This comes in two parts:

  1. binding the ISO to the DVD drive

  2. mounting and building

Binding the ISO to the DVD drive

Now automating binding of the ISO is fairly easy with vagrant. You just have to use the modifyvm to create a CD drive and tell to ``put'' the ISO file in the drive:

vb.customize ['storageattach', :id, '--storagectl', 'IDE Controller', '--device', 1, '--port', 1, '--type', 'dvddrive', '--medium', 'C:\Program Files\Oracle\Virtualbox\VBoxGuestAdditions.iso']

Mounting and building

Like I described in part 2, we will update the ``2-core.sh'' script to build the guest additions.

mount /dev/sr0 /mnt && cd /mnt && ./VBoxLinuxAdditions.run -- --force
umount -f /mnt


I use the vagrant-reload plugin to reboot while provisioning.

Once installed, you can reboot the VM with:

config.vm.provision :reload

Value of all this

At this stage, with just a single vagrant up command, I can automatically provision a Linux VM with X configured and a basic window manager.

This will serve as a foundation to my work/home dev boxes.

What is coming next

Some topics for the near future:

  1. Swap the X session manager to an auto-logger

  2. Configure dwm/st/sxhkd/dmenu using chezmoi dotfiles management to provision everything

  3. Coding tools installation

This may just be one post, we’ll see.

I hope this series is of some use to others and inspire people to use tools that suits their needs.

This is day 5 of my #100DaysToOffload. You can read more about the challenge here: https://100daystooffload.com.

Tags: tools coding Linux 100DaysToOffload vm