Every now and then, a customer/ISV/partner wants to be able to identify the global zone from within a local zone. Per default, this is not possible.
This example describes how this can be done and even survive the relocation of the affected local zone from one node to another.
In this example, the global zone is named example, the local zone is named subample. local's zonepath is /zones/local.
Prework, has to be done once: Create an empty file /etc/globalzone in the local zone
root@example:/ # touch /zones/subample/root/etc/globalzone
Modify the zone's configuration
as a one-liner:
root@example:/ # zonecfg -z subample "add fs; set special=/etc/nodename; set type=lofs; set dir=/etc/globalzone; set options=ro; end"
or interactively:
root@example:/ # zonecfg -z subample zonecfg:subample> add fs zonecfg:subample:fs> set special=/etc/nodename zonecfg:subample:fs> set type=lofs zonecfg:subample:fs> set dir=/etc/globalzone zonecfg:subample:fs> set options=ro zonecfg:subample:fs> end zonecfg:subample> exit
If the zone is already running, mount /etc/nodename
root@example:/ # mount -o ro -F lofs /etc/nodename /zones/subample/root/etc/globalzone
Check your work
root@example:/ # zlogin subample /bin/cat /etc/globalzone example
Comments (3)
Jul 08
cutechaps says:
There is a small change in the first step alone, instead of creating a file a di...There is a small change in the first step alone, instead of creating a file a directory needs to be created or else when the zone is rebooted it will not come up
mkdir /zones/subample/root/etc/globalzone
Jul 16
aperkons says:
Hmm, did you have problems when creating a file? It sure works for me (both on S...Hmm, did you have problems when creating a file? It sure works for me (both on Solaris 10 and OpenSolaris).
Jul 16
cutechaps says:
When we create a file and mount on it, will work fine but when the zone is reboo...When we create a file and mount on it, will work fine but when the zone is rebooted it will create a issue and the zone will not come up, i faced this issue. So i created directory and mounted on it , looks good even after rebooting the zone.