Updated 3 April 2009
Linux Logo

Cloning a Solaris Zone


Description:
  • This procedure describes how to clone a Solaris Zone. That is make a new working zone from an existing zone.
Prerequisites:
  • Access to the global zone server. You must have super user access
Notes:
  • Cloning a zone requires that the zone that is copies be halted or not running before creating a clone.
  • After the new zone is created by cloning and has started, it must be login from the console and the language and network parameters must be assigned.
References:

Step Action Description
1 Use zoneadm list on the global zone server to show status of zone and select the zone you wish to clone,
# /usr/sbin/zoneadm list -vi

On the global zone, use the zoneadm list -vi to show current status of all installed zones.

global# /usr/sbin/zoneadm list -vi
  ID NAME             STATUS         PATH                           BRAND    IP
   0 global           running        /                              native   shared
   2 lqwdev           running        /zonepool/lqwdev               native   shared
   5 lqweb            running        /zonepool/lqweb                native   shared
   6 mysparse         running        /zonepool/mysparse             native   shared
global# 

On the global zone, use the zoneadm list -vc to show current status of all configured zones.

global# /usr/sbin/zoneadm list -ci
  ID NAME             STATUS         PATH                           BRAND    IP
   0 global           running        /                              native   shared
   2 lqwdev           running        /zonepool/lqwdev               native   shared
   5 lqweb            running        /zonepool/lqweb                native   shared
   6 mysparse         running        /zonepool/mysparse             native   shared
   - mywhole          installed      /zonepool/mywhole              native   shared
global# 
Note: You may also use /usr/sbin/zoneadm -z <zone name> list -v to verify the specific zone status.
2 Use the export option with zonecfg -z to create a configuration file of the selected zone by directing the output to a file,
# zonecfg -z <zone name> export <file name>
  On the global zone, create a configuration file of the selected zone by issing zonecfg -z <selected zone> export <configuration file name> which redirects the output to a file. By convention the name of the file is usually the new zone name with a cfg suffix. This file can be created anywhere.
global# /usr/sbin/zonecfg -z mysparse export | sed 's/mysparse/mysparse2/' | zonecfg -z mysparse2
mysparse2: No such zone configured
Use 'create' to begin configuring a new zone.
global# 
3 Edit the configuration file and change the appropriate parameters (e.g. filename and network)
# vi <new zone name>.cfg

Edit the configuration file created in the previous step and change the zonepath parameter, the network parameters and any other parameters that my be required. This examples will call the clone zone mysparse2.

bash-3.00# zonecfg -z mywhole2
zonecfg:mywhole2> info
zonename: mywhole2
zonepath: /zonepool/mywhole2
brand: native
autoboot: true
bootargs:
pool:
limitpriv:
scheduling-class:
ip-type: shared
net:
        address: 192.168.3.188/24
        physical: e1000g0
        defrouter: 255.255.255.0
zonecfg:mywhole2>
4 Use zoneadm -z with the halt option to start an instlled zone.
# zoneadm -z <zone name> halt

On the global zone, Boot the new zone by issuing zoneadm -z <zonename> halt.

global# zoneadm -z mysparse halt
Note:
  • When a zone is halted, its status will change to installed.
global# /usr/sbin/zoneadm list -vi
  ID NAME             STATUS         PATH                           BRAND    IP
   0 global           running        /                              native   shared
   2 lqwdev           running        /zonepool/lqwdev               native   shared
   5 lqweb            running        /zonepool/lqweb                native   shared
   - mysparse         installed      /zonepool/mysparse             native   shared
global# 
5 Use zoneadm -z with the clone option to clone the zone.
# zoneadm -z <new zone> clone <existing zone>
On the global zone, use zoneadm -z with the clone option to create a new zone.
global# zoneadm -z mysparse2 clone myzone
Cloning zonepath /zones/mysparse...
global# 

This will take the amount of time that is required to copy the filesystem of the clone instance.

6 Start the new zone with zoneadm -z with the boot option to start the new zone.
# zoneadm -z <new zone> boot
On the global zone, use zoneadm -z with the boot option to start with the new zone.
global# zoneadm -z mysparse2 boot
global# 
7 Use zlogin -c to the new zone and configure the language, timezone and network parameters.
# zlogin -C <new zone> On the global zone, use zlogin -C to the new zone.
global# zlogin -C mysparse2
[Connected to zone 'mysparse2' console]
When log in to a newly clone zone for the first time you will be prompted to configure the langauge, time zone and network parameters.
Click for more info