Sunday 5 April 2009

ZFS and BSD

So for a client of mine I have been looking into ZFS for BSD.

He needed the ability to add drives to an array and have the filesystem grow to take advantage of the new space.

BSD volume management is pretty lacking atm (without zfs) linux has LVM which works pretty well for them. However with all the pvcreate lvgroup extendfs pvscan etc there are alot of tools to learn.

In steps FreeBSD...

There are bascially 2 tools
zpool and zfs

So how do I create a volume?

zpool create mytankname raidz da0 da1 da2

For those that have RAID experience this will create something like a RAID5 array.

It will also automount it to /mytankname

Now imagine you then had to add some more disks..

zpool add mytankname raidz da3 da4

This would automagically add da3 + da4 to the array.

New space will be avalible as soon as the command has been issued.

Get the status of your array like this

zpool status mytankname

Space like this:
zpool list

Unmount filesystem like this:
zfs umount mytankname

and mount it like this:
zfs mount mytankname


Dont forget to make sure that it starts at boot:
echo 'zfs_enable="YES"' >> /etc/rc.conf


Things to be careful of:
ZFS is experimental atm
If you machine is currently doing swapping then ZFS probably isnt the best choice atm
Once you have choosen the vdev i.e. raidz disk spare mirror only add the same of that type, this means that once you do
zpool create tank mirror da0 da1
do NOT do
zpool add -v tank da2

As the failure of da2 will take the whole array with it



Other tips:
More info on compression alternative roots etc here
http://wiki.freebsd.org/ZFSQuickStartGuide

Live videos:
Add/replace
http://people.freebsd.org/~pjd/misc/zfs/zfs_add_replace.swf
Compressions/gzip
http://people.freebsd.org/~pjd/misc/zfs/zfs_compression.swf
Snapshot
http://people.freebsd.org/~pjd/misc/zfs/zfs_snapshot.swf

http://people.freebsd.org/~pjd/misc/zfs/zfs_ufs-on-zvol.swf

No comments: