Saturday, April 16, 2011

Mapping Global Zone Name Inside Solaris 10 Zone


Sometimes when I am inside of a zone I want to know what global zone its attached to.  By default this was not visible but with a little effort below we can set it up so the global zone is visible within the zone.

Log into global zone where local zone(s) reside.

Using zonecfg, configure the following for each zone:
# zonecfg -z (zone)
add fs
set type=lofs
set options=ro
set special=/etc/nodename
set dir=/etc/globalname
end
verify
commit
exit

Create mount point within local zone directory structure:
# touch /zones/(zone)/root/etc/globalname

Mount lofs file system manually:
# mount -F lofs -o ro /etc/nodename /zones/(zone)/root/etc/globalname (or path where the root of the zone resides)

Confirm local zone can access file:
# zlogin (zone) cat /etc/globalname