[Level 2] How Fast to Clone a Zone in OpenSolaris?

How long do I need for clone a new testing zone from a production zone?
10 mins, 20 mins or more? Such kind of answer maybe you think is.
Do not consider about the time that service down spends in your system (for some special AP, that maybe take a long time to stop), it just need few seconds to build a new testing environment.
How could it be so fast? Because OpenSolaris cloning a zone just use the new feature of ZFS clone technology.
When you create a zone and set the zonepath just under a zfs mount point,
the command zoneadm will create a ZFS for your zone.
Ex.
# zfs list rpool/zones
NAME            USED  AVAIL  REFER  MOUNTPOINT
rpool/zones   278M  32.9G    27K  /export/zones

zonecfg> set zonepath=/export/zones/zone1
zonecfg>...

# zoneadm -z zone1 install
A ZFS file system has been created for this zone.

How do we clone a zone with zone1? The step as the following
1. halt source zone
# zlogin zone1 init 5
2. export config from zone1
zonecfg -z zone1 export -f /tmp/zone2.cfg
3. modify zone2 config
# vi /tmp/zone2.cfg
4. create zone2 by import zone2 config
# zonecfg -z zone2 -f /tmp/zone2.cfg
5. clone zone
# zoneadm -z zone2 clone zone1
6. boot zones
# zoneadm -z zone1 boot
# zoneadm -z zone2 boot

Now you can check the ZFS, and you will find out, the zone2 just use few spaces, and the ZFS rpool/zones/zone2 just need few disk space for different data with zone1. And just use the same data (by reference point) with zone1 to save your disk space. That's why you can build a clone zone so fast.
# zfs list -r rpool/zones
NAME                           USED  AVAIL  REFER  MOUNTPOINT
rpool/zones                  278M  32.9G    27K  /export/zones
rpool/zones/zone1              141M  32.9G    22K  /export/zones/zone1
rpool/zones/zone1/ROOT         141M  32.9G    19K  legacy
rpool/zones/zone1/ROOT/zbe     141M  32.9G   140M  legacy
rpool/zones/zone2             498K  32.9G    22K  /export/zones/zone2
rpool/zones/zone2/ROOT        476K  32.9G    19K  legacy
rpool/zones/zone2/ROOT/zbe    457K  32.9G   140M  legacy

With this helps,

regards,
Stanley Huang

Comments

Popular posts from this blog

[Level 2] Shell Interactive With Zenity Episode 5 -- list

[Level 2] iif in Python