Go to main content

Creating and Using Oracle® Solaris Zones

Exit Print View

Updated: August 2019
 
 

How to Install and Deploy Zones by Cloning

This procedure describes how to clone a source zone to install new zones.

  1. If necessary, shut down the source zone.
  2. Export the zone's configuration to a file.
    global$ zonecfg -z source-zone export -f path-to-filename
  3. For every new zone you want to configure and install, do the following:
    1. Edit the exported file so that any zone-specific parameter is set for the new zone.

      For example, the zonepath, if defined, would need to be changed.

    2. Configure the new zone with the exported file.
      global$ zonecfg -z new-zone -f path-to-filename
    3. Install the new zone by cloning the source zone.
      global$ zoneadm -z new-zone clone [-c full-path-to-profile.xml] source-zone

      Specify the –c option if you are using a configuration profile. See Using Manifests and Configuration Profiles for information.

    4. Boot the new zone.
      global$ zoneadm -z new-zone boot
    5. If you did not use a configuration profile, manually configure the system information.

      Refer to Step 5 of How to Create and Deploy a Non-Global Zone for instructions.

Example 3  Creating Multiple Zones From a Source Zone

    This example shows how to create three non-global zones from zoneA:

  • Three zones to be created are zone0, zone1, and zone2.

  • The zonepath of zoneA is defined. Thus, this parameter needs to be adjusted for each new zone.

  • Each zone has a corresponding configuration profile (/var/tmp/zonename.xml) to be used at installation time.

Shut down the zone if necessary.
global$ zoneadm -z zoneA shutdown
global$ zoneadm list -cv
ID NAME     STATUS     PATH           BRAND     IP
0  global   running    /              solaris   shared
   zoneA    installed  /zones/zonea   solaris   exclusive

Export the configuration.
global$ zonecfg -z zoneA export -f /var/tmp/zoneA.txt
global$ cat /var/tmp/zoneA.txt
create -b
set brand=solaris
set zonepath=/zones/zonea
set autoboot=true

Edit /var/tmp/zoneA.txt to set zonepath to /zones/zone0. Then configure zone0 with /var/tmp/zoneA.txt.

global$ zonecfg -z zone0 -f /var/tmp/zoneA.txt
global$ zonecfg -z zone0 info
zonename: zone0
brand: solaris
zonepath: /zones/zone0specific to zone0
autoboot: true

For each of the remaining zone, repeat editing the zonepath and configuring the zone. After all the new zones are configured, they will be listed as being in the configured state.

global$ zoneadm list -cv
ID NAME     STATUS      PATH           BRAND     IP
0  global   running     /              solaris   shared
   zoneA    installed   /zones/zonea   solaris   exclusive
   zone0    configured  /zones/zone0   solaris   exclusive
   zone1    configured  /zones/zone1   solaris   exclusive
   zone2    configured  /zones/zone2   solaris   exclusive

Clone the source zone to create the three zones.

global$ zoneadm -z zone0 clone -c /var/tmp/zone0.xml zoneA
global$ zoneadm -z zone1 clone -c /var/tmp/zone1.xml zoneA
global$ zoneadm -z zone2 clone -c /var/tmp/zone2.xml zoneA

global$ zoneadm list -cv
ID NAME     STATUS     PATH           BRAND     IP
0  global   running    /              solaris   shared
   zoneA    installed  /zones/zonea   solaris   exclusive
   zone0    installed  /zones/zone0   solaris   exclusive
   zone1    installed  /zones/zone1   solaris   exclusive
   zone2    installed  /zones/zone2   solaris   exclusive

global$ zoneadm -z zone0 boot
global$ zoneadm -z zone1 boot
global$ zoneadm -z zone2 boot

global$ zoneadm list -cv
ID NAME     STATUS     PATH           BRAND     IP
0  global   running    /              solaris   shared
   zoneA    installed  /zones/zonea   solaris   exclusive
1  zone0    running    /zones/zone0   solaris   exclusive
2  zone1    running    /zones/zone1   solaris   exclusive
3  zone2    running    /zones/zone2   solaris   exclusive

Creating a Source Zone

As an option, you can create a zone solely for use as a source to provision new zones. Configure the zone's global properties with settings that remain stable and universally applicable, such as autoboot and so on. You can also explicitly specify its brand so you know to use this source to install other zones of the same brand. Make sure to name the zone in a way to easily identify it as only a source zone. The zone would not be booted to prevent its being used.