The other day I had a junior sysadmin approach me asking for Solaris system with a storage array attached to "practice using ZFS". Apparently he wanted a few drives to be available on the system to be put togeather into a pool to get his feet wet with ZFS administration. Well, he didn't get his wish with getting a dedicated storage array for "sysadmin practice" and not strictly for the reason of unjustified use of hardware reasources, but rather because you don't need a storage array with a number of disks to practice ZFS administration -- ZFS will be just as happy if you give it files as devices in the storage pool. All you need is some spare free storage space for "virtual drives" and you're fully in business of playing with pretty much everything ZFS has to offer. For instance if I wanted to see how RAID-Z array would behave with double parity, which requires more than two drives I can just simulate the drives with three files (of course you can have as many as you want):
Create 3 files 100MB each simulating the correspondingly sized disk drives
# mkdir /data
# cd /data
# mkfile 100m disk1
# mkfile 100m disk2
# mkfile 100m disk3
Now create RAID-Z pool using these "drives":
# zpool create testpool raidz2 /data/disk1 /data/disk2 /data/disk3
Now a zpool with the name testpool should be available and happily mounted under /testpool -- you've got yourself a working ZFS pool without waisting any additional physical resources. Now you can create additional filesystems on that storage pool and test all the neat tricks ZFS has to offer:
# zpool list
NAME SIZE USED AVAIL CAP HEALTH ALTROOT
testpool 286M 200K 286M 0% ONLINE -
# zpool status
pool: testpool
state: ONLINE
scrub: none requested
config:
NAME STATE READ WRITE CKSUM
testpool ONLINE 0 0 0
raidz2 ONLINE 0 0 0
/data/disk1 ONLINE 0 0 0
/data/disk2 ONLINE 0 0 0
/data/disk3 ONLINE 0 0 0
errors: No known data errors
# zfs create testpool/foo
# zfs set quota=50M testpool/foo
# zfs create testpoo/bar
# zfs set quota=100M testpool/bar
# zfs create testpool/foo
# zfs set quota=50M testpool/foo
# zfs create testpool/bar
# zfs set quota=100M testpool/bar
# zfs list
NAME USED AVAIL REFER MOUNTPOINT
testpool 173K 158M 36.6K /testpool
testpool/bar 32.6K 100M 32.6K /testpool/bar
testpool/foo 32.6K 50.0M 32.6K /testpool/foo
To see how ZFS would cope with a failure of one drive and replacing the failed drieve with a spare we can do the following:
1. Let's write some junk into one of the drive effectively corrupting the device:
# dd if=/dev/random of=/data/disk3 bs=1k count=100
2. Lets scrub the pool to make ZFS identify the failure immediately:
# zfs scrub testpool
3. Now we can see that disk3 is effectively toast:
# zpool status
pool: testpool
state: DEGRADED
status: One or more devices could not be used because the label is missing or
invalid. Sufficient replicas exist for the pool to continue
functioning in a degraded state.
action: Replace the device using 'zpool replace'.
see: http://www.sun.com/msg/ZFS-8000-4J
scrub: scrub completed with 0 errors on Wed May 2 12:38:46 2007
config:
NAME STATE READ WRITE CKSUM
testpool DEGRADED 0 0 0
raidz2 DEGRADED 0 0 0
/data/disk1 ONLINE 0 0 0
/data/disk2 ONLINE 0 0 0
/data/disk3 UNAVAIL 0 0 0 corrupted data
errors: No known data errors
Yep, disk3 is corrupt alright, but RAID-Z should be taking care of that and all of our data should still be available.
4. Now let's create a spare "drive" that we will use to replace the failed disk3 component:
# mkfile 100m disk4
5. Let's replace the failed "disk" with a newly created spare and see what happens:
# zpool replace testpool /stuff/disk3 /stuff/disk4
# zpool status
pool: testpool
state: DEGRADED
scrub: resilver completed with 0 errors on Wed May 2 12:42:17 2007
config:
NAME STATE READ WRITE CKSUM
testpool DEGRADED 0 0 0
raidz2 DEGRADED 0 0 0
/data/disk1 ONLINE 0 0 0
/data/disk2 ONLINE 0 0 0
replacing DEGRADED 0 0 0
/data/disk3 UNAVAIL 0 0 0 corrupted data
/data/disk4 ONLINE 0 0 0
errors: No known data errors
So we see that reslivering of a new drive was successfully completed and we now have got 3 normally operating "drives" in the pool -- we're back to normal.
4. After just a little bit of time ZFS will complete the replacement procedure and the failed "drive" will be out of the pool completely - everything is running like nothing happened:
# zpool status
pool: testpool
state: ONLINE
scrub: resilver completed with 0 errors on Wed May 2 12:42:17 2007
config:
NAME STATE READ WRITE CKSUM
testpool ONLINE 0 0 0
raidz2 ONLINE 0 0 0
/data/disk1 ONLINE 0 0 0
/data/disk2 ONLINE 0 0 0
/data/disk4 ONLINE 0 0 0
errors: No known data errors
It goes without saying that using files as devices should be used only for training and experimenation and certainly not in production, since there is little to be gained from using ZFS in this fashion. Other than that give it a whirl and I'm sure you'll want to deploy ZFS in productionon using real hardware after that - ZFS is an absolutely beautiful piece of technology.