Go to main content

Creating and Using Oracle® Solaris Zones

Exit Print View

Updated: April 2019

Cloning a Non-Global Zone on the Same System

Use cloning to provision a new zone on a system by copying the data from a source zonepath to a target zonepath.

When the source zonepath and the target zonepath both reside on ZFS and are in the same pool, the zoneadm clone command automatically uses ZFS to clone the zone. However, you can specify that the ZFS zonepath be copied and not ZFS cloned.

How to Clone a Zone

You must configure the new zone before you can install it. The parameter passed to the zoneadm create subcommand is the name of the zone to clone. This source zone must be halted.

  1. Become a zone administrator.

    For more information, see Assigning Limited Rights to Zone Administrators.

  2. Halt the source zone to be cloned, which is my-zone in this procedure.
    global$ zoneadm -z my-zone halt
  3. Start configuring the new zone by exporting the configuration of the source zone my-zone to a file, for example, master.
    global$ zonecfg -z my-zone export -f /zones/master

    Note -  You can also create the new zone configuration using the procedure How to Configure the Zone instead of modifying an existing configuration. If you use this method, skip ahead to Step 6 after you create the zone.
  4. Edit the file master.

    Set different properties and resources for the components that cannot be identical for different zones. For example, you must set a new zonepath.

    • For a shared-IP zone, the IP addresses in any net resources must be changed.

    • For an exclusive-IP zone, the physical property of any net resource must be changed.

  5. Create the new zone, zone1, by using the commands in the file master.
    global# zonecfg -z zone1 -f /zones/master
  6. Install the new zone, zone1, by cloning my-zone.
    global# zoneadm -z zone1 clone my-zone

    The system displays:

    Cloning zonepath /zones/my-zone...
  7. (Optional) If a storage object contains any preexisting partitions, zpools, or UFS file systems, the clone fails, and an error message is displayed use the appropriate –x option to zoneadm clone.

    This continues the operation and overwrites any preexisting data. This option is similar to the zpool create -f command.

    Note -  The source zone must be halted and uninstalled before the -x force subcommand can be used.
    • -x force-zpool-import

    • -x force-zpool-create=zpoolname

    • -x force-zpool-create=zpoolname1,zpoolname2,zpoolname3

    • -x force-zpool-create-all

    The –x force-zpool-create=zpoolname option can be used multiple times.

  8. List the zones on the system.
    ID  NAME     STATUS       PATH                           BRAND      IP
     0  global   running      /                              solaris    shared
     -  my-zone  installed    /zones/my-zone                 solaris    excl  
     -  zone1    installed    /zones/zone1                   solaris    excl  
Example 4  Applying a System Configuration Profile to a Cloned Zone

Provide an absolute path to the configuration file:

# zoneadm -z zone1 clone -c /path/config.xml my-zone

Note that you must provide an absolute path to the configuration file.