Using pkgcond to determine a zone type

"pkgcond" can be used to find out the type of zone you're logged in or the type of zone that has been installed.

pkgcond is used to determine the type of target being operated on global zone, non-global zone, disk less client. It has one mandatory argument, a condition. The command test whether the condition is true for the specified path.

Syntax:

pkgcond -n condition

where -n Negates the return status (0 becomes 1 and 1 becomes 0). It negates results in the case of is_what condition. Thus 0 is False and 1 is True.

In this article, I show example output from a global zone, a whole-root non-global zone, and a sparse non-global zone.

Global Zone

# pkgcond -n is_what
can_add_driver=0
can_remove_driver=0
can_update_driver=0
is_alternative_root=0
is_boot_environment=0
is_diskless_client=0
is_global_zone=1
is_mounted_miniroot=0
is_netinstall_image=0
is_nonglobal_zone=0
is_path_writable=1
is_running_system=1
is_sparse_root_nonglobal_zone=0
is_whole_root_nonglobal_zone=0

Whole Root Zone

# pkgcond -n is_what
can_add_driver=1
can_remove_driver=1
can_update_driver=1
is_alternative_root=0
is_boot_environment=0
is_diskless_client=0
is_global_zone=0
is_mounted_miniroot=0
is_netinstall_image=0
is_nonglobal_zone=1
is_path_writable=1
is_running_system=0
is_sparse_root_nonglobal_zone=0
is_whole_root_nonglobal_zone=1

Sparse Zone

# pkgcond -n is_what
can_add_driver=1
can_remove_driver=1
can_update_driver=1
is_alternative_root=0
is_boot_environment=0
is_diskless_client=0
is_global_zone=0
is_mounted_miniroot=0
is_netinstall_image=0
is_nonglobal_zone=1
is_path_writable=1
is_running_system=0
is_sparse_root_nonglobal_zone=1
is_whole_root_nonglobal_zone=0