FreeNAS® in a Virtual Environment
FreeNAS can be run inside a virtual environment for development, experimentation, and educational purposes. Please note that running FreeNAS in production as a virtual machine is not recommended.
In order to install or run FreeNAS® within a virtual environment, you will need to create a virtual machine that meets the following minimum requirements:
- 512 MB base memory size (UFS only), 4096 MB or more (ZFS)
- a virtual disk at least 4 GB in size to hold the operating system and swap
- at least one more virtual disk at least 4 GB in size to be used as data storage
- a bridged adapter
This section demonstrates how to create and access a virtual machine within the VirtualBox and VMWare ESXi environments.
Contents |
VirtualBox
VirtualBox is an open source virtualization program originally created by Sun Microsystems. VirtualBox runs on Windows, BSD, Linux, Macintosh, and OpenSolaris. It can be configured to use a downloaded FreeNAS® .iso or .img.xz file, and makes a good testing environment for practicing configurations or learning how to use the features provided by FreeNAS®.
Creating the Virtual Machine
To create the virtual machine, start VirtualBox and click the "New" button, seen in Figure 2.2a, to start the new virtual machine wizard.
Figure 2.2a: Initial VirtualBox Screen
Click the "Next" button to see the screen in Figure 2.2b.
Figure 2.2b: Type in a Name and Select the Operating System for the New Virtual Machine
Enter a name for the virtual machine, then click the "Operating System" drop-down menu and select BSD, which will automatically change the "Version" to FreeBSD. Click "Next" to see the screen in Figure 2.2c.
Figure 2.2c: Select the Amount of Memory Reserved for the Virtual Machine
The base memory size must be changed to at least 512 MB. If your system has enough memory, select at least 4096 MB so that you can use ZFS. When finished, click "Next" to see the screen in Figure 2.2d.
Figure 2.2d: Select Whether to Use an Existing or Create a New Virtual Disk
This screen is used to create the virtual hard disk to install FreeNAS® into. Click "Next" to launch the "Create New Virtual Disk Wizard". Click the "Next" button again to see the screen in Figure 2.2e.
Figure 2.2e:Create New Virtual Disk Wizard
The wizard can be used to create the following types of virtual disk formats:
- VDI: Virtual Disk Image is the format used by VirtualBox. Select this option if you downloaded the ISO.
- VMDK: Virtual Machine Disk is the format used by VMWare. Select this option if you converted the .img file to VMDK format using the instructions in Running FreeNAS® from a USB Image.
- VHD: Virtual Hard Disk is the format used by Windows Virtual PC.
- HDD: is the format used by Parallels.
Once you make a selection, click the "Next" button to see the screen in Figure 2.2f:
Figure 2.2f: Select the Storage Type for the Virtual Disk
You can now choose whether you want "Dynamically expanding storage" or "Fixed-size storage". The first option uses disk space as needed until it reaches the maximum size that you will set in the next screen. The second option creates a disk the same size as that specified amount of disk space, whether it is used or not. Choose the first option if you are worried about disk space; otherwise, choose the second option as it allows VirtualBox to run slightly faster. Once you select "Next", you will see the screen in Figure 2.2g.
Figure 2.2g: Select the File Name and Size of the Virtual Disk
This screen is used to set the size (or upper limit) of the virtual machine. Increase the default size to 4 GB . Use the folder icon to browse to a directory on disk with sufficient space to hold the virtual machine.
Once you make your selection and press "Next", you will see a summary of your choices. Use the "Back" button to return to a previous screen if you need to change any values. Otherwise, click "Finish" to finish using the wizard. The virtual machine will be listed in the left frame, as seen in the example in Figure 2.2h.
Figure 2.2h: The New Virtual Machine
Creating Devices for Storage and Installation Media
Next, create the virtual disk(s) to be used for storage. Click the "Storage" hyperlink in the right frame to access the storage screen seen in Figure 2.2i.
Figure 2.2i: The Storage Settings of the Virtual Machine
Click the "Add Attachment" button, select "Add Hard Disk" from the pop-up menu, then click the "Create New Disk" button. This will launch the Create New Virtual Disk Wizard (seen in Figures 2.2e and 2.2f). Since this disk will be used for storage, create a size appropriate to your needs, making sure that it is at least 4 GB in size. If you wish to practice RAID configurations, create as many virtual disks as you need. You will be able to create 2 disks on the IDE controller. If you need additional disks, click the "Add Controller" button to create another controller to attach disks to.
Next, create the device for the installation media.
If you will be installing from an ISO, highlight the word "Empty", then click the CD icon as seen in Figure 2.2j.
Figure 2.2j: Configuring the ISO Installation Media
Click “Choose a virtual CD/DVD disk file...” to browse to the location of the .iso file. Alternately, if you have burned the .iso to disk, select the detected “Host Drive”.
NOTE: Depending upon the extensions available in your CPU, you may or may not be able to use a 64-bit ISO on a 64-bit system. If you receive the error "your CPU does not support long mode" when you try to boot a 64-bit ISO, your CPU either does not have the required extension or AMD-V/VT-x is disabled in the system BIOS. You can still use the 32-bit version of the ISO, but ZFS performance will be reduced.
Configuring the Bridged Adapter
To configure the network adapter, go to Settings → Network. In the "Attached to" drop-down menu select "Bridged Adapter", then select the name of the physical interface from the "Name" drop-down menu. In the example shown in Figure 2.2k, the Intel Pro/1000 Ethernet card is attached to the network and has a device name of re0.
Figure 2.2k: Configuring a Bridged Adapter in VirtualBox
Once your configuration is complete, click the "Start" arrow. If you configured the ISO, install FreeNAS® as described in Installing from CDROM. Once FreeNAS® is installed, press F12 to access the boot menu in order to select the primary hard disk as the boot option. You can permanently boot from disk by removing the CD/DVD device in "Storage" or by unchecking CD/DVD-ROM in the "Boot Order" section of "System".
If you configured the VMDK, the virtual machine will boot directly into FreeNAS®.
Running FreeNAS® from a USB Image
If you will be running FreeNAS® from an .img.xz file instead of installing it from the ISO, you must first download and install the Oracle VM VirtualBox Extension Pack that matches your version of VirtualBox. The extension pack enables USB support.
Next, uncompress and burn the FreeNAS® .img.xz file using the instructions at Burning an IMG File. Once the image is burned to the USB device, leave the device inserted.
The VirtualBox GUI does not automatically provide a way to select a USB device to boot from. However, you can use a command line utility to link the USB device to a .vmdk file so that it can be selected as a boot device. To do this on a Windows system, open a command prompt in administrative mode (right-click cmd from the Run menu and select Run as administrator), and run the commands shown in Figure 2.2l. Before running these commands, verify the physical drive number from Start menu ➜ right-click Computer ➜ Manage ➜ Storage ➜ Disk Management. If the USB drive is different than Disk 1, change the number in \\.\PhysicalDrive1 to match the disk number. You can also specify where to save the .vmdk file. Make sure that the security tab of the saved file gives “Full control” permissions to Users so that the file can be accessed by VirtualBox.
Figure 2.2l: Creating the vmdk File in Windows
Once you have a .vmdk file, create a new virtual machine while the USB stick is inserted. When you get to Figure 2.2e, select “Use existing hard disk" and browse to your .vmdk file. Click "Next", then "Create". This will create the virtual machine and bring you to Figure 2.2h. You can then create your storage disks and bridged adapter as usual. When finished, start the virtual machine and it will boot directly into FreeNAS®.
VMWare ESXi
ESXi is is a "bare-metal" hypervisor architecture created by VMware Inc. Commercial and free versions of the VMWare vSphere Hypervisor operating system (ESXi) are available from the VMWare website. Once the operating system is installed on supported hardware, use a web browser to connect to its IP address. The welcome screen will provide a link to download the VMware vSphere client which is used to create and manage virtual machines.
Once the VMware vSphere client is installed, use it to connect to the ESXi server. To create a new virtual machine, click File → New → Virtual Machine. The New Virtual Machine Wizard will launch as seen in Figure 2.2m.
Figure 2.2m: New Virtual Machine Wizard
Click "Next" and input a name for the virtual machine. Click "Next" and highlight a datastore. An example is shown in Figure 2.2n.
Figure 2.2n: Select a Datastore
Click "Next". In the screen shown in Figure 2.2o, click "Other" then select a FreeBSD architecture that matches the FreeNAS® architecture.
Figure 2.2o: Select the Operating System
Click "Next" and create a virtual disk file of 4 GB to hold the FreeNAS® operating system, as shown in Figure 2.2p.
Figure 2.2p: Create a Disk for the Operating System
Click "Next" then "Finish". Your virtual machine will be listed in the left frame. Right-click the virtual machine and select "Edit Settings" to access the screen shown in Figure 2.2q.
Figure 2.2q: Virtual Machine's Settings
Increase the "Memory Configuration" to at least 512 MB .
Under "CPUs", make sure that only 1 virtual processor is listed, otherwise you will be unable to start any FreeNAS® services.
To create a storage disk, click "Hard disk 1" → Add. In the "Device Type" menu, highlight "Hard Disk" and click "Next". Select "Create a new virtual disk" and click "Next". In the screen shown in Figure 2.2r, select the size of the disk. If you would like the size to be dynamically allocated as needed, check the box "Allocate and commit space on demand (Thin Provisioning)". Click "Next", then "Next", then "Finish" to create the disk. Repeat to create the amount of storage disks needed to meet your requirements.
Figure 2.2r: Creating a Storage Disk

















