ZoneClone@11
I installed a zone on my T7 box and prepared it for an Oracle DB installation. But I will need the same setup for a second installation... In this example I will use the "clone" function from solaris11/zones/zfs to get my preconfigured zone cloned:
Halt the zone/container:
root@t7primary:~/config# zoneadm list -cv ID NAME STATUS PATH BRAND IP 0 global running / solaris shared 1 t7zone01 running /zones/t7zone01 solaris excl root@t7primary:~/config# zoneadm -z t7zone01 halt
Now I will copy the configuration from the first zone and will just chance the install root directory inside the zone:
root@t7primary:~/config# zonecfg -z t7zone01 export -f ./t7zone01.export root@t7primary:~/config# vi t7zone01.export [...] -> changed zonepath root@t7primary:~/config# zonecfg -z t7zone02 -f ./t7zone01.export root@t7primary:~/config# zonecfg -z t7zone02 info zonename: t7zone02 zonepath: /zones/t7zone02 brand: solaris autoboot: false autoshutdown: shutdown bootargs: file-mac-profile: pool: limitpriv: scheduling-class: ip-type: exclusive hostid: tenant: fs-allowed: [max-shm-memory: 512G] [max-shm-ids: 2048] [max-msg-ids: 2048] [max-sem-ids: 2048] fs: dir: /shared special: /shared raw not specified type: lofs options: [rw,nodevices] anet: linkname: net0 lower-link: auto allowed-address not specified configure-allowed-address: true defrouter not specified allowed-dhcp-cids not specified link-protection: mac-nospoof mac-address: auto mac-prefix not specified mac-slot not specified vlan-id not specified priority not specified rxrings not specified txrings not specified mtu not specified maxbw not specified bwshare not specified rxfanout not specified vsi-typeid not specified vsi-vers not specified vsi-mgrid not specified etsbw-lcl not specified cos not specified pkey not specified linkmode not specified evs not specified vport not specified rctl: name: zone.max-sem-ids value: (priv=privileged,limit=2048,action=deny) rctl: name: zone.max-msg-ids value: (priv=privileged,limit=2048,action=deny) rctl: name: zone.max-shm-ids value: (priv=privileged,limit=2048,action=deny) rctl: name: zone.max-shm-memory value: (priv=privileged,limit=549755813888,action=deny) root@t7primary:~/config# root@t7primary:~/config# zoneadm list -cv ID NAME STATUS PATH BRAND IP 0 global running / solaris shared - t7zone01 installed /zones/t7zone01 solaris excl - t7zone02 configured /zones/t7zone02 solaris excl
As you can see, the configuration from t7zone1 was taken for the new t7zone2. Recourse controls and the shared directory for example comes from the t7zone1 zone. Now I will clone the first zone, this took around 2-3 seconds :-)
root@t7primary:~/config# zoneadm -z t7zone02 clone t7zone01 WARNING: read-write lofs file system on '/shared' is configured in both zones. The following ZFS file system(s) have been created: rpool/zones/t7zone02 Progress being logged to /var/log/zones/zoneadm.20151221T094156Z.t7zone02.clone Log saved in non-global zone as /zones/t7zone02/root/var/log/zones/zoneadm.20151221T094156Z.t7zone02.clone root@t7primary:~/config#
And yes, it worked... I have both zones now "installed". But you will see, that the new t7zone2 only takes less space.
root@t7primary:~/config# zfs list | grep t7zone rpool/zones/t7zone01 1.80G 829G 32K /zones/t7zone01 rpool/zones/t7zone01/rpool 1.80G 829G 31K /rpool rpool/zones/t7zone01/rpool/ROOT 1.80G 829G 31K legacy rpool/zones/t7zone01/rpool/ROOT/solaris 1.80G 829G 1.73G /zones/t7zone01/root rpool/zones/t7zone01/rpool/ROOT/solaris/var 61.3M 829G 52.6M /zones/t7zone01/root/var rpool/zones/t7zone01/rpool/VARSHARE 1.09M 829G 1.03M /var/share rpool/zones/t7zone01/rpool/VARSHARE/pkg 63K 829G 32K /var/share/pkg rpool/zones/t7zone01/rpool/VARSHARE/pkg/repositories 31K 829G 31K /var/share/pkg/repositories rpool/zones/t7zone01/rpool/export 102K 829G 32K /export rpool/zones/t7zone01/rpool/export/home 69.5K 829G 31K /export/home rpool/zones/t7zone01/rpool/export/home/oracle 38.5K 829G 38.5K /oracle rpool/zones/t7zone02 4.91M 829G 34K /zones/t7zone02 rpool/zones/t7zone02/rpool 4.87M 829G 31K /rpool rpool/zones/t7zone02/rpool/ROOT 4.85M 829G 31K legacy rpool/zones/t7zone02/rpool/ROOT/solaris-0 4.85M 829G 1.73G /zones/t7zone02/root rpool/zones/t7zone02/rpool/ROOT/solaris-0/var 48.5K 829G 52.7M /zones/t7zone02/root/var rpool/zones/t7zone02/rpool/VARSHARE 3K 829G 1.03M /var/share rpool/zones/t7zone02/rpool/VARSHARE/pkg 2K 829G 32K /var/share/pkg rpool/zones/t7zone02/rpool/VARSHARE/pkg/repositories 1K 829G 31K /var/share/pkg/repositories rpool/zones/t7zone02/rpool/export 3K 829G 32K /export rpool/zones/t7zone02/rpool/export/home 2K 829G 31K /export/home rpool/zones/t7zone02/rpool/export/home/oracle 1K 829G 38.5K /oracle root@t7primary:~/config# root@t7primary:~/config# zoneadm list -cv ID NAME STATUS PATH BRAND IP 0 global running / solaris shared - t7zone01 installed /zones/t7zone01 solaris excl - t7zone02 installed /zones/t7zone02 solaris excl root@t7primary:~/config#
So were does this come from? Well, it is a clone... so let's call it a re-write-able snapshot, only differences use space. You can see where it comes from in the following outputs:
root@t7primary:~/config# zfs get origin | awk '$3 !~ /-/ {print}' NAME PROPERTY VALUE SOURCE rpool/zones/t7zone02/rpool origin rpool/zones/t7zone01/rpool@t7zone02_snap00 - rpool/zones/t7zone02/rpool/ROOT origin rpool/zones/t7zone01/rpool/ROOT@t7zone02_snap00 - rpool/zones/t7zone02/rpool/ROOT/solaris-0 origin rpool/zones/t7zone01/rpool/ROOT/solaris@t7zone02_snap00 - rpool/zones/t7zone02/rpool/ROOT/solaris-0/var origin rpool/zones/t7zone01/rpool/ROOT/solaris/var@t7zone02_snap00 - rpool/zones/t7zone02/rpool/VARSHARE origin rpool/zones/t7zone01/rpool/VARSHARE@t7zone02_snap00 - rpool/zones/t7zone02/rpool/VARSHARE/pkg origin rpool/zones/t7zone01/rpool/VARSHARE/pkg@t7zone02_snap00 - rpool/zones/t7zone02/rpool/VARSHARE/pkg/repositories origin rpool/zones/t7zone01/rpool/VARSHARE/pkg/repositories@t7zone02_snap00 - rpool/zones/t7zone02/rpool/export origin rpool/zones/t7zone01/rpool/export@t7zone02_snap00 - rpool/zones/t7zone02/rpool/export/home origin rpool/zones/t7zone01/rpool/export/home@t7zone02_snap00 - rpool/zones/t7zone02/rpool/export/home/oracle origin rpool/zones/t7zone01/rpool/export/home/oracle@t7zone02_snap00 - root@t7primary:~/config# root@t7primary:~/config# zfs list -t snapshot NAME USED AVAIL REFER MOUNTPOINT rpool/ROOT/11.3.3.0.6.0@install 110M - 2.59G - rpool/ROOT/11.3.3.0.6.0@2015-12-16-18:11:00 148M - 2.68G - rpool/ROOT/11.3.3.0.6.0/var@install 95.0M - 133M - rpool/ROOT/11.3.3.0.6.0/var@2015-12-16-18:11:00 327M - 440M - rpool/zones/t7zone01/rpool@t7zone02_snap00 0 - 31K - rpool/zones/t7zone01/rpool/ROOT@t7zone02_snap00 0 - 31K - rpool/zones/t7zone01/rpool/ROOT/solaris@install 7.41M - 605M - rpool/zones/t7zone01/rpool/ROOT/solaris@t7zone02_snap00 4.40M - 1.73G - rpool/zones/t7zone01/rpool/ROOT/solaris/var@install 8.68M - 38.2M - rpool/zones/t7zone01/rpool/ROOT/solaris/var@t7zone02_snap00 200K - 52.6M - rpool/zones/t7zone01/rpool/VARSHARE@t7zone02_snap00 22K - 1.03M - rpool/zones/t7zone01/rpool/VARSHARE/pkg@t7zone02_snap00 0 - 32K - rpool/zones/t7zone01/rpool/VARSHARE/pkg/repositories@t7zone02_snap00 0 - 31K - rpool/zones/t7zone01/rpool/export@t7zone02_snap00 1K - 32K - rpool/zones/t7zone01/rpool/export/home@t7zone02_snap00 0 - 31K - rpool/zones/t7zone01/rpool/export/home/oracle@t7zone02_snap00 1K - 38.5K - root@t7primary:~/config#
OK, let's boot the zones. The first one boots up like before. With the new one, you will need to go threw the installation configuration:
root@t7primary:~/config# zoneadm -z t7zone01 boot root@t7primary:~/config# zoneadm -z t7zone02 boot root@t7primary:~/config# zlogin -C t7zone02 System Configuration Tool System Configuration Tool enables you to specify the following configuration parameters for your newly-installed Oracle Solaris 11 system: - system hostname, network, time zone and locale, user and root accounts, name services, support System Configuration Tool produces an SMF profile file in etc/svc/profile/sysconfig/sysconfig-20151221-104209. How to navigate through this tool: - Use the function keys listed at the bottom of each screen to move from screen to screen and to perform other operations. - Use the up/down arrow keys to change the selection or to move between input fields. - If your keyboard does not have function keys, or they do not respond, press ESC; the legend at the bottom of the screen will change to show the ESC keys for navigation and other functions. F2_Continue F6_Help F9_Quit [...] -> skipped root@t7primary:~/config# root@t7primary:~/config# zoneadm list -cv ID NAME STATUS PATH BRAND IP 0 global running / solaris shared 3 t7zone01 running /zones/t7zone01 solaris excl 4 t7zone02 running /zones/t7zone02 solaris excl root@t7primary:~/config#
And that's it... Took about 2 Minutes and you have a new installation :-) It is now a clone... with ZFS clones there are no performance penalties, you can only win and use less space. But if you really want to have your one filesystem you could also "promote" the clone. Promotes a clone file system to no longer be dependent on its origin snapshot. You will need this, if you ever plan to destroy t7zone01...