Wednesday, December 10, 2014

"pkgcond" - How to check the type of zone installed or How to check the type of zone logged in?


As a quick note let us first know the type of zones available on Solaris 10.
Zones are broadly classified into 2. Global Zone and Non-Global Zone.
Where Non-Global Zone is further classified into 3 -
a. Whole Root Zone
b. Sparse Zone
c. Branded Zone (For non-native operating system. Can be created on X86 machines. Currently CentOS and RHEL3 are supported.)

Is there any way to find out the type of zone logged in? Is there any way to find out the type of zone installed?

Yes.
"pkgcond" command is helping us to find the same.
Imagine if the
"pkgcond" command not found, kindly check and ensure to install the package "SUNWpkgcmdsu".
This package comprise the command "pkgcond".


"pkgcond"  - 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.

Here to tweak the output I have used the Solaris 10 1/13 release.

bash-3.2# cat /etc/release
                    Oracle Solaris 10 1/13 s10x_u11wos_24a X86
  Copyright (c) 1983, 2013, Oracle and/or its affiliates. All rights reserved.
                            Assembled 17 January 2013

 


bash-3.2# pkgchk -l -p /usr/bin/pkgcond
Pathname: /usr/bin/pkgcond
Type: regular file
Expected mode: 0555
Expected owner: root
Expected group: sys
Expected file size (bytes): 227524
Expected sum(1) of contents: 31891
Expected last modification: Nov 16 03:36:14 2012
Referenced by the following packages:
        SUNWpkgcmdsu
Current status: installed


bash-3.2# pkgchk -l SUNWpkgcmdsu
Pathname: /usr/bin/pkgcond
Type: regular file
Expected mode: 0555
Expected owner: root
Expected group: sys
Expected file size (bytes): 227524
Expected sum(1) of contents: 31891
Expected last modification: Nov 16 03:36:14 2012
Referenced by the following packages:
        SUNWpkgcmdsu
Current status: installed


(Output Truncated...)



I have executed the command in Global zone, non-global zones - whole root zone and sparse zone respectively
Whole Root Zone name = SampleZone
Sprase Zone name = TestZone


From the Global Zone:

bash-3.2# uname -a;date
SunOS SolarisSVM 5.10 Generic_147148-26 i86pc i386 i86pc
Wed Dec 10 09:13:21 IST 2014
bash-3.2# zonename
global

bash-3.2# zoneadm list -cv
  ID NAME             STATUS     PATH                           BRAND    IP
   0 global           running    /                              native   shared
   1 TestZone         running    /export/home/TestZone1         native   shared
   2 SampleZone       running    /export/home/SampleZone        native   shared



bash-3.2# 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




Where option
-n = Negate return status (0 becomes1 and 1 becomes 0).  It negates results in the case of ' is_what' condition.



Where –
0 = False
1 = True


From the Whole Root Zone:
bash-3.2# uname -a;date
SunOS SampleZone 5.10 Generic_147148-26 i86pc i386 i86pc
Tue Dec  9 20:16:39 PST 2014
 

bash-3.2# zonename
SampleZone

bash-3.2# 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


From the Sparse Zone:
bash-3.2# uname -a;date
SunOS TestZone 5.10 Generic_147148-26 i86pc i386 i86pc
Tue Dec  9 19:42:48 PST 2014
 

bash-3.2# zonename
TestZone

bash-3.2# 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