Posts (Latest 10 updated) : Read all

Link List (Edit):
Contents:
  1. Virtualization
    1. FreeBSD as guest in Virtualbox
    2. FreeBSD on Qemu
# __     ___      _               _ _          _   _
# \ \   / (_)_ __| |_ _   _  __ _| (_)______ _| |_(_) ___  _ __
#  \ \ / /| | '__| __| | | |/ _` | | |_  / _` | __| |/ _ \| '_ \
#   \ V / | | |  | |_| |_| | (_| | | |/ / (_| | |_| | (_) | | | |
#    \_/  |_|_|   \__|\__,_|\__,_|_|_/___\__,_|\__|_|\___/|_| |_|
#

Virtualization

FreeBSD as guest in Virtualbox

Vbox Additions Installation Options

You have two options.

  1. Build from the ports tree. This comes from the FreeBSD documentation.
  2. Install with pkg. This comes from the FreeBSD foundation wiki, and is reccommended by me.

It will take several hours to compile the guest additions AND all the required dependencies. For one of my instances then resulted in exhausted memory. Where, installing from a package will take only a few (<5) minutes.

Using the ports tree.

Get the ports tree.

portsnap auto
cd /usr/ports/emulators/virtualbox-ose-additions && make install clean

At this point you should expect it to take over eight hours to complete.

If or when complete, do not reboot. There is more work to be done.

Using pkg
pkg install emaulators/virtualbox-ose-additions

Same as above. Once complete move on to the configuration.

Configure FreeBSD to use the

Then enable the guest additions by editing the /etc/rc.conf file with vi. Add the two lines below to it at the end.

vboxguest_enable="YES"
vboxservice_enable="YES"

Make FreeBSD use the vbox graphics driver by creating the /etc/X11/xorg.conf file, and place both blocks of code for the graphics driver AND the mouse driver in it.

Section "Device"
	Identifier "Card0"
	Driver "vboxvideo"
	VendorName "InnoTek Systemberatung GmbH"
	BoardName "VirtualBox Graphics Adapter"
EndSection

Configure the mouse for use.

Section "InputDevice"
	Identifier "Mouse0"
	Driver "vboxmouse"
EndSection

At this point, you should power off the sytem.

poweroff

Once the computer is powered down, open virtualbox settings and change the graphics controller to “VBoxSVGA”. Then power back on the machine.

configure the host for folder sharing.

vboxmanage sharedfolder add 'BSDBox' --name myshare --hostpath /mnt/bsdboxshare

Mount the shared folder on FreeBSD.

mount_vboxvfs -w myshare /mnt

After this is done, you may now go to setting up whatever you want for your installation.

FreeBSD on Qemu

Just writing this from shear memory as I do it, so if you have problems let me know.

Even with kvm enabled, FreeBSD’s performance is significantly less

Installing the image.

  1. Virtual machine images are available from FreeBSD’s website. They come in three formats; qcow2, vhd, and vmdk. For working with qemu you will want to download the qcow2 image. Once downloaded you will need to extract it.
xz -d FreeBSD(...).qcow2.xz
  1. Next, you will need to create a “backing file” for your image. If you fail to do this, all freespace left in the virutal image will be consumed within a matter of minutes on your virtual disk image. “Backing Files” are often referred to as overlay images. They write changes made to the original image, and it’s current state. It is a handy feature, because it keeps the original image in a pristine state, and allows the creation of a disposable environment if needed.
    qemu-img create -f qcow2 -o backing_file="$ORIGINAL_IMAGE",format=qcow2 "$NEW_FILE".qcow2 
    
  2. Now you can start your virtual macine instance in a graphical environment. Personally, because of the loftiness of the command, I always create a one line script to make it easier to execute in the future.
    service netif restart
    service sshd start
    

Reference Material

  1. qemu wiki
  2. The qemu book
  3. Qemu’s Documentation