Solaris Zones

Zones are virtual process environments in Solaris 10 (and newer) that allow system administrator to isolate process in one zone from processes in another zone. Zones have their own (chroot) storage environment which again separates data between zones.

the zoneadm -z zone boot command on a zone in the running state will have the zone be booted into the running state

Restore zone configuration using command file zonecfg -z zone install

Create zone
Create sparse root model zone (default) zonecfg -z zone zonecfg:zone> create Create whole root model zone zonecfg -z zone zonecfg:zone> create -b Create zone using custom template zonecfg -z zone -f template.zone

List zones
List available zones zoneadm list -cv Look at zone configuration zonecfg -z zone info Check current zone zonename

This quick reference list the most commonly used commands involved managing Solaris zones. For a zones overview see the solaris_zones_intro quick reference at http://www2.petervg.nl/quick_reference

Zone states
Undefined zonecfg -z zone ↓ zone: > create zonecfg -z zone delete Configured ↓zoneadm -z zone install zoneadm -z uninstall ↑ Installed ↓zoneadm -z zone ready Ready ↓zoneadm -z zone boot ↓ zoneadm -z zone halt ↑ ↑ ↑

Manage zone
Create zone's root file system structure zoneadm -z zone install Boot zone in ready mode zoneadm -z zone ready Into running mode zoneadm -z zone boot Reboot zone(from global zone) zoneadm -z zone boot Halt zone (from global zone) This will not run the shutdown procedures!! zoneadm -z zone halt Reboot zone (from global zone) This will not run the shutdown procedures zoneadm -z zone reboot Backup zone configuration zonecfg -z zone -f /backup/zone.cmd

Log in and run commands
Log in on zone's console (from global zone) zlogin -C zone Log in on zone (from global zone) zlogin zone Log in on zone (from anywhere) ssh zone_host_name Run command in zone (from global zone) zlogin -c command zone Run command in zone (from anywhere) ssh zone cmd Run command in zone ( from anywhere) rsh zone command

Running zoneadm -z zone reboot Running

A running zone cannot be brought back to the ready state. A halt on a running zone will bring the zone to the installed state. A zone doesn't have to be booted into the ready state before it can enter the running state. Issuing

Manage processes
Display zone name with running process ps -e -Z

Display processes running in zone (from global zone) ps -z zone Display zone statistics prstat -Z Kill process by name in zone pkill -z zone process_name Find process by name in zone pgrep -z zone process_name List process tree in zone ptree -z zone

Create resource pool poolcfg -dc 'create pool zone_pool' Associate processor set with pool poolcfg -dc 'associate pool zone_pool (pset two_cpu)' Enable pool facility pooladm -e Save active pool configuration pooladm -s /etc/pooladm.conf Activate the /etc/pooladm.conf configuration pooladm -c

Install packages and patches
Install package in current zone only pkgadd -G pkg_name Install patch in current zone only patchadd -G path_name Backup zone configuration zonecfg -z zone export > /backup/zone.cmd

Memory capping
To manage the memory usage of zone's you can use the so-called memory capping feature in Solaris. Setup project projadd -c "Project Description" -G users -p 101 users projmod -s -K rcap.max-rss=1000k users Enable resource capping rcapadm -E Check status rcapstat

Dynamic resource pool management
Dynamic resource pools are not part of the zone framework. I have listed the command here for your convenience. View current pool configuration poolcfg -dc info Read pool configuration file poolcfg -c info /etc/pooladm.conf Create processor set (with 2 CPUs) poolcfg -dc 'create pset two_cpu ( uint pst.min = 1 ; uint pset.max = 2 )'

Colophon Author Peter van Gemert Name solaris_zones_commands.pdf Location http://www2.petervg.nl/quick_reference Created 16 July 2007 Modified 16 July 2007