Cloning a Solaris zone
The beauty of zones under Solaris for me is the ability to clone any zone and then easily adapt it for it's new resources and function. I wrote this post as an occasional reminder for myself, but also to share with you the steps undertaken to achieve this goal.
At present I have a SunFire V490 system running 5 zones; each installed under /zones but with there own unique IP address and datasets; I need to clone one of these zones so I'll share with you my ssteps taken from this incident:
Firstly, we need to export the configuration for the zone I wish to clone
# zonecfg -z pinky export > perky.cfg
In this instance, I'm taking a copy of the config for zone pinky and saving it in a filename I'll use for my new zone perky.
I then modify the new configuration file for the new zone, changes included IP address, data set names, network interface, etc.)
# vi perky.cfg
The main reason for editing the configuration file, is that I give each of my zones a unique IP address, there own data sets, for load balancing I change the network interface, etc.
Once happy with my config change I created an unconfigured zone based on my new configuration file:-
# zonecfg -z perky -f perky.cfg
We now need to shutdown the zone I am cloning in order to copy it's contents (I've not found a method yet of performing a clone of a live/active zone, maybe someone can enlighten me)
# zoneadm -z pinky halt
followed by the clone command
# zoneadm -z perky clone pinky Copying /zones/pinky...
the cloning finished in ~20minutes for the 18GB zone I cloned
after verifying that the new zone is installed correctly
# zoneadm list -vi ID NAME STATUS PATH BRAND IP 0 global running / native shared 13 french running /zones/french native shared 14 saunders running /zones/saunders native shared 17 holmes running /zones/holmes native shared 18 sherlock running /zones/sherlock native shared - pinky installed /zones/pinky - perky installed /zones/perky
so far so good, lets bring them both back online
# zoneadm -z pinky boot # zoneadm -z perky boot
One final check to confirm they are up and running
# zoneadm list -vi ID NAME STATUS PATH BRAND IP 0 global running / native shared 13 french running /zones/french native shared 17 holmes running /zones/holmes native shared 22 perky running /zones/perky native shared 20 pinky running /zones/pinky native shared 14 saunders running /zones/saunders native shared 18 sherlock running /zones/sherlock native shared
and finally all I need to do is login to the new zone and tweak my configuration for the new zone accordingly
# zlogin -C perky
After this I am able to log into my new zone, directly using ssh or from the global zone using zlogin. I can confirm that everything is up and running smoothly, and all the packages, services, security settings, and user configuration are all now available under my new zone :-)