There is already an RFE open for this:
6383119 RFE: add support for using zfs clones when cloning a zone
and we are in the middle of active development on this feature already.
The code we have will automatically create zfs filesystems when you
install new zones, will destroy the zfs filesystem when you uninstall
the zone and will automatically clone the zone using the appropriate
technique based upon the source and target filesystems. We'll be
starting the architectural review process for these new features
shortly. Once those have been approved by the ARC process, the code
should be available within the open solaris source tree.
If you are interested, we can take this over to the zones-interest
alias for further discussion. Maybe you would be interested in taking
a look at the code we already have and seeing how it fits with what
you have been doing.
Mike Gerdts wrote:
> I opened an RFE related to this earlier today, but I have not received any
> indication what the RFE number is. Here is a what the RFE says:
> zoneadm clone is a great feature However, it could be faster and more space
> efficient if it were to bring in the zfs feature set. Currently the command
> zoneadm -z target clone template
> performs a "find | cpio" to copy the data. However, it would be much more
> time, space, and performance efficient for it to have a "zfsclone" method.
> The general algorithm for the new copy_zone_zfs() would be:
> zfs snapshot <fs mounted at zonepath of source_zone>@zone-SUNWzone-<newzone>
> zfs clone <snapshot from above> <pool>/SUNWzone-<newzone>
> zfs setmountpoint=<zonepath of newzone> <pool>/SUNWzone-<newzone>
> Presumably the zfs commands above would really be implemented through the
> zfs API.
> I have implemented what I describe above, using the appropriate calls to
> libzfs. Here is a zone creation in less than 1 second on an Ultra 2:
> # time ksh -x /var/tmp/clone
> + newzone=fast
> + template=template
> + zoneadm=/ws/usr/src/cmd/zoneadm/zoneadm
> + PATH=/usr/bin:/usr/sbin
> + zonecfg -z fast create -t template
> + zonecfg -z fast set zonepath=/zones/fast
> + /ws/usr/src/cmd/zoneadm/zoneadm -z fast clone -m zfsclone template
> Cloning zonepath /zones/template...
> real 0m0.922s
> user 0m0.128s
> sys 0m0.171s
> I have a little bit of cleaning before it is ready for others. Also, I
> would like to get "zoneadm uninstall" to be smart enough to just destory the
> clone and snapshot if it was created with this mechanism.
> Mike Gerdts
> request-sponsor mailing list
> request-sponsor at opensolaris.org