Setting Up Your Development Environment on OpenSolaris
Isolating Your Development Work Using Zones
You might want to develop and test different applications in different zones in the OpenSolaris OS. Applications running in different zones do not interact and do not directly compete for resources.
Using zones is also a good way to deploy applications that need to stay separate.
A zone is a virtualized operating system environment within a single instance of the Solaris 10 OS or OpenSolaris OS. A zone is an application execution environment in which processes are isolated from the rest of the system. Processes that are running in one zone cannot monitor or affect processes running in other zones. Even a process running with superuser credentials cannot view or affect activity in other zones.
Every Solaris system contains a global zone. The global zone is both the default zone for the system and the zone used for system-wide administrative control. Only the global zone is bootable from the system hardware.
In this discussion, the term zone means non-global zone. Non-global zones must be configured, installed, managed, and uninstalled from the global zone.
Each zone is assigned a zone name. Each zone also has a node name that is independent of the zone name. The node name is assigned by the administrator of the zone.
Each zone is given a unique numeric identifier, which is assigned by the system when the zone is booted. Each zone has a path to its root directory that is relative to the global zone's root directory.
Other resources and properties are optional. A shared-IP zone is the easiest to create if you need network connectivity. The shared-IP zone is the default type.
Creating a Zone: Steps
Take the following steps to create a zone:
- Use the zonecfg(1M) command to configure a zone. Specify various parameters for the zone's virtual platform and application environment. You must specify a name and path for the zone.
- Use the zoneadm(1M) command to install the configured zone. Install software at the package level into the file system hierarchy established for the zone.
- If you plan to use an /etc/sysidcfg file to perform initial zone configuration, create the sysidcfg file and place it the zone's /etc directory before you boot the zone.
- Use the zoneadm command to boot the zone.
- Use the zlogin(1) command to log in to the zone console to perform the internal zone configuration. Use the zlogin command with the -C option and enter the requested information, including assigning the zone root password.
Creating a Zone: Examples
Following is a very simple example that shows minimal configure, install, boot, and log in:
global$ zoneadm list -cv ID NAME STATUS PATH BRAND IP 0 global running / native shared global$ pfexec zonecfg -z myzone myzone: No such zone configured Use 'create' to begin configuring a new zone. zonecfg:myzone> create zonecfg:myzone> set zonepath=/export/home/myzone zonecfg:myzone> verify zonecfg:myzone> commit zonecfg:myzone> exit global$ zoneadm list -cv ID NAME STATUS PATH BRAND IP 0 global running / native shared - myzone configured /export/home/myzone ipkg shared global$ pfexec zoneadm -z myzone install A ZFS file system has been created for this zone. Publisher: Using release (http://pkg.opensolaris.org/release/). done. /export/home/myzone/root ...Refreshing Catalog Cache: Using /var/pkg/download. Sanity Check: Looking for 'entire' incorporation. Installing: Core System (output follows) <...more messages...> Done: Installation completed in 351.567 seconds. Next Steps: Boot the zone, then log into the zone console (zlogin -C) to complete the configuration process global$ pfexec zoneadm -z myzone boot global$ pfexec zlogin -C myzone <Answer questions about terminal type, host name, time zone, root password.> <Log in. To log out, enter the tilde character followed by the period: ~.> global$ zoneadm list -cv ID NAME STATUS PATH BRAND IP 0 global running / native shared 1 myzone running /export/home/myzone ipkg shared global$ pfexec zlogin myzone myzone# exit global$
Create user accounts, install additional software, and customize the zone's configuration. Add zone-wide resource controls and pool functionality to a zone quickly by using zonecfg properties. You can partition resources, constrain resources, and allocate resources based on the importance of the zone. A zone that includes resource management features is called a container.
How to Configure the Zone is an example that shows many zone configuration actions such as restricting and allocating resources, modifying privileges, adding a file system, adding a ZFS dataset, adding a shared file system that is loopback-mounted from the global zone, adding a network interface, adding a device.
Zone Installs also shows more complex, real world examples.
Zones Information Resources
For more information, see the following resources:
- The Observatory:
- Zones OpenSolaris Community
- Zones and Containers FAQ
- Creating a Flash Archive of a Zoned System; Jeff Victor; March 2006
- Zones in System Administration Guide: Virtualization Using the Solaris Operating System
- Solaris Containers: Resource Management and Solaris Zones Developer's Guide
- Step 1 to Solaris Containers - Creating Containers
- Zones topics on Solaris Internals and Performance FAQ:
Zones
Zones Resource Controls
Zones Best Practices

