FreeBSD as a Host for Windows XP using VirtualBox

Posted in FreeBSD Tutorials on December 1st, 2009 by admin

Although I mostly use FreeBSD to perform many tasks, it can also be useful to have access to Windows binaries. Multiple choices are available: emulation, dual booting and virtualization. I personally dislike wine since it is not capable to run every binaries and even the ones he can emulate sometimes need hard tweaking to get them work correctly. Dual booting is not an option for me because I want to be able to run simultaneously FreeBSD and Windows binary. For those reasons I prefer to use VirtualBox to get a full Windows operating system, it may seem like a waste of ressources but by now, virtualization is easily supported by most of the modern computers.
I already see people ready to burn me with reflexion like “Don’t be stupid, there is an open source solution for what you need !”, that’s mostly true but there are many reasons to want to use a particular closed source software including compatibility issues or company restriction to some software and this debate is not the point of this post. :P

As usual we start with the compilation of the port, don’t forget to activate the “Enable Guest Additions” on the config screen, we will use this later:

# cd /usr/ports/emulators/virtualbox && make config-recursive install clean

To be able to use VirtualBox, we need to do some settings to our system, starting by loading a kernel module:

# kldload vboxdrv

It will be ok if you want to use VirtualBox once, but I assume you want to use it regularly, so get the module loaded at boot by adding this line to /boot/loader.conf:

vboxdrv_load="YES"

VirtualBox will also need to have the proc filesystem mounted.
Edit /etc/fstab:

proc /proc procfs rw 0 0

and mount this new entry:

# mount /proc

Last step is to add yourself and the users you want to be able to use VirtualBox to the vboxusers group:

# pw groupmod vboxusers -m lioks

We are now ready to use VirtualBox:

% VirtualBox

Now create a new virtual machine, specifying the type of the OS you are about to install (i.e. Windows XP).
Set the memory size you want it to have, and create a new virtual hard drive.
I chose “Dynamically expanding storage” as my hard drive type, it allows the virtual drive to expand on the real hard drive as you need more space in your virtual machine. The maximum size you set for the disk will be used by the guest OS to determine the virtual size of this disk.

You should by now have a new machine available on the side menu of VirtualBox, right-click on it and go to the settings menu. In the CDROM/DVDROM option you can attach to this machine a cd/dvd drive or an iso file.
I’ll skip the Windows installation steps since there is almost no human intervention needed :P

Once your fresh Windows Xp is up and running in your box, click on the Devices menu and select Install Guest Additions.
Follow the instructions (Windows-style :p) and reboot your virtual machine.
These additions will provide you with video drivers which allow you to have a real resolution, full-screen mode, the possibility to integrate windows from your guest OS in your host OS and a smooth focus switching.

You also can set up access to directories in your host OS using the Devices->Shared Folders menu, they will appear in your guest Windows Xp as network folders.

That’s it, now you should not have any problem installing and using softwares like Office or VisualStudio, I did not have to configure anything to get network work properly, it was working just fine the first time I launched my new virtual machine :)

You can even launch your virtual machine without using the VirtualBox interface:

% VBoxManage startvm "vm name here"

I had a bunch of screenshots for this tutorial but I can’t manage to find where i put them, so I hope you will find what you need without visual support ;)
(I will upload them if I ever find them again…)
See you.

Tags: ,