Updated 22 March 2010
Linux Logo

Listing Global Zone Hostname


Description:
  • This procedure describes list the name of the global zone while logged in to a zone.
Prerequisites:
  • The script/command "zone-global-name" must be installed on the global zone and propagated to the local zones during creation.
Notes:
  • A command/script /usr/bin/zone-global-name has been added. This script consist of:
#!/bin/sh
# Copyright LogiQwest 2007
# Name: /usr/bin/zone-global-name
# Version 1.00:07 Jul 2007 Created
# Purpose: Displays name of global zone.
# Implementation: 1. On the global zone, obtain global zone name by using 
#                    "/usr/bin/hostname" .
#                 2. On the global zone, edit or create /usr/bin/zone-global-name
#                    and hard code
#                    the name of the global zone.
#                 3. Make the permissions and ownership of the file:
#   -r-xr-xr-x   1 root     bin     538 Jul 07 10:43 /usr/bin/zone-global-name
echo "Global Zone Host: lqwv20z"
  • This script is automatically propagated to each zone when it is create.
  • If on an unknown server type use, /usr/sbin/zoneadm list -vi to see if on local or global zone.
Warning:
  • The name of the global zone host is hard coded in this command script. It you change the hostname of the global zone, this script will need to be updated as well as copied version that exist on "big zones" (non shared filesystem) zones.

Step Action Description
1 Use zone-global-name script to display global zone hostname.
# /usr/bin/zone-global-name to display global zone name.

Global Zone:

global# /usr/bin/zone-global-name
Global Zone Host: lqwv20z
global# 

Local Zone:

myzone$ zone-global-name
Global Zone Host: lqwv20z
-bash-3.00$ 

If on an unknown server type, use /usr/sbin/zoneadm list -vi to see if on local or global zone. If you are on the global zone, /usr/bin/hostname can be use to list the hostname of the global zone as well as the zone-global-name script.

Global Zone:

global# /usr/sbin/zoneadm list -vi
 ID NAME             STATUS         PATH                           BRAND    IP
  0 global           running        /                              native   shared
  2 rlogic           running        /zones/rlogic                  native   shared
  3 utility          running        /zones/utility                 native   shared
  4 myzone           running        /zones/myzone                  native   shared
global# hostname
lqwv20z
global# /usr/bin/zone-global-name
Global Zone Host: lqwv20z 
global# 

If you are on a local zone using /usr/sbin/zoneadm list -vi will only display information on your local zone. Use the zone-global-name script.

Local Zone:

myzone# /usr/sbin/zoneadm list -vi
 ID NAME             STATUS         PATH                           BRAND    IP
  4 myzone           running        /zones/myzone                  native   shared
myzone# zone-global-name
Global Zone Host: lqwv20z 
myzone# 
Click for more info