Mount a CIFS share to QNAP on reboot

Recently I purchased a qnap TS-251+ mostly for using its applications like photo sharing/QvPC/Qsirch and others. I already have my storage on a raidz array which is hosted on FreeNAS 9.10. FreeNAS then provides the storage through various ways to my pc’s/mac in my house using mostly CIFS and ISCSI. My TS-251+ currently hosts only 1 6TB disk (will purchase another one in the future for a raid mirroring volume) but I don’t care so much because all my storage is on the FreeNAS at the moment.

After purchasing the qnap I found out that there is no way that you can mount external shares automatically from the UI (you can only do it for ISCSI targets). And the worse thing is that if you mount them from command line when you reboot the machine they are not remounted because the /etc/fstab file on the NAS lives in RAM, and therefore does not survive the “reboot”

So after a bit of research here I found out how you can do it.

Continue reading

Building a NAS – Part 2 – Installing ESXi and FreeNAS

In Part 2 I am going to explain how I installed vmware esxi (free version of esx) and then created a virtual machine for freenas using the disks with raw device mapping, which is like freenas having direct access to the disks

Installing ESXi 5.5

I chose to install esxi on a fast class 10 SDHC 32GB which had roughly 10 MB/sec speed

After the installation of esxi was finished, I installed the VMWare Vsphere Client on a Windows machine and created a virtual machine for the FreeNAS with 8GB hd and 8GB RAM. You have to keep in mind that a lot of memory is needed for the zfs volumes – 8GB is the minimum. My esxi has 16GB RAM and I planning to assign the 12 GB to FreeNAS and the rest to the ubuntu server.

Adding the disks as Raw Device Mapping

I found this very good article on how to mount the disks as Raw Devices to esxi

What you basically do is perform a ls -l inside the directory /dev/disks in order to show all the drives (hd’s) – the drives in my case are the ones that start with t10.ATA_____ST (seagate drives) and with the capacity in front. You can also check the serial numbers of the drives from here

Then you cd inside the directory where the esxi volume is – in my case disk0 (cd /vmfs/volumes/disk0)

And the you run the command vmkfstools -z drive drive_name_given.vmdk

 vmkfstools -z /vmfs/devices/disks/t10.ATA_____ST2000DM0012D1CH164__________________________________Z1E1DSBL rdm_Z1E1DSBL.vmdk

This has created the rdm_Z1E1DSBL.vmdk for the disk /vmfs/devices/disks/t10.ATA_____ST2000DM0012D1CH164__________________________________Z1E1DSBL

So now my raw disk mappings are ready and all I have to do is to add the three drives (HD) from vsphere to FreeNAS. I chose the “Use an existing virtual disk”  as type of disk and then I chose the files that I had created

Now you can see the disks mapped as Mapped Raw LUN to FreeNAS – remember to give different SCSI device node numbers for each one

So now we mount the iso of FreeNAS to the CD drive of the virtual machine and start it

I select to install FreeNAS on my virtual hd that I chose to be 8GB large (no need for a big hd as this is used only by FreeNAS and cannot be used for volumes)

freenas install -1

freenas install -2

Finish the install and reboot

freenas install -3

After reboot I can open my browser and type in the url in order to access FreeNAS

freenas install -4

Logging to FreeNAS and going to Storage -> View Disks you can check my drives mounted as raw devices

Testing FreeNAS zfs volumes from ubuntu

Before copying all my data to the FreeNAS, I wanted to check if my writes were readable from a different system

After I created a volume in FreeNAS I removed the hard drive and installed it in a ubuntu 12.04 server which had the zfs installed. You can install zfs in ubuntu by using

 apt-get install ubuntu-zfs

in order to import the volume you can try

 zpool import volume1

where volume1 was the name of the volume I had created in FreeNAS

Importing the volume in ubuntu and viola! I was able to read the files and directories without any problem

Building a NAS – Part 1 – Assembling the server

After owning for a long time 6 external hard disks (one was with a network interface) I decided to buy/build one server and accomondate all of them. Doing some research over the internet I was between the ready made solutions like drobo/synology and a custom built. I liked the low powered and compact design of the ready ones but I was skeptical about what happens when it is out of guarantee and something breaks. In addition being able to install my open source software on the NAS made me decide to go with a custom one.

So my requirements for the custom built NAS server were:

  1. Low powered (around 50W)
  2. Quiet (as it will be on all the time)
  3. Open Source O/S
  4. Upgradable
  5. Not more expensive than the ready ones
After a lot of thinking and googling decided to install esxi which I have worked a lot with in the past and install FreeNAS as a virtual machine. The disks will be passed with Raw Disk  Mapping (RDM) directly to freenas which is very important if you want to attach the disk as it is to another zfs machine and be able to read it. In addition the performance of RDM is almost close to the performance of a bare metal disk. I would then install another virtual with ubuntu server for all the rest of the functions like media/vpn/itunes server that FreeNAS doesn’t support.

The parts of the server are:

  • Coolermaster Silencio 550 Case
  • Corsair TX550M 550W PSU 80+ BRONZE
  • Asrock Z77 PRO4-M
  • Intel Core i3 3220 3.30GHz
  • 4x4GB RAM Corsair PC3-12800
  • Seagate Barracuda 2TB 7200.12

The coolermaster case was selected because of the factor that is very silent and it also has a high speed SD reader where the esxi is going to be installed. The removable dust filters and the external SATA dock are also a nice addition. The PSU has a 80+ bronze certification which is good if you want to save power when you leave your server running all day long. Asrock’s motherboard support Intel VT-d which is a nice feature if you want to pass control of devices directly to the virtual machine.

I was more skeptical about the CPU because I knew that choosing an Atom one, would have saved energy but maybe I would have run out of processing power when I would install an ubuntu server media and vpn server. So I chose the Intel Core i3 3220 which unfortunately doesn’t support VT-d but maybe sometime later I would replace that with an i5 that supports it if there is a need in the future

Assembling the server components

Putting all components inside the case was easy apart from closing the side panels. As the case promotes its cable management capabilities, I have to admit that the available space between the side panel and the motherboard’s panel was not much so closing it needed a lot of pushing!

Apart from that I have to admit that after you power it on, you can hardly hear it. The air circulation is not bad and the temperatures are low. Using also only the onboard graphics unit helps to keep the temperature (and power consumption) low

Power Consumption

With 3x2TB, 1x250GB disk and 4 sticks of DDR3 RAM the maximum power consumption while disk write/read and various cpu consuming tasks (like indexing media files) were taking place, is around 70W. When the server is idle the power falls at 50W