Creating and Using Oracle® Solaris Zones

Exit Print View

Updated: May 2015

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.

You must be the global administrator or a user with appropriate authorizations in the global zone to perform this procedure.

  1. Become an administrator.

    For more information, see Using Your Assigned Administrative Rights in Securing Users and Processes in Oracle Solaris 11.2 .

  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.

    To continue the operation and overwrite any preexisting data, use the appropriate –x option to zoneadm clone. The source zone must be uninstalled before the 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

    This option is similar to the zpool create –f command.

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

    Note that the source zone must be halted before the –x force option can be used.

  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 3-4  Applying a System Configuration Profile to a Cloned Zone

To include a configuration profile:

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

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