How to create a lot of zones (and delete them afterwards)

Sometimes, e.g. in educational contexts, or for testing purposes, you might want to create a number of zones in one step and delete them later. In this entry, I am describing one possible way of doing this. Other tools are already well-known (e.g. zonemgr), but with a different focus.

The basic steps are as follows:

  1. Create a zone that you want to clone.
  2. Boot that zone so that the SMF manifests are imported.
  3. Customize that zone as you like.
  4. Set some basic parameters in the CUSTOMIZE section of the script.
  5. Start the script and wait for its completion. The creation of one zone can take about 15 to 30 seconds, depending on the server you are using.
The script performs the following steps for each zone, after performing some small calculations, e.g. for creating the default route, the netmask, and the root password:
  1. The IP address and the zone name and zone root path are determined.
  2. The zone configuration file is created.
  3. The sysidcfg file is created.
  4. The zone root path of the source zone is determined
  5. If that zone root path and the destination root path are both on a ZFS file system, zone cloning is performed using ZFS snapshots.
  6. Using the zonecfg command and the zone configuration file, the zone is configured.
  7. Then, the zone is cloned, using the zoneadm command.
  8. The sysidcfg file is copied to the etc directory of the zone, and the .UNCONFIGURED file is deleted from that directory.
  9. The zone is then left in the installed state, brought to the ready state, or booted. Bringing it to the ready state will configure the zone's IP interface and reduce the boot time of the zone.

Click here to download the zone cloning script. Another script, delete-cloned-zones, can then be used to delete these zones. It searches the list of zones for a certain pattern, halts and deletes each zone and then destroys each of these zone's zfs file systems. Be sure to test this script carefully!

I'll post a sample zone cloning and deleting session in my next blog entry.

Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

blogfinger

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today