In the following post I’ll go over what it takes to get FreeNAS installed and working on the new ARTiGO A2000. Since this was my first time ever dealing with FreeNAS I ran into a few glitches along the way. Lucky for you I’ll outline those glitches below so you can avoid making the same mistakes that I made. You should have very little trouble getting a full NAS setup up and running on your A2000; pitfalls aside, I was able to get RAID 1 and CIFS set up in little under an hour.
A description of FreeNAS from their Web site:
FreeNAS is a free NAS (Network-Attached Storage) server, supporting: CIFS (samba), FTP, NFS, AFP, RSYNC, iSCSI protocols, S.M.A.R.T., local user authentication, Software RAID (0,1,5) with a Full WEB configuration interface. FreeNAS takes less than 32MB once installed on Compact Flash, hard drive or USB key.
The minimal FreeBSD distribution, Web interface, PHP scripts and documentation are based on M0n0wall.
Sounds like a perfect fit for the A2000! Because the A2000 supports two 3.5″ hard drives and one CompactFlash card, I opted to install FreeNAS to the CF card. This allows me to use the two 3.5″ hard drives to the maximum, and gives me the ability to RAID (via software in FreeNAS) the two drives should I want to. The rest of this article is based around installing FreeNAS in this way, but if you want to install it in another configuration the directions here should still be helpful.
First off, I didn’t have any luck getting the FreeNAS live CD to boot using an external USB CD drive. It would try to boot, but would die very early on in the process. I was also unsuccessful getting Ubuntu 8.10 to boot all the way up (it died before getting to the desktop). I didn’t spend too much time figuring out why, but my guess is that the Nano-ITX board included with the A2000 isn’t very well supported on these OS’s. If anyone has any luck getting it to boot the live CD off of an external CD drive, go ahead an post in the comments.
In any event, I opted to remove the CompactFlash card and write the image directly using an external USB card reader. Because I was doing this from my Linux desktop, this was a pretty straight-forward process that I will outline below. However, if you’re using Windows, there’s a program the FreeNAS people suggest called physdiskwrite (part of the m0n0wall project) that sounds like it makes it even easier. I didn’t use that program so I can’t comment much about it, but it looks like it amounts to running it from the command line and specifying the image file you want to write and where you want to write it, much like the dd example below.
The first thing you’ll want to do is download the FreeNAS image from their Web site. Like I mentioned before, I wasn’t able to get the live CD to boot, so go for the “embedded” image. I grabbed the latest stable release (at the time of this writing that’s 0.686.4), but they have some recent betas and release candidate builds you could grab if you’re feeling adventurous. Once you have the image downloaded, here’s a little tip: unzip it first. This is one of the areas I got stuck on for a little while, because, even though the file you’ll download ends in .img, it’s actually gzipped. If you know this, it’s easy enough to deal with, but leaving the .gz file extension off caused me an hour or so of tearing my hair out, downloading and re-downloading different images, and almost giving up before I finally found this blog post and was finally able to get a bootable FreeNAS install. I have no idea why the FreeNAS guys chose to leave off the .gz extension; perhaps this is a sick game they like to play on the people trying to download and use their software. If it was mentioned anywhere that the disk image was zipped, I certainly couldn’t find it. Anyway, don’t make the same mistakes I did!
As an aside, if you suspect that a file isn’t exactly what it appears to be you can use the “file” command on a Linux system to try and get a little extra info. For example:
david@W023:~/Desktop$ file FreeNAS-i386-embedded-0.686.4.3374.img
FreeNAS-i386-embedded-0.686.4.3374.img: gzip compressed data, was "image.bin", from Unix, last modified: Fri May 23 09:33:32 2008, max compression
You can see from the output that the file is actually gzipped. If I’d known this before I started it would have saved me some time. You learn something new everyday!
Anyway, so here’s what you need to do to get the disk image onto a hard drive or CompactFlash card using the Linux command line. First, you need to determine which device to write the disk image to. You can find this in a couple of different ways, and it depends somewhat on the device you have attached (card reader, SATA hard drive, etc.) but the easiest way for me was to plug in the card reader I was using with the CF card inserted and then read the output of the dmesg command. Here’s what that might look like:
david@W023:~$ dmesg | tail -n 20[24559.663902] scsi 11:0:0:1: Direct-Access IC USB Storage-SMC 322E PQ: 0 ANSI: 0 CCS[24559.666900] scsi 11:0:0:2: Direct-Access IC USB Storage-MMC 322E PQ: 0 ANSI: 0 CCS[24559.670900] scsi 11:0:0:3: Direct-Access IC USB Storage-MSC 322E PQ: 0 ANSI: 0 CCS[24559.728896] sd 11:0:0:0: [sdb] 1000944 512-byte hardware sectors (512 MB)[24559.731947] sd 11:0:0:0: [sdb] Write Protect is off[24559.731954] sd 11:0:0:0: [sdb] Mode Sense: 00 00 00 00[24559.731958] sd 11:0:0:0: [sdb] Assuming drive cache: write through[24559.748895] sd 11:0:0:0: [sdb] 1000944 512-byte hardware sectors (512 MB)[24559.751877] sd 11:0:0:0: [sdb] Write Protect is off[24559.751883] sd 11:0:0:0: [sdb] Mode Sense: 00 00 00 00[24559.751887] sd 11:0:0:0: [sdb] Assuming drive cache: write through[24559.752356] sdb: sdb1[24559.759196] sd 11:0:0:0: [sdb] Attached SCSI removable disk[24559.759504] sd 11:0:0:0: Attached scsi generic sg2 type 0[24559.786019] sd 11:0:0:1: [sdc] Attached SCSI removable disk[24559.786486] sd 11:0:0:1: Attached scsi generic sg3 type 0[24559.793137] sd 11:0:0:2: [sdd] Attached SCSI removable disk[24559.793522] sd 11:0:0:2: Attached scsi generic sg4 type 0[24559.803079] sd 11:0:0:3: [sde] Attached SCSI removable disk[24559.803455] sd 11:0:0:3: Attached scsi generic sg5 type
This is the output I got after plugging in the card reader. Your output may look slightly different depending on the make and model of your card reader. What we’re looking for is where the CompactFlash is getting attached; if we carefully scan the output above, you’ll notice a line that contains “sdb: sdb1”. In this case, the CF card I was using already had a partition on it, so that’s why we get the /dev/sdb1 instead of just /dev/sdb. Another indicator is that most modern Linux distros will generally “pop up” and mount any newly-attached devices that have partitions on them. If the CF card was not already formatted, you can still see that there is a bunch of information about sdb that isn’t there for the other devices. If you REALLY want to check though you can try the following:
david@W023:~$ cd /sys/block
david@W023:/sys/block$ cat sda/size
david@W023:/sys/block$ cat sdb/size
david@W023:/sys/block$ cat sdc/size
Basically we’re using the handy Linux /sys virtual filesystem (read more about it here if you’re interested) to get some specific information about our block devices. The big thing to notice is that sda and sdb have size, while sdc does not (for reference, sda is my main hard drive). If you’re curious, the size is given in blocks. Because I know I only have one hard drive installed in my system, and no other removeable media plugged in via a USB port OR in the card reader itself, I know that sdb is the CF card.
If you have an “X-in-1” card reader like I do, you’ll probably see a bunch of other drives detected when you plug it in, much like I did in the dmesg output above. Using one (or all) of the processes outlined above you should be able to safely determine where the CF card is and disregard the others.
OK, now that we’ve determined the location of our CF card, we’ll want to cd to the directory where we downloaded the FreeNAS image from earlier. In my case it was the desktop.
david@W023:~$ cd ~/Desktop
Next we’ll do the bulk of the work. We’re going to use the dd command to write the embedded image to the CompactFlash card. Before we get to that, a small digression on dd…
When using dd, you want to be VERY CAREFUL. Always double-check and make sure the “out file” is what you expect; especially make sure it’s not another disk on your system that has valuable data on it or you could overwrite and lose that data. One way to do this is to use the “mount” command with no arguments, and then check to see if the “out file” you’re writing to is mounted anywhere:
david@W023:~/Desktop$ mount | grep sdb
If you see any output at all, check and verify that what’s mounted is what you want to overwrite (and unmount it before using the dd command). In my case there was no output, because the CompactFlash card wasn’t mounted anywhere. If what you see is something like this:
david@W023:~/Desktop$ mount | grep sda
/dev/sda1 on / type ext3 (rw,relatime,errors=remount-ro)
DO NOT USE THAT DEVICE. This is the disk that holds your root partition (indicated by “on /”), which I’m guessing you’re probably not interested in overwriting.
OK, one last warning:
DON’T COPY AND PASTE THE COMMAND BELOW UNLESS YOU’RE SURE YOUR CF CARD IS ATTACHED AS sdb!!!
OK, let’s write our image to the CF card. As noted above, the image is zipped, so we’ll need to it unzip first. We’ll do it the fancy way and unzip and write the image all at once. Here we go!
david@W023:~/Desktop$ gunzip -c FreeNAS-i386-embedded-0.686.4.3374.img | sudo dd of=/dev/sdb
53248+0 records in
53248+0 records out
27262976 bytes (27 MB) copied, 0.635942 s, 42.9 MB/s
An brief explanation of the command above for those interested: the “-c” flag tells gunzip to unzip the file and dump the output to stdout, leaving the original file zipped. We then pipe that output to dd (using the sudo command since I wasn’t logged in as root) and specify /dev/sdb as the “out file” with the “of=/dev/sdb” switch.
That’s it! If everything goes well, you’ll see output similar to that shown above, with information about how many records were read/written, etc. Since FreeNAS is really small (27MB according to the output above), this should take almost no time at all.
Now that you have the image written to the disk, you should be able to pop it back into the A2000. Make sure you have your boot priority set in the BIOS to boot from the CF card first and then fire up the machine.
If your boot priority settings are correct, you’ll eventually get to a nice graphical FreeNAS splash screen. Hit enter on that screen and you’ll get a menu, much like m0n0wall or pfSense® software if you’ve ever used them. You have options to set the administrator credentials for the Web interface, set up any networking interfaces, change the LAN IP address, drop to a shell, etc. By default FreeNAS detects the ethernet port fine and grabs 192.168.1.250 as an IP; if your LAN is on a different subnet, you’ll want to change that address from this menu. You can also change the administrator password, which is probably a good idea. By default, the username and password for a FreeNAS box will be “admin” and “freenas” respectively.
Once you set the address for the box (you can use the “Ping Host” option to test for connectivity) you’ll want to hop on another machine connected to the network and access the web interface by taking your browser to the IP address you set above. From there, you can set up the drives you want to use and how those are exposed via services (such as FTP, CIFS/Samba, etc.). I won’t go into too much detail here, because different people will most likely want to do different things, and the documentation (warning: pdf link) for setting up your drives is very good. However, the process will be something like the following:
- Go to the Disks -> Management section of the Web interface, and add your drives
- Go to the Disks -> Format section and format the drives you just added
- Go to Disks -> Mount Point and mount the partitions you just created
- Go to Services section and expose the drives however you see fit
That’s it! It was very easy to set up a RAID 1 and expose the RAID as a Samba share on my local network. You also have options for setting up FTP, Rsync, etc. It couldn’t be easier.
I did run into a strange issue when I was first adding my drives where there were more drives listed as available to add then were actually installed in the machine. However, I believe this was because one of the drives previously had Vista on it and wasn’t wiped clean before being installed into the A2000. After a little messing around and pulling the drives and wiping them, this issue disappeared. I would recommend wiping your drives clean of all data and partitions before installing them into the A2000 just to avoid any of these sorts of issues.
Like I said before, except for the zipped image and the extra drive issues I ran into, it was a snap setting up FreeNAS on the A2000. If you’ve ever used m0n0wall or pfSense® software, you’ll feel right at home here with FreeNAS. If you have any questions or issues, post them in the comments below, and I’ll do what I can to help. Otherwise, enjoy!