A reader recently commented on my post about upgrading to FreeNAS version 8 and asked if I had any advice for installing FreeNAS on VirtualBox. The thought of virtualizing FreeNAS didn’t occur to me but it’s actually a great idea so I decided to give it a try. It turns out that FreeNAS actually runs pretty good on VirtualBox.
VirtualBox is a virtualization package developed by Oracle, it’s similar to VMWare except VirtualBox is open source which is a big advantage.
I tested the following versions of FreeNAS on VirtualBox version 4.0.6.
VirtuaBox is very easy to set up, just download the installer and run through the wizard. To create a new virtual machine click the ‘new’ button in VirtualBox, this will start the new machine wizard. The first step is to set the OS type and version. Select BSD as the type and select either FreeBSD, or FreeBSD (64 bit) if you are using the amd64 version of FreeNAS.
On the next screen you can set the amount of RAM the virtual machine will be allowed to access. FreeNAS itself does not have a minimum requirement although I wouldn’t use any less than 1GB. If you plan to use ZFS you will need at least 4GB since it is a very resource intensive filesystem.
After you assign the RAM you will need to configure the virtual hard disk. For FreeNAS you will need at least two virtual disks, one will be the boot drive containing the OS and the second one for data storage. Make sure ‘Boot Hard Disk’ is selected, choose ‘create new disk’, then click next to start the new disk wizard. You can create the second hard disk later in the process so don’t worry about it now.
VirtualBox allows you to choose between dynamically expanding or fixed-size storage. I would recomend choosing dynamically expanding, this will create a small file that can grow over time depending on the amount of space required. If you chose fixed-size VirtualBox will allocate a file of the size you selected and it will not be able to grow.
Even if you choose dynamic you will have to select a size for the disk. The size you select is the size that will be reported to the operating system. The FreeNAS installer needs to see that there is enough space available to perform the install so I chose 2GB.
The easiest way to install FreeNAS on your new VirtualBox is by mounting the ISO using Daemon Tools, this saves you the trouble of having to burn a CD. After you have downloaded the FreeNAS iso and mounted it using daemon tools you can boot up your VirtualBox machine.
The first time you start a machine in VirtualBox it will start the first boot wizard. Select the drive letter assigned to the CD containing FreeNAS or the ISO you mounted using Daemon Tools
As soon as you finish the first boot wizard your virtual machine will start up. If you pointed it to the correct boot drive you should see the FreeNAS boot screen. At this point you can proceed with installing FreeNAS.
Instead of rebooting after the installation power down the virtual machine so you can modify a few of the settings. You can turn it off by selecting the close option from the machine menu. At this time you should also unmount the installation media otherwise when you boot the virtual machine it will try to begin the installation process again.
Click on the devices menu, then under CD/DVD devices uncheck the box next to the drive you used. If the drive is still in use you may have to force the unmount of the drive.
By default VirtualBox will attach the network adapter of the virtual machine to a NAT adapter. I prefer to bridge the adapter directly to the host machines adapter, this way the virtual machine can connect to your local network just like any other machine would.
To change the network settings select your virtual machine on the main screen and click on settings. On the network tab select bridged adapter from the drop down box where it says ‘attached to’.
Adding an additional virtual drive for storage
While your VM is still powered down you should add an additional virtual disk for FreeNAS to use for data storage. To do this select the storage tab on the settings page and click the plus symbol at the bottom of the storage tree, then select ‘add hard disk’. This will once again start the new disk wizard you used earlier.
I created a 100GB dynamic disk for my test, but you can create as many drives with whatever sizes you need.
At this point all of the configuration you need is in place and you can boot FreeNAS. To start the VM select it from the main screen in VirtualBox and click start. FreeNAS should automatically obtain an IP via DHCP which will allow you to access it using the web interface.
FreeNAS should detect the new virtual disk that you created, to confirm try to create a new volume and see if it shows up.
I’ll probably use this method to test new releases of FreeNAS without having to upgrade my primary NAS. You could actually run several FreeNAS systems on one physical machine using VirtualBox but it would take a multi-core CPU and a lot of RAM to do.