Migrate FreeNAS to VMware

I was running my FreeNAS installation dedicated on my NAS Build I did last year. Though I wanted more freedom thus installing a hyper-visor (VMware) to run multiple virtual operating systems so I can fully utilize my resources in this build. In this blog I describe how I migrated the FreeNAS installation to a virtual machine. I assume you have VMware running (I might include a short blog on that later on).

Below are the high level steps that we are going to do;

  1. The first step is to “detach” the volume and showdown the system.
  2. Next is to install FreeNAS in a virtual machine and
  3. setup RDM (RAW Device Mappings) from the disks to the virtual machine.
  4. In the last step we are going to import the disks and bring the volume back on-line. 

Be aware; you are going to lose your configuration (shares, users, Jails etc)! This was no problem for me as I just have a few shares and are going to create a new dedicated virtual machine for downloading (blog for later!)

Step 1; Detach the volumes (and save configuration)

Login to your FreeNAS GUI and go to “Storage”. There you see your current RAID Z volume with the datasets we created during our initial installation . If you select  your RAID Z volume you see options at the bottom of the screen and if you hover over the most left one, you see “Detach Volume” just as in the screen-shot. Notice that when you click it the background screen will become red and you can not deselect “Also delete the share’s configuration”. If you want to backup the configuration you can do so by going to “System” –> “General” and than select “Save Configuration”. This will create a database file that holds your settings (not your actual data!).

Step 2; Installing FreeNAS into a virtual machine (running VMWare)

We are going to install FreeNAS on a virtual machine. We first are going to download the latest version of FreeNAS (http://www.freenas.org/download/). Next is to prepare a Virtual Machine that is going to run FreeNAS. We go to our VMware client (in my case the web version) and are going to “create / Register VM” in the “Virtual Machines” section. FreeNAS is using “FreeBSD” so in the second screen you will have to select the right operating system (OS) to be “Other” and in “Version” select “FreeBSD (64-bit).  I am going to install the OS on the local device and in screen 4 (customize Settings) I will provide my FreeNAS with the following virtual hardware as show in the screen-shot.

After you finish you see the new Virtual Machine in the list powered off. Do not yet power on as we first need to mount the ISO for installing FreeNAS we downloaded earlier in this section. We select “Actions” and are going to “edit settings”. In this screen we will “Add other device” –> “CD/DCD Drive”. It should appear right after you clicked it. Though instead of a “Host device” we need a “Datastore ISO file”. You should get another screen named “Datastore browser”. We are going to upload the ISO from FreeNAS to a new sub-folder on our datastore. First, create a new directory (i named it ISO) and select “Upload” on the top left on this window. Search for the ISO from FreeNAS we downloaded earlier and select it. It will upload to your ISO folder and once complete, select it and hit select.

If you are done power-on the virtual machine and walk thru the installation setup. Ignore the “4 GB is to low” and select the local disk (10GB) to install FreeNAS, create a root password and select BIOS instead of UEFI boot. When done it will install FreeNAS and, in my case, it took just 5 minutes. Once complete I selected Shutdown and again in “Edit Settings” I removed the “CD/DVD Drive” that was pointing to the Datastore ISO file.

Step 3; Setup RDM (RAW Device Mappings) from the actual physical disks to the virtual machine

This is the hardest part of the migration as it is going to involve going into SSH on the VMWare host. I got help from KB 1017530 that explains the commands and syntax used for this action. The very first step is to enable SSH to get into our VMWare host if not enabled yet. This can be done by navigating to Host –> Manage –> Services in the VMWare GUI. Next, you right click “TSM-SSH” and select “Start” from the drop down menu. Next is to start your favorite SSH client (I use Putty) and login to your VMWare environment. Below is the step-by-step from my own installation using my own disk-names;

  1. We first need to list the disks that we will convert to RDM’s to be used by FreeNAS.  Run this command to list the disks that are attached to the ESXi host:
    ls -l /vmfs/devices/disks
  2. According to the KB the devices are likely be prefixed with t10. To make life more easier I selected the complete output and pasted it in a more easy text editor (Notepad++) and removed all the other output so I just had the following list;
    t10.ATA_____WDC_WD30EFRX2D68EUZN0_________________________WD2DWCC4N2VAHD35 
    t10.ATA_____WDC_WD30EFRX2D68EUZN0_________________________WD2DWCC4N7LPRJKL
    t10.ATA_____WDC_WD30EFRX2D68EUZN0_________________________WD2DWCC4N7LPRPFL
    t10.ATA_____WDC_WD30EFRX2D68EUZN0_________________________WD2DWCC4N7XTRV9C
  3. Next is to create a “pointer file” we need to run the command  vmkfstools with the -z option to the actual Disk name and store it somewhere in our datastore using a .vmdk extension. I created a folder inside our “FreeNAS” and ran the command where [diskname] is the long t10 name I pasted in my text editor. The full command with an syntax is vmkfstools -z /vmfs/devices/disks/diskname /vmfs/volumes/datastorename/vmfolder/vmname.vmdk Below step 5 you can see my console output
  4. The final step is to add the RDM’s to our virtual machine running FreeNAS so we can rebuild our RAID Z volume. At this stage we still do not have power on our Virtual Machine!
    • Click Edit Settings from our FreeNAS Virtual machine
    • Select “Add Hard Disk”
    • Select “Existing hard disk”
    • Browse to the directory you saved the RDM pointer file in step 3 and click Next (Local –> FreeNAS –> RDM)
    • Do this for all disks (4 in my case). Afterwards it should look like this where, in green, you can see the highlighted new drives
    • Click Save.
  5. You should now see your new hard disk in the virtual machine inventory as Mapped Raw LUN
[root@vmware:~] mkdir /vmfs/volumes/Local/FreeNAS/RDM
 [root@vmware:~] vmkfstools -z /vmfs/devices/disks/t10.ATA_____WDC_WD30EFRX2D68EUZN0_________________________WD2DWCC4N2VAHD35 /vmfs/volumes/Local/FreeNAS/RDM/WD2DWCC4N2VAHD35.vmdk
 [root@vmware:~] vmkfstools -z /vmfs/devices/disks/t10.ATA_____WDC_WD30EFRX2D68EUZN0_________________________WD2DWCC4N7LPRJKL /vmfs/volumes/Local/FreeNAS/RDM/WD2DWCC4N7LPRJKL.vmdk
 [root@vmware:~] vmkfstools -z /vmfs/devices/disks/t10.ATA_____WDC_WD30EFRX2D68EUZN0_________________________WD2DWCC4N7LPRPFL /vmfs/volumes/Local/FreeNAS/RDM/WD2DWCC4N7LPRPFL.vmdk
 [root@vmware:~] vmkfstools -z /vmfs/devices/disks/t10.ATA_____WDC_WD30EFRX2D68EUZN0_________________________WD2DWCC4N7XTRV9C /vmfs/volumes/Local/FreeNAS/RDM/WD2DWCC4N7XTRV9C.vmdk

Step 4; Bring the Volume Back on-line (and restore the configuration).

If everything went well the system booted and you should see the basic console from FreeNAS. You will have to setup the network again as we did in the initial setup from an earlier post in the “Installation Steps”. After you have done the network part, switch to the GUI and select the location. In my version from FreeNAS (11.0-U2) I got a notification during the Initial Wizard that my volume was found! Though I did skip this for this blog. I did the add manually using the following steps;

  1. Navigate to “Storage”
  2. Verify that using “View Disks” all your disks are visible
  3. Select “Import Volume”
  4. I did not encrypt my disks and in the second step it found my RaidZ volume (See Screen-Shot)

That’s it! Step 2 took a while though but it might have to do that one of my disks broke during and it had bad sectors. Alternatively you can restore the configuration from the backup that we created in step 1. Go to”System” –> “General” and than select “Upload Config”, select the database file we created end of step 1 and select “update”. The system will twice reboot afterwards and you will have all your configurations back. Though do remember that this also includes your old root password!

3 Comments

Add a Comment

Your email address will not be published. Required fields are marked *