Create your own Network Storage Solution using FreeNAS

Posted by Sean Duffy in Storage, SysAdmin, Tutorials on 05-04-2011

Tags: , , , , , , , ,

Having a central location to store all your data on the local network can come in very handy when it comes to sharing your files and providing access for other users. FreeNAS is an open source solution that is very quick to setup. My main use for

FreeNAS is for creating shared storage for VMware ESX or ESXi hosts – a requirement when you want to use some of the vSphere clustering features like HA and DRS. I simply provision a VM that it runs on and use that to provide the storage in NFS (Network File System) format to my hosts. FreeNAS supports some great features. Namely – CIFS for Windows shares, FTP, NFS, iSCSI and many others. It also supports software RAID 0, 1, or 5 and is so small, you can even install it on a 64MB flash disk making it portable too.


Setting up FreeNAS in a VM


As I mentioned above, my main preference is to run FreeNAS in a VM. However, you can of course install it on a physical PC/Server or even run it in embedded mode using a USB flash drive. I will be downloading the 0.7.2 build in VMware Image format and setting this up.

Open the .VMX file for the VMware image in VMware Workstation or Server. Add an extra Hard disk to the VM choosing a SCSI disk with the desired size you would like to use for your Data Shares. I added a 120GB drive as I wanted to have 120GB for my ESXi hosts to use to run Virtual Machines from.

If you choose to go your own installation route, or would like to install FreeNAS on a physical machine, the installer is really simple to use, consisting of just a couple of options that ask which disk you would like to install it on and whether you want a swap partition or not.

Continuing with the VM setup, let us get started by powering on the FreeNAS server image. You will be asked if it has been moved or copied. Choose “I copied it”. Once it has booted you’ll be up and running with the fully installed version of FreeNAS and have some options to work with as seen below.

Configure your Network interface by choosing option 2) and entering your local network information. Turn DHCP off as you’ll want a static IP address for this server. You’ll set up an interface name, IP address and subnet mask, default gateway and DNS.

Now you can browse to the IP address you configured using the format http://IPAddress in your local machine’s web browser. Your default credentials are admin/freenas to login with. You’ll see the main configuration page which should look similar to this:


Provisioning a NFS Share


First things first, we’ll get our data disk configured for use. Go to Disks -> Management and click the little “+” (Plus) sign on the far right to add a disk. You should see your data disk (da1) in the dropdown menu. Just ensure you have your added disk selected in this dropdown. Type in a short description and leave all the other options at their defaults. Click the “Add” button to add the disk, following which you’ll see the disk set to “Initializing”. Click the “Apply changes” button to confirm changes. You should now see your disk as ONLINE.

We need to format this disk, so open up Disks -> Format, choose “da1” (your extra data disk) and select UFS for the file system. Assign a volume label and leave all other options at their defaults. Proceed with the format. Here is a rundown of the settings I used:

Go to the Disks -> Mount Point section next, then click the “+” (Plus) sign to add a mount point. Configure it as per the screenshot below (with the exception of assigning your own mount point name) then click “Add” at the bottom when done.

Make sure you “Apply Changes” when the disk mount point has been added. Your Mount Point status should now show as OK.

Next up, navigate to Services -> NFS. Click the “Enable” tick box for “Network File System” then click the “Save and Restart” button to enable the NFS service for your server. Now click the “Shares” tab under the NFS section and configure a share by clicking the “+” (Plus) button on the right.

Configure your NFS share using the screenshot below as a guide – your path should be something like /mnt/YourMountPointName – this is the path that your client machines will connect to (VMware ESXi hosts for example). In my configuration case, the Path is: /mnt/Datastore120GB. Select the authorized network range (the client network that will be allowed access to this share) and tick the option for “Share all sub directories”. Be sure to click the “Add” button at the bottom when finished, and apply the changes on the page that follows.


Conclusion


Now that the share is setup it should be simple enough for your clients (or in my case ESXi hosts) to connect to. Here is how I connected my ESXi hosts to this share so that they could use a centralized storage location to run multiple VMs from. Having this shared storage allows them, whilst being connected to vCenter Server, to use features such as HA (High Availability) and DRS (Distributed Resource Scheduling – as all hosts need to have access to the exact same storage as a requirement).

  1. Connect to ESX/ESXi host using vSphere client
  2. Go to configuration tab
  3. Click on Storage -> Add Storage
  4. Select “Network File System”
  5. Enter the FreeNAS IP address as the Server
  6. Enter the “Folder” as the share name.

Finish the wizard.

You can of course use your FreeNAS server to host other shares too. As mentioned in the beginning, you can use other protocols such as CIFS, FTP, iSCSI (another great protocol for VMware hosts needing shared storage), and many others with FreeNAS. Network Attached Storage is a great way to provide shares to more than one client machine and in my case makes for an excellent lab storage virtual appliance.


Comments (8)

Realy it helps lot to me.

Thanks

[...] You can of course use your FreeNAS server to host other shares too. As mentioned in the beginning, you can use other protocols such as CIFS, FTP, iSCSI (another great protocol for VMware hosts needing shared storage), and many others with FreeNAS. Network Attached Storage is a great way to provide shares to more than one client machine and in my case makes for an excellent lab storage virtual appliance. SysAdmin Talk [...]

Does this version of Free NAS support vmotion/svmotion?

Hi Harish,

Its not really about FreeNAS supporting those two VMware clustering features, its more about the storage being configured correctly in order for those two features to work. Yes, FreeNAS, if configured correctly to share the datastore to all hosts in your VMware cluster will support vMotion and svMotion. All it comes through as is a shared NFS volume, and provided all your hosts in the cluster can see this storage, then the above mentioned features should work. Hope that helps!

Sean

[...] can follow this guide to download a preconfigured VM for VMware Workstation and get everything you need for your NFS [...]

Sean,
Thank you for this invaluable how-to.
Best Reagards,
Tom

[...] hosts need to have access to in order to use clustering capabilities such as HA and DRS.You can follow this guide to download a preconfigured VM for VMware Workstation and get everything you need for your NFS [...]

Write a comment