ZoneDemo

Creating/Cloning a Zone Demo (5 Minutes)

Description

Creating a zone during a live presentation on stage is tricky because zone creation requires a 70MB download from IPS. Fortunately, the process of cloning a zone is almost identical to creating a zone. Creating a zone is a 4 step process: create, install, boot and configure. Cloning a zone simply replaces the install step with clone: create, clone, boot and configure. The only difference being that you need to have zone available to clone.

We'll be creating a zone for running GlassFish, gfzone, which will create by cloning a zone called myzone.

OpenSolaris Versions Supported

2009.06

Points to Hit

  • OpenSolaris zones allow you to virtualize and partition the operating system.

Demo Prep

  • A zone must be available to clone. Follow the blog Preconfiguring Zones to get started. You'll end up with a zone called myzone. Make sure it's been booted at least once to ensure the SMF service descriptions have been loaded. If not, the clone will spend unnecessary time loading them.
  • Save the following zone configuration file to your home directory:
bleonard@opensolaris:~$ cat gfzone.config
create
set zonepath=/zones/gfzone
set ip-type=exclusive
add net
set physical=glzone0
end
  • Save the following sysidcfg file to your home directory:
bleonard@opensolaris:~$ cat gfzone.config
create
set zonepath=/zones/gfzone
set ip-type=exclusive
add net
set physical=gfzone0
end

Gotchas

Things that may go wrong

Demo

Create a VNIC for the Zone

Hopefully you've already covered and possibly done the VNIC Demo. Here we'll create a VNIC for our zone to use. First, review the physical links on the system:

dladm show-phys

Then, create a virtual NIC over one of the Ethernet links:

pfexec dladm create-vnic -l e1000g0 gfzone0

Where e1000g0 is the name of your network interface card from dladm show-phys.

Create the Zone

Show the existing zones on the system (which may be just the global zone):

zoneadm list -cv

Create the new zone:

pfexec zonecfg -z gfzone -f gfzone.config

Install (Clone) the Zone

Note to the audience that if we were creating the zone from scratch, the only difference would be that we'd use "install" rather than "clone" in the command below. Running install would fetch the zone from the IPS repository, which is about 70MB of data and impractical for an on stage demo.

Look at the existing zones on the system. We'll be using the "installed" myzone to create the "configured" (needs to be installed) gfzone.

bleonard@opensolaris:~$ zoneadm list -cv
  ID NAME             STATUS     PATH                           BRAND    IP
   0 global           running    /                              native   shared
   - myzone           installed  /zones/myzone                  ipkg     excl
   - gfzone           configured /zones/gfzone                  ipkg     excl

Create the clone:

bleonard@opensolaris:~$ pfexec zoneadm -z gfzone clone myzone
sys-unconfig started Fri Jul 17 10:27:43 2009
rm: cannot remove `/zones/gfzone/root/etc/vfstab.sys-u': No such file or directory
grep: /zones/gfzone/root/etc/dumpadm.conf: No such file or directory
sys-unconfig completed Fri Jul 17 10:27:43 2009

You can ignore the sys-unconfig warnings.

Boot & Configure the Zone

Ready the zone's file system so we can copy the sysidcfg file to it:

pfexec zoneadm -z gfzone ready

Copy the sysidcfg file:

pfexec cp sysidcfg /zones/gfzone/root/etc/.

Log into the zone:

bleonard@opensolaris:~$ pfexec zlogin -C gfzone
[Connected to zone 'gfzone' console]

Open a 2nd terminal the boot the zone:

pfexec zoneadm -z gfzone boot

Back in the first terminal wait while the zone is configured and then log in using abc123 as the root passowrd:

[NOTICE: Zone booting up]


SunOS Release 5.11 Version snv_111b 64-bit
Copyright 1983-2009 Sun Microsystems, Inc.  All rights reserved.
Use is subject to license terms.
Hostname: gfzone
Reading ZFS config: done.
Mounting ZFS filesystems: (5/5)
 network_interface=gfzone0 {
gfzone0 is not a valid network interface  line 3 position 19
Creating new rsa public/private host key pair
Creating new dsa public/private host key pair
Configuring network interface addresses: gfzone0.

gfzone console login: root
Password:
Jul 17 10:33:32 gfzone login: ROOT LOGIN /dev/console
Last login: Thu Jul 16 14:41:03 on console
Sun Microsystems Inc.   SunOS 5.11      snv_111b        November 2008
root@gfzone:~#

From the 2nd terminal, halt the zone and show how quickly it boots up once it's been configured:

pfexec zoneadm -z gfzone halt
pfexec zoneadm -z gfzone boot

Demo Cleanup

These are the necessary steps to take in order to successfully run the demo again on the same machine.

bleonard@opensolaris:~$ pfexec zoneadm -z gfzone halt
bleonard@opensolaris:~$ pfexec zoneadm -z gfzone uninstall
Are you sure you want to uninstall zone gfzone (y/[n])? y
bleonard@opensolaris:~$ pfexec zonecfg -z gfzone delete
Are you sure you want to delete zone gfzone (y/[n])? y
bleonard@opensolaris:~$ pfexec dladm delete-vnic gfzone0
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

Sign up or Log in to add a comment or watch this page.


The individuals who post here are part of the extended Sun Microsystems community and they might not be employed or in any way formally affiliated with Sun Microsystems. The opinions expressed here are their own, are not necessarily reviewed in advance by anyone but the individual authors, and neither Sun nor any other party necessarily agrees with them.

Copyright 1994-2009 Sun Microsystems, Inc.
Powered by Atlassian Confluence
Sun Guidelines on Public Discourse Privacy Policy Terms of Use Trademarks Site Map Employment Investor Relations Contact