![]() | ||
|
Tech Stuff Pocket Stocks Personal |
FreeNAS - Open Source Storage Server I have been looking for a very cheap mass storage solution for home and test environments. My needs are:
I settled on Sun's ZFS as the filesystem, since it offers both expansion and redundancy. ZFS is native to OpenSolaris, but I decided on FreeNAS 0.7---a Linux distro aimed at running cheap x86-based storage servers. It provides a relatively simple interface to share using CIFS/SMB, iSCSI, FTP, SSH, etc. I've discovered some neat things while reading blog posts and testing on a virtual machine. In the examples below, I list the CLI commands because the FreeNAS GUI doesn't automate some of the more advanced steps. 1) Create a basic ZFS pool
Create a Basic ZFS Pool Creating a ZFS pool from the command line is very simple: zpool create tank mirror da0 da1 (where "tank" is the name of the ZFS pool, and we're creating a virtual device made up of two mirrored disks: da0 and da1) When that command is executed, ZFS automatically creates the filesystem and mounts it as /tank. If you create it from the FreeNAS GUI, it will be mounted at /mnt/tank. I created a pool from two 2GB disks on VirtualBox: freenas:~# zpool status tank
Add Space to an Existing ZFS Pool (while online!) The ZFS pool and filesystem can be expanded without taking it offline. Let's add a mirrored vdev to the above pool using the new 1GB da0 and da1 drives: freenas:~# zpool add tank mirror da0
da1 errors: No known data errors freenas:~# zpool iostat tank Very cool. If you're using SATA, SCSI, or USB drives, you can use this method to add storage without ever taking anything offline.
I started my ZFS/FreeNAS server using a 10GB boot drive and a mirrored pair of 40GB drives for the zpool. If I continue to expand using internal 1TB-2TB drives, I will eventually want to get rid of those 40GB drives to save space. Unfortunately, ZFS does not allow a vdev to be removed. So I'm stuck with that 40GB mirror vdev until I destroy the zpool (and data!). Fortunately there's a workaround. We can replace each 40GB drive with a 1TB drive, and allow the system to resilver (rebuild) onto the new drives. This must be done one drive at a time to avoid data loss. Once that is done, we need to unmount and remount the filesystem. I have seen a sample where an unmount/remount was not needed, so perhaps it can all be done online using the newest ZFS release. Here's the example on FreeNAS, using 1GB and 2GB drives: freenas:~# zpool create tank mirror da0
da1 freenas:~# zpool replace tank da0 da2 freenas:~# zpool iostat tank ZFS doesn't recognize the extra capacity, even though we've swapped up to 2GB disks. We need to export and import the zpool, at least when using FreeNAS. freenas:~# zpool export tank Your IP address is: 38.107.191.80 | |