ZFS is simply awesome. It simplifies storage management, performs well, is fault-tolerant and scalable and generally is just amazing. I will use this article to demonstrate some of its interesting features. Note that we are only scraping the tip of the ZFS iceberg here; read the official documentation for much more detail. The terms dataset and filesystem are used interchangeably throughout as with ZFS they are essentially the same thing.
When I created my VM I created a bunch of 20GB disks along with it:sol11lab
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
# format < /dev/null Searching for disks...done AVAILABLE DISK SELECTIONS: 0. c8t0d0 <VMware,-VMware Virtual S-1.0-30.00GB> /pci@0,0/pci15ad,1976@10/sd@0,0 1. c8t1d0 <VMware,-VMware Virtual S-1.0 cyl 2608 alt 2 hd 255 sec 63> /pci@0,0/pci15ad,1976@10/sd@1,0 2. c8t2d0 <VMware,-VMware Virtual S-1.0 cyl 2608 alt 2 hd 255 sec 63> /pci@0,0/pci15ad,1976@10/sd@2,0 3. c8t3d0 <VMware,-VMware Virtual S-1.0 cyl 2608 alt 2 hd 255 sec 63> /pci@0,0/pci15ad,1976@10/sd@3,0 4. c8t4d0 <VMware,-VMware Virtual S-1.0 cyl 2608 alt 2 hd 255 sec 63> /pci@0,0/pci15ad,1976@10/sd@4,0 Specify disk (enter its number): |
Even though it will not be the final Zpool/ZFS configuration (I’ll presume, again, this article is being read by andvanced system administrators who have at least worked a little with ZFS) but I will spend a little time creating and destroying pools, and discussing ZFS send/receive, deduplication, ecryption, compression and so on.
First, I’ll create a simple striped RAID0 set using all four free disks:
|
1 2 3 |
# zpool create testpool c8t1d0 c8t2d0 c8t3d0 c8t4d0 'testpool' successfully created, but with no redundancy; failure of one device will cause loss of the pool |
As you can see, zpool warns you that this simple set of disks provides no redundancy – and that the striped set (i.e. RAID0) will be destroyed even if a single pool member fails. Let’s make sure the pool was indeed created how we expected:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# zpool list testpool NAME SIZE ALLOC FREE CAP DEDUP HEALTH ALTROOT testpool 79.5G 92.5K 79.5G 0% 1.00x ONLINE - # zpool status testpool pool: testpool state: ONLINE scan: none requested config: NAME STATE READ WRITE CKSUM testpool ONLINE 0 0 0 c8t1d0 ONLINE 0 0 0 c8t2d0 ONLINE 0 0 0 c8t3d0 ONLINE 0 0 0 c8t4d0 ONLINE 0 0 0 errors: No known data errors |
And that a default ZFS dataset has been created and mounted for the pool:
|
1 2 3 4 5 6 |
# zfs list testpool NAME USED AVAIL REFER MOUNTPOINT testpool 92.5K 78.3G 31K /testpool # df -Zh /testpool Filesystem Size Used Available Capacity Mounted on testpool 78G 31K 78G 1% /testpool |
Here you can see that the pool has been mounted under /<poolname> (in our case /testpool). Additional zfs filesystems (or the root of the zpool itself) can have their mountpoints changed at any time via the zfs set mountpoint command. We won’t spend too much work here, as this isn’t our standard configuration. So let’s destroy the pool:
|
1 |
# zpool destroy testpool |
Our final configuration will be a two-way mirror, (i.e. RAID1 with 2 disks) with a third disk as a hot-spare. However, as we have four disks, let’s create another test configuration – this time RAID0/1:
|
1 |
# zpool create testpool mirror c8t1d0 c8t2d0 mirror c8t3d0 c8t4d0 |
And see if this has had the desired effect:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
zpool status testpool pool: testpool state: ONLINE scan: none requested config: NAME STATE READ WRITE CKSUM testpool ONLINE 0 0 0 mirror-0 ONLINE 0 0 0 c8t1d0 ONLINE 0 0 0 c8t2d0 ONLINE 0 0 0 mirror-1 ONLINE 0 0 0 c8t3d0 ONLINE 0 0 0 c8t4d0 ONLINE 0 0 0 errors: No known data errors |
As I am using virtual hardware, it isn’t too easy to simulate a failure of a disk component – running cfgadm -c unconfigure against one of the disks used in the pool gives an I/O error on the SCSI device. If I had a physical server I’d yank a disk and show you it works. For now; believe that ZFS is highly fault-tolerant, and very easy to recover from a failure (just attach the new device back into the pool once replaced). ZFS is only as fault-tolerant as the RAID level of your pool though. We can create RAIDZ{1,2,3} pools which are RAID5 with x number of parity disks (i.e. RAIDZ2 is RAID6, essentially). We can also add hot-spare disks, logging disks, caching disks, etc. and generally tune ZFS to perform in exactly the way we want.
I will destroy testpool to make way for our final destination zpool and filesystem:
|
1 |
# zpool destroy testpool |
Verify that it’s gone, and all we have is our original rpool:
|
1 2 3 |
# zpool list NAME SIZE ALLOC FREE CAP DEDUP HEALTH ALTROOT rpool 29.5G 4.10G 25.4G 13% 1.00x ONLINE - |