Faster zone provisioning using zoneadm clone
In a recent thread on zones-discuss@opensolaris.org about creating zones in parallel to reduce the time it takes to provision multiple zones, it was suggested that the new zoneadm clone subcommand could be of help. The zoneadm clone subcommand (available from build 33 onwards) copies an installed and configured zone. Cloning a zone is faster than installing a zone, but how much faster? To find out I did some quick experiments creating and cloning both whole root and sparse root zones on a V480:
Creating a whole root zone:
# zonecfg -z zone1 zone1: No such zone configured Use 'create' to begin configuring a new zone. zonecfg:zone1> create -b zonecfg:zone1> set zonepath=/zones/zone1 zonecfg:zone1> exit # time zoneadm -z zone1 install time zoneadm -z zone1 install Preparing to install zone. Creating list of files to copy from the global zone. Copying <123834> files to the zone. Initializing zone product registry. Determining zone package initialization order. Preparing to initialize <986> packages on the zone. Initialized <986> packages on zone. Zone is initialized. Installation of these packages generated errors: The file contains a log of the zone installation. real 13m40.647s user 2m49.840s sys 4m43.221s
Cloning a whole root zone:
# zonecfg -z zone1 export|sed -e 's/zone1/zone2/'|zonecfg -z zone2 zone2: No such zone configured Use 'create' to begin configuring a new zone. # time zoneadm -z zone2 clone zone1 Cloning zonepath /zones/zone1... real 8m4.615s user 0m9.780s sys 2m18.334s
For the whole root zone cloning is almost twice a fast as a regular install.
Creating a sparse root zone:
# zonecfg -z zone3 zone3: No such zone configured Use 'create' to begin configuring a new zone. zonecfg:zone3> create zonecfg:zone3> set zonepath=/zones/zone3 zonecfg:zone3> exit # time zoneadm -z zone3 install Preparing to install zone. Creating list of files to copy from the global zone. Copying <2535> files to the zone. Initializing zone product registry. Determining zone package initialization order. Preparing to initialize <986> packages on the zone. Initialized <986> packages on zone. Zone is initialized. Installation of these packages generated errors: The file contains a log of the zone installation. real 6m3.227s user 1m45.902s sys 2m47.717s
Cloning a sparse root zone:
# zonecfg -z zone3 export|sed -e 's/zone3/zone4/'|zonecfg -z zone4 zone4: No such zone configured Use 'create' to begin configuring a new zone. # time zoneadm -z zone4 clone zone3 Cloning zonepath /zones/zone3... real 0m11.535s user 0m0.706s sys 0m6.440s
For the sparse root zone, cloning is more than thirty times faster then installing!
So if you need to provision multiple zones of a certain configuration, zoneadm clone is clearly the way to go.
Note that the current clone operation does not (yet) take advantage of ZFS. To see what ZFS can do for zone cloning, have a look at Mike Gerdts' blog: Zone created in 0.922 seconds. Goodness indeed.
T: OpenSolaris Zones
( Mar 18 2006, 07:12:17 PM CET ) Permalink Comments [4]Comments are closed for this entry.


Posted by David Comay on March 18, 2006 at 11:39 PM CET #
I'll take two ZFS sparse zones with the "zoneadm clone" option, please. :)
Oh -- can I follow that with a non-sparse ZFS zoneadm clone please?
Thank you very much. :)
Does anyone else remember how long it took to load Interactive Unix on a Compaq 386 machine from approx. 27 floppy disks!.
Boy - what I could have done with those man-hours.....
Posted by Al Hopper on March 19, 2006 at 01:42 AM CET #
Posted by Jerome on May 16, 2006 at 04:08 PM CEST #
Creating, deleting and then recreating a zone is not as fast as a 'clone'. Recreating the zone is a normal 'install' (i.e. pkgadd all the packages), while a 'clone' is simply a cpio of an existing zone (slightly simplified, of course). The impact of the pkgadd far outweighs the advantage you get of having the files cached:
The caching of the files saves you about 30 seconds of the 14 minutes on the 'install', the 'clone' only takes 55 seconds in total....Posted by 192.18.1.9 on May 17, 2006 at 11:23 AM CEST #