Solaris Containers (Zones) Administration

To view the performance stats of the zones, run “prstat -Z” from the global zone.

In the examples below, we will assume that the machine has a zone called “testzone”.

To list the zones configured in the machine, run “zoneadm list -iv”, it shows all the zones and the status of each zone:

root@hamdan # zoneadm list -iv
  ID NAME             STATUS     PATH                BRAND    IP   
   0 global           running    /                   native   shared
   - testzone         installed  /export/testzone    native   shared

 

The status of “testzone” is “installed”, this means that the zone is down.

To boot a zone, run “zoneadm -z <zone_name> boot” :

root@hamdan # zoneadm -z testzone boot
root@hamdan #
root@hamdan # zoneadm list -iv
  ID NAME             STATUS     PATH                BRAND    IP   
   0 global           running    /                   native   shared
   6 testzone         running    /export/testzone    native   shared

The status of the zone is “running”, it means the zone has been successfully booted up. 

To shut-down a zone, run “zoneadm -z <zone_name> halt” :

root@hamdan # zoneadm -z testzone halt
root@hamdan #
root@hamdan # zoneadm list -iv
  ID NAME             STATUS     PATH                BRAND    IP   
   0 global           running    /                   native   shared
   - testzone         installed  /export/testzone    native   shared

 

To reboot a zone, you can use “zoneadm -z <zone_name> halt” then “zoneadm -z <zone_name> boot” OR you can use “zoneadm -z <zone_name> reboot” (note: both are graceful reboots):

root@hamdan # zoneadm -z testzone reboot
root@hamdan #
root@hamdan # zoneadm list -iv
  ID NAME             STATUS     PATH                BRAND    IP   
   0 global           running    /                   native   shared
   6 testzone         running    /export/testzone    native   shared

To login to a zone, run “zlogin -z <zone_name>” :

root@hamdan # zlogin -z testzone
[Connected to zone 'testzone' pts/2]
Sun Microsystems Inc. SunOS 5.10 Generic January 2005
$
$ hostname
testzone
$ exit
root@hamdan #

 

To backup zone configuration, run “zonecfg -z <zone_name> export > /my_backup ” (note: /my_backup is any user backup file!):

root@hamdan # zonecfg -z testzone export > /my_backup
root@hamdan # more /my_backup
create -b
set zonepath=/export/testzone
set autoboot=true
set ip-type=shared
add net
set address=192.168.1.10/24
set physical=e1000g0
set defrouter=192.168.1.1
end
root@hamdan #

To restore zone configuration, run “zonecfg -z <zone_name> -f /my_backup”.

This entry was posted in Containers, Solaris, Virtualization, Zones and tagged , , , . Bookmark the permalink.

2 Responses to Solaris Containers (Zones) Administration

  1. Jim Klimov says:

    You make a note that “zoneadm halt” and “zoneadm reboot” are “graceful” shutdowns.
    As far as I know, this is not quite true (I may be wrong, please say so if I am ;) ): these commands cause sending a SIGTERM to local zone’s processes and after a timeout the zone’s run-time resources are revoked and processes are killed.
    This is not a very graceful shutdown in terms of not calling initscripts or SMF stop methods for service shutdown and cleanup, and doing so in a particular order.
    Portable graceful shutdown and reboot actions are “zlogin -S ZONENAME init 0″ and “zlogin -S ZONENAME init 6″ accordingly. (The -S flag stands for “safemode zlogin” which cuts some corners, requires less resources and is more likely to succeed on a busy system; it is not required if not implemented in your version of OpenSolaris descendant).
    A currently unportable solution exists in Solaris 11 apparently, “zoneadm -z ZONENAME shutdown (-r)” which does proper graceful shutdown (optionally followed by a reboot).
    HTH,
    //Jim Klimov

  2. Jim Klimov says:

    Also it may be important to notice that unlike other commands, “zlogin” does not have the “-z” argument. It is just “zlogin ZONENAME”.
    It has a “-C” argument however, to log onto a local zone’s console and receive its “kernel log messages” sent to the zone’s /dev/console.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>