Tuesday, 30 December 2008

Building a SAN with OpenSolaris and ZFS

The one line summary: OpenSolaris and ZFS is very, very cool.

Having created a ZFS pool "datapool" consisting of two 500GB disks in a RAID1 mirror, I then created a few filesystems, including datapool/filestore which was to be the new fileserver. The whole process took two commands:

# zpool create datapool mirror c3d1 c4d1
# zfs create datapool/filestore

To make the new filesystem available over NFS to my Linux machine took another command:

# zfs set sharenfs=rw,anon=0 datapool/filestore

Okay, but what about the Windows box that doesn't support NFS natively? For this, I had to install the SMB server package (along with the kernel extension) and reboot the server. But after that it was simply a case of one more command:

# zfs set sharesmb=on datapool/filestore

The Mac has a very nifty backup tool called Time Machine. To use it you must directly attach a second hard disk, or tweak the configuration to allow for "unsupported" devices to work. I wanted to add in another hard disk to allow me to run Time Machine. Again, OpenSolaris/ZFS to the rescue.

I installed the iSCSI target server software (a couple of ticks in the package manager) and then ran the following commands:

# zfs create -s -V 100GB datapool/mac_backup
# zfs set shareiscsi=on datapool/mac_backup
# iscsitadm list target

The first command creates a "zvol" - a block device that is built from the zpool but does not have ZFS on it. The -s creates a sparse volume so that the space is not-preallocated. The second command makes the volume available over iSCSI, while the third command lists the available iSCSI targets so you can easily get the iSCSI address.

I then downloaded and installed the free globalSAN software for the Mac which provides an iSCSI initiator. Five minutes later (including a reboot of the Mac because it's another kernel extension), I had a new block device ready for partitioning in the Disk Utility. I created a Mac HFS journaled filesystem which Time Machine is able to use.

So one server can now provide simulateous NFS, CIFS/SMB and iSCSI to all my servers. It really is a small SAN at home!

No comments: