Tuesday , December 16 2014
Home / Solaris11 / Solaris 11 – How to Clone the local zone ?

Solaris 11 – How to Clone the local zone ?

Solaris 11 local zone installation article already available in Unixarena. But here we are going to see how to create a local zone much faster than that and how to clone the local zones in seconds.The cloning mechanism utilizes the ZFS deduplication facility and it creates local zones with size few MB’s if we create the local zones on same zpool. The cloning is much faster than the actual zone installation if we keep the zones on separate zpool as well.Another feature is profile creation and we have discussed lot about that on Configuration Differences between Solaris 11 and Solaris 10


Let starts with local zone creation and assuming IPS is already configured on the global zone.
Creating the first local zone with pre-configured sysconfig:
1.List the physical network interfaces and create a vnic for local zone.
root@TESTSOL11G:~# dladm show-phys
LINK MEDIA STATE SPEED DUPLEX DEVICE
net0 Ethernet up 1000 full e1000g0
root@TESTSOL11G:~# dladm create-vnic -l net0 vnic1

2.Create a dataset for local zone root and perform the zone configuration as below.
root@TESTSOL11G:~# zfs create rpool/webunixarena1
root@TESTSOL11G:~# zfs set mountpoint=/webunixarena1 rpool/webunixarena1
root@TESTSOL11G:~# df -h /webunixarena1
Filesystem Size Used Available Capacity Mounted on
rpool/webunixarena1 15G 31K 9.5G 1% /webunixarena1

root@TESTSOL11G:~# zonecfg -z webunixarena1
Use 'create' to begin configuring a new zone.
zonecfg:webunixarena1> create
create: Using system default template 'SYSdefault'
zonecfg:webunixarena1> set zonepath=/webunixarena1
zonecfg:webunixarena1> add net
zonecfg:webunixarena1:net> set physical=vnic1
zonecfg:webunixarena1:net> end
zonecfg:webunixarena1> exit
root@TESTSOL11G:~# zoneadm list -cv
ID NAME STATUS PATH BRAND IP
0 global running / solaris shared
- webunixarena1 configured /webunixarena1 solaris excl
root@TESTSOL11G:~#

3.Create the profile for zone webunixarena1 using below command.

root@TESTSOL11G:~# sysconfig create-profile -o /tmp/webunixarena1-profile.xml
SC profile successfully generated.
Exiting System Configuration Tool. Log is available at:
/system/volatile/sysconfig/sysconfig.log.1946
root@TESTSOL11G:~#



Note:The sysconfig command will open a graphical window and it will ask the local zone hostname,Network,Timezone and root password.

4.Start the zone installation .

root@TESTSOL11G:~# zoneadm -z webunixarena1 install -c /tmp/webunixarena1-profile.xml
/webunixarena1 must not be group readable.
/webunixarena1 must not be group executable.
/webunixarena1 must not be world readable.
/webunixarena1 must not be world executable.
changing zonepath permissions to 0700.
Progress being logged to /var/log/zones/zoneadm.20130715T185026Z.webunixarena1.install

Image: Preparing at /webunixarena1/root.

AI Manifest: /tmp/manifest.xml.sDaO4e
SC Profile: /tmp/webunixarena1-profile.xml
Zonename: webunixarena1
Installation: Starting ...

Creating IPS image
Startup linked: 1/1 done
Installing packages from:
solaris
origin: http://localhost:1008/solaris/e6a99ea2a1304638e6614d015d965aefe14ff6dc/
DOWNLOAD PKGS FILES XFER (MB) SPEED
Completed 183/183 33556/33556 222.2/222.2 213k/s

PHASE ITEMS
Installing new actions 46825/46825
Updating package state database Done
Updating image state Done
Creating fast lookup database Done
Installation: Succeeded

Note: Man pages can be obtained by installing pkg:/system/manual done.
Done: Installation completed in 1868.649 seconds.
Next Steps: Boot the zone, then log into the zone console (zlogin -C)
to complete the configuration process.

Log saved in non-global zone as /webunixarena1/root/var/log/zones/zoneadm.20130715T185026Z.webunixarena1.install
root@TESTSOL11G:~#


5. Login to local zone and configure the network part.

root@TESTSOL11G:~# zoneadm list -cv
ID NAME STATUS PATH BRAND IP
0 global running / solaris shared
- webunixarena1 installed /webunixarena1 solaris excl
root@TESTSOL11G:~# zoneadm -z webunixarena1 boot
root@TESTSOL11G:~# zlogin -C webunixarena1
[Connected to zone 'webunixarena1' console]116/116
Hostname: webunixarena1

webunixarena1 console login: root
Password:
Roles can not login directly
Login incorrect
Jul 16 01:29:02 webunixarena1 login: login account failure: Permission denied

webunixarena1 console login: lingesh
Password:
Oracle Corporation SunOS 5.11 11.1 September 2012
lingesh@webunixarena1:~$ su - root
Password:
Jul 16 01:29:20 webunixarena1 su: 'su root' succeeded for lingesh on /dev/console
Oracle Corporation SunOS 5.11 11.1 September 2012
root@webunixarena1:~#

Here is the network configuration part.

root@webunixarena1:~# ipadm
NAME CLASS/TYPE STATE UNDER ADDR
lo0 loopback ok -- --
lo0/v4 static ok -- 127.0.0.1/8
lo0/v6 static ok -- ::1/128
root@webunixarena1:~# dladm
LINK CLASS MTU STATE OVER
vnic1 vnic 1500 up ?
net0 vnic 1500 up ?
root@webunixarena1:~#
root@webunixarena1:~# ipadm create-ip vnic1
root@webunixarena1:~# ipadm create-addr -T static -a local=192.168.10.61/24 vnic1/v4
root@webunixarena1:~# ipadm
NAME CLASS/TYPE STATE UNDER ADDR
lo0 loopback ok -- --
lo0/v4 static ok -- 127.0.0.1/8
lo0/v6 static ok -- ::1/128
vnic1 ip ok -- --
vnic1/v4 static ok -- 192.168.10.61/24


We have successfully created the local zone with Pre-configured profile (XML) file.

Clone the local zone
1.List the physical network interfaces and create a vnic for local zone.
root@TESTSOL11G:~# dladm create-vnic -l net0 vnic2
root@TESTSOL11G:~# dladm
LINK CLASS MTU STATE OVER
net0 phys 1500 up --
vnic2 vnic 1500 up net0

2.Create a dataset for local zone root and perform the zone configuration as below.
root@TESTSOL11G:~# zfs create rpool/dbunixarena1
root@TESTSOL11G:~# zfs set mountpoint=/dbunixarena1 rpool/dbunixarena1
root@TESTSOL11G:~# df -h /dbunixarena1
Filesystem Size Used Available Capacity Mounted on
rpool/dbunixarena1 15G 31K 8.8G 1% /dbunixarena1
root@TESTSOL11G:~# zonecfg -z dbunixarena1
Use 'create' to begin configuring a new zone.
zonecfg:dbunixarena1> create
create: Using system default template 'SYSdefault'
zonecfg:dbunixarena1> set zonepath=/dbunixarena1
zonecfg:dbunixarena1> add net
zonecfg:dbunixarena1:net> set physical=vnic2
zonecfg:dbunixarena1:net> end
zonecfg:dbunixarena1> exit
root@TESTSOL11G:~#
root@TESTSOL11G:~# zoneadm list -cv
ID NAME STATUS PATH BRAND IP
0 global running / solaris shared
1 webunixarena1 running /webunixarena1 solaris excl
- dbunixarena1 configured /dbunixarena1 solaris excl
root@TESTSOL11G:~#


3.Create the profile for zone webunixarena1 using below command.

root@TESTSOL11G:~# sysconfig create-profile -o /tmp/dbunixarena1-profile.xml
SC profile successfully generated.
Exiting System Configuration Tool. Log is available at:
/system/volatile/sysconfig/sysconfig.log.5971
root@TESTSOL11G:~#


4.Halt the webunixarena1.

root@TESTSOL11G:~#zoneadm -z  webunixarena1 halt
root@TESTSOL11G:~#zoneadm list -cv
ID NAME STATUS PATH BRAND IP
0 global running / solaris shared
1 webunixarena1 installed /webunixarena1 solaris excl
- dbunixarena1 configured /dbunixarena1 solaris excl


5.Clone the webunixarena1 zone as dbunixarena1.

root@TESTSOL11G:~# zoneadm -z dbunixarena1 clone -c /tmp/dbunixarena1-profile.xml webunixarena1

Progress being logged to /var/log/zones/zoneadm.20130716T100537Z.dbunixarena1.clone
Log saved in non-global zone as /dbunixarena1/root/var/log/zones/zoneadm.20130716T100537Z.dbunixarena1.clone
root@TESTSOL11G:~#


6.Boot the local zone and configure the networking part like webunixarena1.

root@TESTSOL11G:~# zoneadm -z dbunixarena1 boot
root@TESTSOL11G:~# zlogin -C dbunixarena1
[Connected to zone 'dbunixarena1' console]Hostname: unknown
Hostname: dbunixarena1
dbunixarena1 console login: lingesh
Password:
Last login: Tue Jul 16 01:29:13 on console
Oracle Corporation SunOS 5.11 11.1 September 2012
lingesh@dbunixarena1:~$ su - root
Password:
Jul 16 15:55:08 dbunixarena1 su: 'su root' succeeded for lingesh on /dev/console
Oracle Corporation SunOS 5.11 11.1 September 2012
root@dbunixarena1:~#


You are done . Now we have two local zones webunixaren1 & dbunixaren1 are up and running now.

Thank you for reading this article.Please leave a comment if you have any doubt on this.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>