Zones Resource Configuration:

Adding a network resource to a zone

# zonecfg –z zone1 
zonecfg:zone1> add net 
zonecfg:zone1:net> set address=192.168.0.12 
zonecfg:zone1:net> set physical=hme0 
zonecfg:zone1:net> end 
zonecfg:zone1> export 
create -b 
set zonepath=/zones/zone1 
set autoboot=false 
add inherit-pkg-dir 
set dir=/lib 
end 
add inherit-pkg-dir 
set dir=/platform 
end 
add inherit-pkg-dir 
set dir=/sbin 
end 
add inherit-pkg-dir 
set dir=/usr 
end 
add net
set address=147.184.30.12 
set physical=hme0 
end 
zonecfg:zone1>exit

Mount a LOFS in a zone (ideal for cdrom)

# zonecfg -z zone1
zonecfg:zone1> add fs
zonecfg:zone1:fs> set dir=/mnt
zonecfg:zone1:fs> set special=/cdrom
zonecfg:zone1:fs> set type=lofs
zonecfg:zone1:fs> add options [ro,nodevices]
zonecfg:zone1:fs> end
zonecfg:zone1> commit
zonecfg:zone1> exit

Add a disk/filesystem device to a zone

# zonecfg –z zone1 
zonecfg:zone1> add fs 
zonecfg:zone1:fs> set dir=/data1
zonecfg:zone1:fs> set special=/dev/dsk/c1t1d0s0
zonecfg:zone1:fs> set raw=/dev/rdsk/c1t1d0s0
zonecfg:zone1:fs> set type=ufs
zonecfg:zone1:fs> add options [logging, nosuid] 
zonecfg:zone1:fs> end 
zonecfg:zone1:fs> commit 
zonecfg:zone1:fs> exit

create the vfstab file entry and mount the device

# df –k
/data1 8705501 8657 8609789 1% /data1

# mount 
/data1 on /data1 read/write/setuid/devices/intr/largefiles/logging/xattr/onerror=panic/dev=80008 8 on Mon Mar 7 15:50:53 2005

# cat /etc/mnttab
/dev/dsk/c1t1d0s0 /export/home/zone1/root/data1 ufs rw,intr,largefiles, logging, xattr,onerror=panic,dev=800088 1110211568

Mount a filesystem from the global zone

# zonecfg -z zone1
zonecfg:zone1> add inherit-pkg-dir
zonecfg:zone1:fs> set dir=/opt/sfw
zonecfg:zone1:fs> end
zonecfg:zone1> commit
zonecfg:zone1> exit

We have 2 zones : zone01 and zone02. I will assign 20% CPU shares to zone01 and 60% to zone02 and 20% to the global zone as follows.

total shares 100
global zone - 20 shares out of 100 = 20% (this is optional, but in case you want to set this , it requires a reboot of the global zone)
zone01 - 20 shares out of 100 = 20%
zone02 - 60 shares out of 100 = 60%
global # zonecfg -z global
zonecfg:global> add rctl
zonecfg:global:rctl> set name=zone.cpu-shares
zonecfg:global:rctl> add value (priv=privileged,limit=20,action=none)
zonecfg:global:rctl> end
zonecfg:global> verify
zonecfg:global> commit
zonecfg:global> exit
global # zonecfg -z zone01
zonecfg:zone01> add rctl
zonecfg:zone01:rctl> set name=zone.cpu-shares
zonecfg:zone01:rctl> add value (priv=privileged,limit=20,action=none)
zonecfg:zone01:rctl> end
zonecfg:zone01> verify
zonecfg:zone01> commit
zonecfg:zone01> exit
global # zonecfg -z zone02
zonecfg:zone02> add rctl
zonecfg:zone02:rctl> set name=zone.cpu-shares
zonecfg:zone02:rctl> add value (priv=privileged,limit=80,action=none)
zonecfg:zone02:rctl> end
zonecfg:zone02> verify
zonecfg:zone02> commit
zonecfg:zone02> exit

Zones Capping-SWAP-CPU / Resource Pool Create