Solaris non-global Zone States (part 2)

Following on from my previous post (Solaris non-global Zone States), I had a few readers ask for more information, so I continued to put together this additional insite into Soalris Zoles.

Zone Daemons

  • zoneadmd
    • zoneadmd daemon starts whenever zones requires to be managed.
    • Each zones have single instance of zoneadmd (ie zoneadmd -z zonename)
    • Its started automatically by SMF and its stop automatically when no longer required.
    • Allocates the zone ID and starts the zsched process
    • Sets system-wide resource controls
    • Plumbs the virtual network interface
    • Mounts any loopback or conventional file systems
  • zsched
    • The zsched process is started by zoneadmd.
    • The zsched job is to keep the track of kernel threads running within the zone.
    • It is also known as the zone scheduler.

Frequently used commands

  • zonecfg
    Add, Delete, Modify and View zone configuration
    • zonecfg -z zonename — Interactive mode
    • zonecfg -z zonename commit
    • zonecfg -z zonename create
    • zonecfg -z zonename delete
    • zonecfg -z zonename verify
  • zoneadm
    Change the zone states or Administration of zones
    • zoneadm -z zonename boot
    • zoneadm -z zonename halt
    • zoneadm -z zonename install
    • zoneadm -z zonename ready
    • zoneadm -z zonename reboot
    • zoneadm -z zonename uninstall
    • zoneadm -z zonename verify
  • zlogin
    Login non-gobal from global zone
    • zlogin zonename verify
    • zlogin -C zonename verify — Login to zone console

Command Examples

  • Example #1 : Set zonepath and autoboot (Note: the zones servicesvc:/system/zones:default must also be enabled when we go for autoboot=true)
    # zonecfg -z myzone
    zonecfg:myzone> set zonepath=/export/home/myzone
    zonecfg:myzone> set autoboot=true
    zonecfg:myzone> verify
    zonecfg:myzone> commit
    zonecfg:myzone> exit
    
  • Example #2 — Filesystem is added into the non-global zone
    # zonecfg -z myzone
    zonecfg:myzone> add fs
    zonecfg:myzone:fs> set dir=/test/mnt
    zonecfg:myzone:fs> set special=/dev/vx/dsk/zonedg/vol1
    zonecfg:myzone:fs> set raw=/dev/vx/rdsk/zonedg/vol1
    zonecfg:myzone:fs> set type=vxfs
    zonecfg:myzone:fs> end
    zonecfg:myzone> verify
    zonecfg:myzone> commit
    zonecfg:myzone> exit
    
  • Example #3 — Network is added into the non-global zone
    # zonecfg -z myzone
    zonecfg:myzone> add net
    zonecfg:myzone:net> set physical=e1000g0
    zonecfg:myzone:net> set address=192.168.10.35
    zonecfg:myzone:net> end
    zonecfg:myzone> verify
    zonecfg:myzone> commit
    zonecfg:myzone> exit
    
  • Example #4 — ZFS Dataset filesystem is added into the non-global zone
    # zonecfg -z myzone
    zonecfg:myzone> add dataset
    zonecfg:myzone:dataset> set name=zonepool/myzonevol
    zonecfg:myzone:dataset> end
    zonecfg:myzone> verify
    zonecfg:myzone> commit
    zonecfg:myzone> exit
    
  • Example #5 — Specify the memory limits (each limit is optional, but at least one must be set)
    # zonecfg -z myzone
    zonecfg:myzone> add capped-memory
    zonecfg:myzone:capped-memory> set physical=50m
    zonecfg:myzone:capped-memory> set swap=100m
    zonecfg:myzone:capped-memory> set locked=30m
    zonecfg:myzone:capped-memory> end
    zonecfg:myzone> verify
    zonecfg:myzone> commit
    zonecfg:myzone> exit
    
  • Example #6 — Assign dedicated CPU (1-3) and set the importance as well.
    # zonecfg -z myzone
    zonecfg:myzone> add dedicated-cpu
    zonecfg:myzone:dedicated-cpu> set ncpus=1-3
    zonecfg:myzone:dedicated-cpu> set importance=2
    zonecfg:myzone:dedicated-cpu> end
    zonecfg:myzone> verify
    zonecfg:myzone> commit
    zonecfg:myzone> exit
    
  • Example #7 — Specifies capped CPU of 3.5 CPUs for the zone
    # zonecfg -z myzone
    zonecfg:myzone> add capped-cpu
    zonecfg:myzone:capped-cpu> set ncpus=3.5
    zonecfg:myzone:capped-cpu> end
    zonecfg:myzone> verify
    zonecfg:myzone> commit
    zonecfg:myzone> exit
    

zonecfg command attributes

AttributeDefinition
zonepath Path of the zone root which is from global zone's file space.
Autoboot Define whether we need automatically boot the zone
pool Associate the zone with a resource pool; multiple zones may share a pool.
net Network interface of Zone
fs File systems from the zone's /etc/vfstab, automounted file systems configured within the zone, manually mounted file systems or ZFS mounts from within the zone
dataset To manage non-global zone with ZFS file system.
inherit-pkg-dir In a sparse root zone, represents directories containing packaged software that a non-global zone shares with the global zone. (Should not be used in a whole root zone.)
device Devices that should be configured in a non-global zone.
rctl Zone-wide resource controls such as zone.cpu-shares and zone.max-lwps
attr Zone comments

The following table lists "sub commands", which are also important while configuring the zone:

Sub-commandDefinition
add Add the specified resource or components
cancel Ends the resource specification and returns to the global scope without retaining partially specified resources.
commit Save the current configuration to the disk.
create Create new zone configurations
delete Destroy configuration.
end Ends the resource specification
exit Ends the zonecfg session.
info Display information about the configuration of the current scope.
remove Remove the specified resource
revert Return to the last state written to disk.
set Set the specified property to the specified value
verify Verify the current configuration for correctness.