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 jeeves export > wooster.cfg

In this instance, I'm taking a copy of the config for zone jeeves and saving it in a filename I'll use for my new zone wooster.

I then modify the new configuration file for the new zone, changes included IP address, data set names, network interface, etc.)

# vi wooster.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 wooster -f wooster.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 jeeves halt

followed by the clone command

# zoneadm -z wooster clone jeeves
Copying /zones/jeeves...

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
  -  jeeves           installed  /zones/jeeves
  -  wooster          installed  /zones/wooster 

so far so good, lets bring them both back online

# zoneadm -z jeeves boot
# zoneadm -z wooster 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
  14 saunders         running    /zones/saunders                native   shared
  17 holmes           running    /zones/holmes                  native   shared
  18 sherlock         running    /zones/sherlock                native   shared
  20 jeeves           running    /zones/jeeves                  native   shared
  22 wooster          running    /zones/wooster                 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 wooster

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 :-)