Posts Tagged VMserver VMWare FreeNAS

Creating a VMServer NAS using FreeNAS

So I wanted to create a NAS on a Virtual machine to store webfiles.  This would allow a good separation of program files and content files.  With the help of my friends Ron and Phil, we were able to get it up and running from scratch in about 90 minutes.  Aren’t friends and VMs nice. 

The idea is to create a NAS on a virtual server as a virtual machine, mount the NAS on the webserver and then setup apache to be able to access it.

Setting up FreeNAS VM

For the NAS virtual machine, we were able to download the FreeNAS VM Image from http://www.freenas.org/index.php?option=com_versions&Itemid=51

  1. Download the VM Image from http://www.freenas.org/index.php?option=com_versions&Itemid=51
  2. unzip in your virtual machines directory on your Virtual Server host.
  3. Then add a new virtual machine from inventory to have the vm show up in your inventory.
  4. At this point, you can increase the size of the hard drive. 
  5. You may also wish change some settings to the network card depending on how you wish to manage your NAS IP.  In my case, I manually set the virtual network card MAC address and set my hardware firewall to assign a static IP address to that MAC address.
  6. You may also wish to set the auto-start/auto stop settings of the VM Server to include the new NAS so it will auto power up and down. 
  7. After starting up the NAS, you can connect to it and reset the webGUI password, assign interfaces and set LAN IP if necessary.
  8. Connect to the webGUI using a web browser.  You will be prompted for the username and password. 
  9. Once connected you will want to create a folder to store your data and enable the services to allow sharing of files.
  10. create a new folder by going to the advanced menu and selecting file manager.
  11. create a new folder  like /usr/local/nas/
  12. Go to the Service menu and select NFS and enable it and save it.
  13. Then go to the Share tab and add a folder to share, browse and select the new folder you created
  14. For authorized network, you can either set it to be your entire network by adding something like 192.168.0.0 and a mask of 24 or you can specify the specific web service IP and set the mask to 32.   

Mounting your NAS on your web server

Next we would like to mount the NAS on the web server so that it has access to it.

  1. log into you webserver.
  2. go to the /mnt directory by using  the cd /mnt command
  3. add a new directory by using the mkdir command, mkdir nasfiles
  4. next mount the new directory to the nas directory using, the command, sudo mount -t 192.168.0.35:/usr/local/nas /mnt/nasfiles
  5. edit the fstab file in the /etc folder to have the nas mounted on power up with the following line 192.168.0.35:/usr/local/nas /mnt/nasfiles ext3 defaults 0 0

Give Apache access to the newly mounted NAS

  1. edit the httpd.conf file and add in an alias to the mnt directory and add a directory declaration
  2. Alias /nasfiles “/mnt/nasfiles”
  3. <Directory “/mnt/nasfiles”>Options None AllowOverride None Order allow,deny Allow from all </Directory>
  4. then restart the httpd service

Test it.

Add a file to the mounted nas directory, see if you can access the file from your website.

3 Comments