User:Mjb/FreeBSD on VirtualBox

From Offset
< User:Mjb
Revision as of 08:01, 5 October 2015 by Mjb (talk | contribs) (BIOS must enable hardware virtualization if CPU supports it)
Jump to navigationJump to search

VirtualBox emulates IBM PC-compatible hardware. It's like an imaginary rack of PCs. Each PC is a Virtual Machine (VM) with its own pretend hardware (motherboard, RAM, keyboard, mouse, display, networking, storage). Your real computer running VirtualBox is the "host". The VMs are "guests".

I'm running FreeBSD in a VirtualBox VM. The host system is Windows 7. Here are some of my notes about it.

See also:

Install VirtualBox

I already had VirtualBox 4.3.20 installed for other projects. I don't recall if there was anything special I did to set it up.

BIOS must enable hardware virtualization if CPU supports it

Once I got FreeBSD working in a VM under VirtualBox 4.3.x, I upgraded to VirtualBox 5.0.6. The FreeBSD VM continued to work, but some other VMs (Windows XP and Archive Team Warrior) would not fully boot.

It seems the newer versions of VirtualBox don't like it if you have an Intel CPU with VT-x (hardware virtualization features), but this support is not enabled in your motherboard's BIOS settings. The symptoms are strange crashes during the guest OS's bootup. The crash report may or may not seem to be related to what's going on. In one case I was getting an assertion failure for something quite obscure, but in another the VBox.log file mentioned there was an issue with hardware virtualization support.

So before running the 5.x versions of VirtualBox, be sure to enable the VT-x and any other hardware virtualization support settings in your BIOS. If your motherboard or BIOS has no such settings, you may be out of luck!

Windows custom theme app incompatibility

On Windows, VirtualBox 4.3.14 and up has "hardening" improvements which checks the integrity of Windows DLL processes to make sure nothing is hijacking or extending them. If you are running software which modifies any core Windows features, like certain theme/font/skinning apps, your VMs will all fail to start in these newer builds of VirtualBox. You need to either disable that software or configure it to ignore the VirtualBox.exe process. In MacType, for example, add VirtualBox.exe to the [UnloadDlls] section of the current profile (.ini file).

Decide what to run

Since it's (almost) just like having a separate PC, you have a choice of what to do:

  • You can get a "live" CD/DVD image file and have a VirtualBox VM boot and run FreeBSD from it. This is mainly just for trying out the OS; changes won't be saved.
  • You can get a FreeBSD snapshot and put it onto a virtual hard drive, then use a VirtualBox VM to boot FreeBSD from that drive.
  • You can have a VirtualBox VM boot from a FreeBSD installer CD/DVD image, and use the installer to put FreeBSD onto the VM's virtual hard drive.

I chose the latter option (using the installer).

Download a FreeBSD installer DVD image

You need an uncompressed ISO-format image of an i386 release version of FreeBSD. Go to ftp://ftp.freebsd.org/pub/FreeBSD/releases/i386/i386/ISO-IMAGES/ and pick the latest version available. In my case it was 10.2, and the file I wanted was FreeBSD-10.2-RELEASE-i386-dvd1.iso.

Download and save the .iso file somewhere.

Create a Virtual Machine for FreeBSD

  • Name: whatever you want, e.g. FreeBSD 10.2-RELEASE
  • Type: BSD
  • Version: FreeBSD (32-bit)
  • Memory size: 128 MB is recommended but that's the bare minimum. I chose 1024 MB (1 GB). It will be using the host's RAM, so you have to decide how much you can spare.
  • Hard drive: Create a virtual hard drive now, file type VDI, Dynamically allocated. The size can be whatever you can spare. It will live in a file on one of your host's drives.

Now click on the Settings icon; don't turn on your VM yet.

  • System > Motherboard > [X] Hardware Clock in UTC Time
  • Storage > under Controller: IDE, there's a CD/DVD icon and the word "Empty". Click on it. Now on the right side, under Attributes, click on the new CD/DVD icon that's next to "IDE Secondary Master", and choose "Choose a virtual CD/DVD disk file...". Find the .iso you saved (see previous section) and point it to that. You have just done the equivalent of putting a DVD into the VM's drive! Click OK.
  • Network > Attached to: Bridged Adapter. This defaults to NAT, but you want Bridged Adapter so that it will be visible and fully accessible to other machines on your LAN, including your host machine (i.e. they can establish inbound connections to the VM). If you choose NAT, then the VM is hidden "behind" your host machine and is only capable of outbound connections.

OK, now you're ready. Click Start to power on the VM. The DVD should boot and you're ready to install. Just follow the prompts.

Before rebooting at the end of the install process, you will need to "remove" the DVD from the drive, or it will boot back into the DVD. If that happens, it's OK just to power off the VM.