Ok, now it is official: Mac OS X Leopard (Build 9a321) features support for ZFS. The rumors were true, you can create disk images with a ZFS filesystem, well at least in theory, because Build 9a321 is far away from being stable. The DiskUtility itself crashes again and again. Trying to create an actual ZFS image produces kernel panics. There is no pool support to create stripes, mirrors or even RaidZ in DiskUtility yet.
It seems that all the other rumor sites stopped right there, which is why we had to set up this website to show you how well ZFS is already implemented. We show you what works and what doesn’t. After reading you will know what the deal is, with ZFS and the upcoming Mac OS.
What most people are missing is the existance of command-line tools. The big news is, with Build 9a321, there is not only a ZFS.kext kernel extension, but there are also a bunch of command-line tools to manage your ZFS filesystems (as you will see as you read along). With these tools it is possible to create stripes, mirrors and RaidZ with ZFS!
I played around to find out how well ZFS is already implemented in 10.5. Here is what I did:
First, I simply added two SATA-disks with the following command-line: (I’m using files as disks now, because its much faster to play with.)
1> sudo zpool create tank mirror /Users/themachacker/test1 /Users/themachacker/test2
and boom – theres a zpool with 200MB (this is the size of the pool, not the usable size for filesystems in it)
1> sudo zpool status pool: tank state: ONLINE scrub: none requested config: NAME STATE READ WRITE CKSUM tank ONLINE 0 0 0 mirror ONLINE 0 0 0 /Users/themachacker/test1 ONLINE 0 0 0 /Users/themachacker/test2 ONLINE 0 0 0 errors: No known data errors 1> sudo zpool list NAME SIZE USED AVAIL CAP HEALTH ALTROOT tank 95.5M 90K 95.4M 0% ONLINE -
Now we are enabling compression:
1> sudo zfs set compression=on tank 1> sudo zfs get all NAME PROPERTY VALUE SOURCE tank type filesystem - tank creation Tue Dec 19 2:49 2006 - tank used 87K - tank available 63.4M - tank referenced 24.5K - tank compressratio 1.00x - Bus error
Oops… we ran into a bug here, but the OS still is running.
Then I copied the sources of postgresql into it to test the compression ratio.
1> sudo zfs get all NAME PROPERTY VALUE SOURCE tank type filesystem - tank creation Tue Dec 19 2:49 2006 - tank used 54.3M - tank available 9.21M - tank referenced 54.1M - tank compressratio 1.88x - Bus error 1> du -sk postgresql-8.2.0 102008 postgresql-8.2.0
Originally the folder was about 100MB. With ZFS and compression it only uses 54M.
The fun thing is: you can turn compression on and off as you wish – all the time, even while the copy process is still running. The same applies for the checksum algorithm you want to use (fletcher2, fletcher4 or sha256).
Now I will delete one part of the mirror and create an empty one:
1> rm test2 1> mkfile 100m test2
how does it look now?
1> sudo zpool status pool: tank state: ONLINE scrub: none requested config: NAME STATE READ WRITE CKSUM tank ONLINE 0 0 0 mirror ONLINE 0 0 0 /Users/themachackers/test1 ONLINE 0 0 0 /Users/themachackers/test2 ONLINE 0 0 0 errors: No known data errors
ZFS has not detected anything. But you can check your pool with:
1> sudo zpool scrub tank 1> sudo zpool status pool: tank state: ONLINE status: One or more devices has experienced an unrecoverable error. An attempt was made to correct the error. Applications are unaffected. action: Determine if the device needs to be replaced, and clear the errors using 'zpool clear' or replace the device with 'zpool replace'. see: http://www.sun.com/msg/ZFS-8000-9P scrub: scrub completed with 0 errors on Tue Dec 19 03:04:12 2006 config: NAME STATE READ WRITE CKSUM tank ONLINE 0 0 0 mirror ONLINE 0 0 0 /Users/themachackers/test1 ONLINE 0 0 0 /Users/themachackers/test2 ONLINE 0 0 5.67K errors: No known data errors
After the scrub it found out that one half is missing. Other Raid0 implementations would copy the whole disk again – not ZFS. It knows, which parts are used and and only copies these. That’s the improvement over solutions like LVM. On big disks you would watch the progress, in our case it already reports that scrub has completed.
So I do what it says:
1> sudo zpool clear tank 1> sudo zpool status pool: tank state: ONLINE scrub: scrub completed with 0 errors on Tue Dec 19 03:04:12 2006 config: NAME STATE READ WRITE CKSUM tank ONLINE 0 0 0 mirror ONLINE 0 0 0 /Users/themachackers/test1 ONLINE 0 0 0 /Users/themachackers/test2 ONLINE 0 0 0 errors: No known data errors
Everything is fine again – what now? I think we should make our pool bigger. We buy bigger disks, in our case two new bigger files with 200MB each. You can then replace the older smaller disk. You could also make them mirrors and add them to the pool. But I want to replace the old ones to give them away:
1> sudo zpool replace tank /Users/themachackers/test1 /Users/themachackers/test3 1> sudo zpool replace tank /Users/themachackers/test2 /Users/themachackers/test4
So, what does it say now?
1> sudo zpool list NAME SIZE USED AVAIL CAP HEALTH ALTROOT tank 196M 54.4M 141M 27% ONLINE -
But we are also interested in the usable size:
1> sudo zfs list NAME USED AVAIL REFER MOUNTPOINT tank 54.3M 109M 54.1M /tank
I made my old drives unused – which is exactly what I wanted. Simply think that your small tower can’t handle more than two drives.
To see what happened to your zpool you can look at the history of the commands:
1> sudo zpool history tank History for 'tank': 2006-12-19.02:49:12 zpool create tank mirror /Users/themachackers/test1 /Users/themachackers/test2 2006-12-19.02:55:37 zfs set compression=on tank 2006-12-19.03:04:11 zpool scrub tank 2006-12-19.03:08:59 zpool clear tank 2006-12-19.03:12:24 zpool replace tank /Users/themachackers/test1 /Users/themachackers/test3 2006-12-19.03:12:39 zpool replace tank /Users/themachackers/test2 /Users/themachackers/test4
Since this feature came to open solaris only some weeks ago you can see that Apple is not very far behind with their code. It also supports RaidZ2 (the RaidZ version which supports double parity). You can see that with the following command:
1> sudo zpool upgrade -v This system is currently running ZFS version 3. The following versions are suppored: VER DESCRIPTION — ——————————————————– 1 Initial ZFS version 2 Ditto blocks (replicated metadata) 3 Hot spares and double parity RAID-Z For more information on a particular version, including supported releases, see: http://www.opensolaris.org/os/community/zfs/version/N Where ‘N’ is the version number.
Since I’m testing this on a nice MBP C2D I don’t know if it also runs on PPC. But it looks like it does according to this:
1> file /System/Library/Extensions/zfs.kext/Contents/MacOS/zfs /System/Library/Extensions/zfs.kext/Contents/MacOS/zfs: Mach-O universal binary with 2 architectures /System/Library/Extensions/zfs.kext/Contents/MacOS/zfs (for architecture i386): Mach-O object i386 /System/Library/Extensions/zfs.kext/Contents/MacOS/zfs (for architecture ppc): Mach-O object ppc
Ok, that’s enough for tonight. But there is alot more to expore like: snapshots, clones and other cool features you don’t see in the usual filesystems.
