Monday, January 24, 2011

Solaris Zone

Create zone:
bash-3.00# zonecfg -z 1
1: No such zone configured
Use 'create' to begin configuring a new zone.
zonecfg:1> create
zonecfg:1> set zonepath=/opt/zones/1
zonecfg:1> add net
zonecfg:1:net> set physical=e1000g0
zonecfg:1:net> set address=
zonecfg:1:net> end
zonecfg:1> add inherit-pkg-dir
zonecfg:1:inherit-pkg-dir> set dir=/opt
zonecfg:1:inherit-pkg-dir> end
zonecfg:1> verify
zonecfg:1> commit
zonecfg:1> exit

# zoneadm -z 1 install
Preparing to install zone <1>.
Creating list of files to copy from the global zone.
Copying <2924> files to the zone.
Initializing zone product registry.
Determining zone package initialization order.
Preparing to initialize <1102> packages on the zone.
Initialized <1102> packages on zone.
Zone <1> is initialized.
The file contains a log of
the zone installation.

# zoneadm -z 1 boot
# zlogin -C 1
(follow on screen instructions)

If you want to rename zone:
# zoneadm -z 1 halt
# vi /etc/zones/index (rename "1" to your new zone name, i.e. zone1x86)
# cd /etc/zones/
# mv 1.xml zone1x86.xml
# vi zone1x86.xml (change any reference "1" to new zone name, i.e. zone1x86)
# zoneadm -z zone1x86 boot

Cloning zone1x86 to zone2x86:
# zonecfg -z zone1x86 export > zone2x86.cfg
# vi zone2x86.cfg (change zone1x86 to your new zone name, i.e. zone2x86 and IP address)
"zone2x86.cfg" 23 lines, 331 characters
create -b
set zonepath=/opt/zones/zone2x86
set autoboot=false
set ip-type=shared
add inherit-pkg-dir
set dir=/lib
add inherit-pkg-dir
set dir=/platform
add inherit-pkg-dir
set dir=/sbin
add inherit-pkg-dir
set dir=/usr
add inherit-pkg-dir
set dir=/opt
add net
set address=
set physical=e1000g0
"zone2x86.cfg" 23 lines, 331 characters
# zonecfg -z zone2x86 -f zone2x86.cfg
# zoneadm -z zone1x86 halt
# zoneadm -z zone2x86 clone zone1x86
Copying /opt/zones/zone1x86...
grep: can't open /a/etc/dumpadm.conf

Verify zones are correctly installed:
# zoneadm list -vi
0 global running / native shared
- zone1x86 installed /opt/zones/zone1x86 native shared
- zone2x86 installed /opt/zones/zone2x86 native shared

Boot zones:
# zoneadm -z zone1x86 boot
# zoneadm -z zone2x86 boot

No comments: