unix sysadmin archives
Donation will make us pay more time on the project:

Tuesday, 7 June 2011

How to know if you are on the Global Zone

Just incase you are wondering if you are on the Global Zone or not.

A quick listing of the zones may give you a hint. If you are in the global zone, listing the zones will usually give you a line containing the name “global” together with the local zones.

From a global zone:

reciosys01# zoneadm list -cv
  ID NAME             STATUS     PATH                           BRAND    IP   
   0 global           running    /                              native   shared

In contrast, if you are in a local here is what usually get.
From a non-global zone:

reciosys02# zoneadm list -cv
  ID NAME             STATUS     PATH                           BRAND    IP   
  12 reciosys02       running    /                              native   shared

It is quite straight forward, a one liner list with the name of the local zone.

Let's dig in a little more.

You can also check the /etc/zones directory; it contains an index file and other xml files that contain information about the zones.

reciosys03# cd /etc/zones
reciosys03# ls -la
total 66
drwxr-xr-x   2 root     sys          512 Dec 18  2009 .
drwxr-xr-x  61 root     sys         4608 Jun  2 15:54 ..
-r--r--r--   1 root     bin          392 Aug  8  2007 SUNWblank.xml
-r--r--r--   1 root     bin          562 Aug  8  2007 SUNWdefault.xml
-r--r--r--   1 root     bin          420 Oct  8  2007 SUNWsolaris8.xml
-r--r--r--   1 root     bin          420 Apr 24  2008 SUNWsolaris9.xml
-rw-r--r--   1 root     root         373 Nov 24  2008 global.xml
-rw-r--r--   1 root     sys         1127 Dec 18  2009 index
-rw-r--r--   1 root     root        1194 Dec 18  2009 reciosys04.xml
-rw-r--r--   1 root     root         799 Dec 18  2009 reciosys05.xml

There is an xml file for each zone (Global and Non-global). You can already tell it from here that it is a global zone.

Opening the index file, you can see similar entries with zoneadm list.

reciosys03# more index
# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
# ident "@(#)zones-index        1.2     04/04/01 SMI"
# DO NOT EDIT: this file is automatically generated by zoneadm(1M)
# and zonecfg(1M).  Any manual changes will be lost.

Now let’s get into one of the local zones and see what the difference is.

reciosys03# zlogin reciosys05
reciosys05# cd /etc/zones
reciosys05# ls -la
total 12
drwxr-xr-x   2 root     sys          512 Nov 24  2008 .
drwxr-xr-x  51 root     sys         4096 Apr 29 14:21 ..
-rw-r--r--   1 root     sys           57 Apr  8 01:59 index

Well, it only have an index file and no xmls.

And the index file, contains a one liner entry of the zones information.
Easy to conclude that this is a local zone.

reciosys05# more index

There it is. Hope this helps.

No comments:

Post a Comment