Tuesday, September 11, 2012

Creating Zone from zone config file or Cloning Solaris Zone

The procedure I've used to clone zones are as follows.

Procedure

1. Export the configuration of the zone you want to clone/copy
    # zonecfg -z zone1 export > zone2.cfg

2. Change the details of the new zone that differ from the existing one (e.g. IP address, data set names, network interface etc.)
    # vi zone2.cfg
3. Create a new (empty, unconfigured) zone in the usual manner based on this configuration file
    # zonecfg -z zone2 -f zone2.cfg

NOTE: if you get capped-memory resource error-- ( move the Capped-memory to the top of rlctl entry)
            # zonecfg -z zone2 -f zone2.cfg
            On line 28 of zone2.cfg:
            The capped-memory resource or a related resource control already exists.
            On line 29 of zone2.cfg:
            Cannot set a resource-specific property from the global scope.
                The ordering error in the generated output makes this statement incorrect, or
                at least inaccurate, depending on the meaning of 'suitable'.

            Workaround
                Edit the exported script and move the rctl entry
                after the capped-memory entry

4. Ensure that the zone you intend to clone/copy is not running
    # zoneadm -z zone1 halt
5. Clone the existing zone
    # zoneadm -z zone2 clone zone1
    Cloning zonepath /export/zones/zone1...
    This took around 5 minutes to clone a 1GB zone (see notes below)
6. Verify both zones are correctly installed
    # zoneadm list -vi

    ID NAME STATUS PATH
        0 global running /
        - zone1 installed /export/zones/zone1
        - zone2 installed /export/zones/zone2

7. Boot the zones again (and reverify correct status)
    # zoneadm -z zone1 boot
    # zoneadm -z zone2 boot
    # zoneadm list -vi
    ID NAME STATUS PATH
    0 global running /
    5 zone1 running /export/zones/zone1
6 zone2 running /export/zones/zone2

8. Configure the new zone via its console (very important)

# zlogin -C zone2

No comments: