Pre-requisite before creating zone :
Plan for, how your
zone should and where its path on global zone .
Below are the few
required values which require while creating zones.
zonepath : Is the location or path on global zone
where the lofs filesystems are located . (I am using here /myzone) .And the
zone path should have the permissions 700 as shown below (otherwise zone
installation will fail) .
[root@solaris1 /]#ls -ld /myzone
drwx------ 5 root
root 1024 Aug 3 21:18 /myzone
|
Inherited-pkg-dir: Are the directories
which are loop back mounted from global zone. (/lib,/platform,/sbin and /usr
are default dir that are loopback from global zone to local zone ).Further you
can add other directories to the list also ... (As it will be shown in this
post)
CREATING A SPARSE
ROOT ZONE :
In this post I will be creating as sparse
root zone under /myzone directory with all default inherited dir and an extra
dir (/opt ) . Creating a zone is straight forward with zonecfg command .
For
the first time of creting myzone a message appears similar to below . This
occurs becuase myzone is not already created and not in any configuration files
.
[root@solaris1 /]#zonecfg -z
myzone
myzone: No such zone configured
Use 'create' to begin configuring
a new zone.
zonecfg:myzone>
|
Using the zonecfg it will take you to a zone
configuration special prompt zonecfg: from where you can
configure the zone .
For the first time you need to use the
'create' to start with new zone configuration . Below output shows the initial
config of a zone without any customization .
zonecfg:myzone>
create
zonecfg:myzone> info
zonename: myzone
zonepath:
brand: native
autoboot: false
bootargs:
pool:
limitpriv:
scheduling-class:
ip-type: shared
inherit-pkg-dir:
dir: /lib
inherit-pkg-dir:
dir: /platform
inherit-pkg-dir:
dir: /sbin
|
Now the very first
config value will be zonepath for which I am using /myzone which is already
created with 700 permission in global zone . And apart from default
inherit-pkg-dir here I am adding one more dir that needs to be lofs mounted in
local zone .
zonecfg:myzone> set
zonepath=/myzone
zonecfg:myzone>
zonecfg:myzone>
add inherit-pkg-dir
zonecfg:myzone:inherit-pkg-dir>
set dir=/opt
zonecfg:myzone:inherit-pkg-dir>
info
inherit-pkg-dir:
dir: /opt
|
Below is the zone configuration after you add extra
inherit-pkg-dir and set zonepath.
zonecfg:myzone> info
zonename: myzone
zonepath: /myzone
brand: native
autoboot: false
bootargs:
pool:
limitpriv:
scheduling-class:
ip-type: shared
inherit-pkg-dir:
dir: /lib
inherit-pkg-dir:
dir: /platform
inherit-pkg-dir:
dir: /sbin
inherit-pkg-dir:
dir: /usr
inherit-pkg-dir:
dir: /opt
|
Further you can add network info to the zone with ‘add net’ attributes required are
address , which is the IP address assigned to zone and the physical, which is
the interface on which a VIP is configured .
zonecfg:myzone> add net
zonecfg:myzone:net> info
net:
address not specified
physical not specified
defrouter not specified
zonecfg:myzone:net> set
address=192.168.15.100
zonecfg:myzone:net> set
physical=e1000g0
zonecfg:myzone:net> end
|
Note: before you exit from the zone prompt , save this
configuration with ‘commit’ because all the configuration set before commit are
not permanently saved .
This completes our configuration of zones and below is the
configured zone info . (You can further see the same outside the zone prompt
with command zoneinfo –z info )
zonecfg:myzone> info
zonename: myzone
zonepath: /myzone
brand: native
autoboot: false
bootargs:
pool:
limitpriv:
scheduling-class:
ip-type: shared
inherit-pkg-dir:
dir: /lib
inherit-pkg-dir:
dir: /platform
inherit-pkg-dir:
dir: /sbin
inherit-pkg-dir:
dir: /usr
inherit-pkg-dir:
dir: /opt
net:
address: 192.168.15.100
physical: e1000g0
defrouter not specified
zonecfg:myzone> commit
zonecfg:myzone> exit
|
Our zone is now in configured state and is ready to get
installed .
[root@solaris1 /]#zoneadm list
-cv
ID NAME STATUS PATH BRAND IP
0 global running / native shared
- myzone configured
/myzone
native shared
|
You can install the zone with zone admin command ‘zoneadm –z install’
[root@solaris1 /]#zoneadm -z
myzone install
Preparing to install zone
Creating list of files to copy
from the global zone.
Copying <1969> files to the
zone.
Initializing zone product
registry.
Determining zone package
initialization order.
Preparing to initialize
<953> packages on the zone.
Initialized <953> packages
on zone.
Zone
Installation of <2>
packages was skipped.
The file
contains a log of the
zone installation.
|
Yes now we are done with the zone installation without any
problems and now the status of zone changes to installed.
[root@solaris1 /]#zoneadm list
-cv
ID NAME STATUS PATH BRAND IP
0 global running / native shared
- myzone
installed /myzone native shared
|
No You are ready to boot the zone and you that with zoneadm
command as shown below .
[root@solaris1 /]#zoneadm -z
myzone boot
|
As you boot the zone status will be changed to running .
[root@solaris1 /]#zoneadm list
-cv
ID NAME STATUS PATH BRAND IP
0 global running / native shared
1 myzone running /myzone native shared
|
For the first time boot of zone just after installation , you
need to login to zone console using zlogin and “-C” options , because there are
few details that you need to provide for zone to operate .(Like Language info ,
timezone and so on . These questions are same as it show up while installing
solaris OS .)
[root@solaris1 /]#zlogin -C
myzone
[Connected to zone 'myzone'
console]
Reading ZFS config: done.
Select a Language
0. English
1. Japanese
2. Korean
3. Simplified Chinese
4. Traditional Chinese
Please make a choice (0 - 4), or
press h or ? for help:
[NOTICE: Zone rebooting]
|
Above are few messages that appear in the process when you
connect to console of zone . After
answering all , zone boots again and now it is complete and stable .
SunOS Release 5.10 Version
Generic_137138-09 64-bit
Copyright 1983-2008 Sun
Microsystems, Inc. All rights
reserved.
Use is subject to license terms.
Hostname: myzone
Reading ZFS config: done.
myzone console login:
myzone console login: ~.
|
Note : To exit from zone
console session use the key sequence “~.“
And now zone is perfect to use .
Below are few of the outputs after zone installation .
[root@solaris1 /]#zlogin
myzone
[Connected to zone 'myzone'
pts/2]
Sun Microsystems Inc. SunOS 5.10 Generic January 2005
# uname -a
SunOS myzone 5.10
Generic_137138-09 i86pc i386 i86pc
# df -h
Filesystem size used
avail capacity Mounted on
/ 1.0G 97M
870M 10% /
/dev 1.0G 97M
870M 10% /dev
/lib 940M 623M
261M 71% /lib
/opt 1.9G 490M
1.4G 27% /opt
/platform 940M 623M
261M 71% /platform
/sbin 940M 623M
261M 71% /sbin
/usr 2.9G
2.3G 560M 81%
/usr
proc 0K 0K
0K 0% /proc
ctfs 0K 0K
0K 0% /system/contract
mnttab 0K 0K
0K 0% /etc/mnttab
objfs 0K
0K 0K 0%
/system/object
swap 968M 288K
968M 1% /etc/svc/volatile
/usr/lib/libc/libc_hwcap1.so.1
2.9G 2.3G
560M 81% /lib/libc.so.1
fd 0K 0K
0K 0%
/dev/fd
swap 968M 4K
968M 1% /tmp
swap 968M 16K
968M 1% /var/run