By dgolds on Oct 09, 2007
ZFS, available from Solaris 10 update 2 on, is one amazing piece of technology. Bloggers like Drew get what I get about ZFS, which is that once you grok its features and start combining them, you can do some weird and wonderful things.
State management of training machines is something I've been trying to do well for about 15 years now. I've been through a lot of technologies like Norton ghost, scripting, jumpstarting, and OS virtualized images and while they all work, they also have limitations that often make me have to settle for less than what I really want to do.
So I was playing around with a VMware Solaris 10 Update 2 a couple of months ago that had /z, a big ol' ZFS file system, about 5 GB on it, and a whole root zone completely encapsulated within the ZFS file system. Here's what I was able to do with it:
- First, I took a ZFS snapshot called z@machinestartstate.
- I booted and logged into the whole root zone.
- I set the zone up to have the start state for one of the classes for which I am responsible. Let's call it class 1.
- I took another ZFS snapshot called z@class1startstate.
- I saved the deltas between the two snapshots: zfs send -i z@machinestartstate z@class1startstate > machinestartstate.class1startstate.
- I did Lab 1.
- I took another ZFS snapshot called z@class1lab1endstate.
- I saved the deltas between the two snapshots: zfs send -i z@class1startstate z@class1lab1endstate > class1startstate.z@class1lab1endstate.
- I did Lab 2.
- I took another ZFS snapshot called z@class1lab2endstate.
- I saved the deltas between the two snapshots: zfs send -i z@class1lab1endstate z@class1lab2endstate > class1lab1endstate.class1lab2endstate.
- I followed the same steps for Labs 3 through 10, and then did the same things for 5 other classes I am responsible for.
- zfs rollback -r z@machinestartstate always takes me back to the original virtual machine state.
- zfs recv < machinestartstate.class1startstate restores the start state for class 1.
- zfs recv < class1startstate.class1lab1endstate restores the end state for Lab 1 of class 1.