How to clone a zone in Solaris 11.1

In this post I am going to show you the procedure of cloning a zone. I am having one existing zone named as testzone1 we are going to create a new zone named as testzone2 by using clone feature.

Step 1 : First we can create the profile which we are going to use for new zone. I have created that profile by logging into present zone testzone1. During the wizard of profile creation give the zonename and IP address which you want to set for new zone testzone2.

root@solaris11:~# zlogin testzone1
[Connected to zone ‘testzone1’ pts/2]
Oracle Corporation SunOS 5.11 11.1 September 2012

root@testzone1:~# sysconfig create-profile -o /root/testzone2_template.xml

Step 2 : After profile creation halt the source zone(testzone1) from which we are going to clone the new zone. After halt operation get the configuration file of that zone.

root@solaris11:~# zoneadm -z testzone1 halt

root@solaris11:~# zonecfg -z testzone1 export -f testzone2.conf

root@solaris11:~# cat testzone2.conf
create -b
set brand=solaris
set zonepath=/zones/testzone1
set autoboot=false
set file-mac-profile=none
set ip-type=exclusive
add anet
set linkname=net0
set lower-link=auto
set configure-allowed-address=true
set link-protection=mac-nospoof
set mac-address=random
end

Step 3 : Important step edit the conf file using your favorite editor. I used vi to change the zonepath in that file from /zones/testzone1 to /zones/testzone2

Step 4 : Now create the new zone using that configuration file. Verify the same.

root@solaris11:~# zonecfg -z testzone2 -f /root/testzone2.conf

root@solaris11:~# zoneadm list -cv
ID NAME STATUS PATH BRAND IP
0 global running / solaris shared
– testzone1 installed /zones/testzone1 solaris excl
– testzone2 configured /zones/testzone2 solaris excl

Step 5 : Now create the new zone using existing zone. Your source zone should be in halt status for cloning. Its really very quick compare to creating new zone.

root@solaris11:~# zoneadm -z testzone2 clone -c /zones/testzone1/root/root/testzone2_template.xml testzone1
The following ZFS file system(s) have been created:
rpool/zones/testzone2
Progress being logged to /var/log/zones/zoneadm.20140615T143127Z.testzone2.clone
Log saved in non-global zone as /zones/testzone2/root/var/log/zones/zoneadm.20140615T143127Z.testzone2.clone

Step 6 : New zone has come into installed status. I am able to boot both the zones successfully 🙂

root@solaris11:~# zoneadm list -cv
ID NAME STATUS PATH BRAND IP
0 global running / solaris shared
– testzone1 installed /zones/testzone1 solaris excl
– testzone2 installed /zones/testzone2 solaris excl

root@solaris11:~# zoneadm -z testzone2 boot

root@solaris11:~# zoneadm -z testzone1 boot
root@solaris11:~# zoneadm list -cv
ID NAME STATUS PATH BRAND IP
0 global running / solaris shared
17 testzone2 running /zones/testzone2 solaris excl
18 testzone1 running /zones/testzone1 solaris excl

Verification that everything is placed on newly created zone. I gave IP 192.168.120.170 and hostname testzone2 in profile created for zone testzone2 in step 1.

root@testzone2:~# uname -a
SunOS testzone2 5.11 11.1 i86pc i386 i86pc

root@testzone2:~# 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
net0 ip ok — —
net0/v4 static ok — 192.168.120.170/24
net0/v6 addrconf ok — fe80::8:20ff:feec:151c/10

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s