Solaris Zone Basics
We are using the default zone filesystem model is called sparse-root. As of this article a new zone comes out to only 515MB.
Installing Zone Software
Before continuing make sure the packages required for zones are installed.
Creating a Sparse Zone
First, make sure you are running as root:
su - rootPick an ip address make sure to ping from inside the subnet to ensure it is not already being used. You will also need to determine the physical address you want to use.
ifconfig -a | grep -i broadcast
e1000g0: flags=201000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4,CoS> mtu 1500 index 2
inet 10.248.143.60 netmask ffffff00 broadcast 10.248.143.255
e1000g0:1: flags=201000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4,CoS> mtu 1500 index 2
inet 10.248.143.33 netmask ffffff00 broadcast 10.248.143.255
e1000g0:2: flags=201000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4,CoS> mtu 1500 index 2
inet 10.248.143.37 netmask ffffff00 broadcast 10.248.143.255
e1000g0:3: flags=201000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4,CoS> mtu 1500 index 2
inet 10.248.143.63 netmask ffffff00 broadcast 10.248.143.255
e1000g0:4: flags=201000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4,CoS> mtu 1500 index 2
inet 10.248.143.65 netmask ffffff00 broadcast 10.248.143.255
e1000g0:5: flags=201000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4,CoS> mtu 1500 index 2
inet 10.248.143.68 netmask ffffff00 broadcast 10.248.143.255
e1000g0:6: flags=201000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4,CoS> mtu 1500 index 2
inet 10.248.143.62 netmask ffffff00 broadcast 10.248.143.255
e1000g0:7: flags=201000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4,CoS> mtu 1500 index 2
inet 10.248.143.64 netmask ffffff00 broadcast 10.248.143.255In the results from the example above, we are using the physical network card e1000g0 which have the assigned ip addresses (in bold).
Set Zone Path
Follow these instructions where my_zone will be the name of the new zone you are creating.
su - root
zoneadm list -cv {see what zones you have}
zonecfg -z[my_zone]You will see the message below and and be taken into a special command prompt for zone control,
[my_zone]: No such zone configuredzonecfg:[my_zone]>create {to create your new zone}
zonecfg:[my_zone]>set zonepath=/var/zones/[my_zone]
zonecfg:[my_zone]>add net
zonecfg:[my_zone]:net>set physical=[bge0] {this references the chosen physical network card}
zonecfg:[my_zone]:net>set address=10.248.142.2 {if you want to specify a specific subnet use, 10.248.142.2/xx}
zonecfg:[my_zone]:net>end
zonecfg:[my_zone]>info {double check your settings}
zonecfg:[my_zone]>verify
zonecfg:[my_zone]>commit
zonecfg:[my_zone]>exit
zoneadm list -cv {see the new zone you created}Commit the zone,
zoneadm -z [my_zone] install
(You may encounter the following - ERROR: zones not available on this system, I don't know why this happens, but I got around this
by reinstalling the following packages- SUNWluzone SUNWzoneu SUNWzoner - Duncan)
If you are manually cloning a zone do not boot the zone yet. Instead stop here and go back to Manually Cloning a Zone.
Boot and Verify the Zone
Start a new session in the Global Zone, we will call it session2 which will allow us to watch [my_zone] boot up.
su - root
zlogin -C [my_zone] {simulates the terminal console for you}Note: Use DEC VT100 for proper screen use and ~. to exit.
Now go back to your first session in the Global Zone and start the [my_zone] boot,
zoneadm -z [my_zone] bootWatch the console in session2. If you are not cloning the zone then you will be asked a subset of questions (many will be inherited from the global zone) on how to setup the Solaris operating sytem inside zone. Otherwise, ensure the [my_zone] boots up properly.
Delete a Zone
zoneadm -z [my_zone] uninstall {deletes all of the files under the zonepath}
zonecfg -z [my_zone] delete {remove it completely from the zone system}
cd /var/zones
rm -rf [myzone] {deletes the files}Change a Zones IP Address and Interface
Best to shutdown the zone before doing this.
zonecfg -z [my_zone]
zonecfg:[my_zone]>info {look at the old ip address}
zonecfg:[my_zone]>select net address=[old_ip]
zonecfg:[my_zone]:net>set address=[new_ip] {if you need to specify a subnet use [new_ip]/## for example [new_ip]/25 specifies}
zonecfg:[my_zone]:net>set physical=[new_interface]
zonecfg:[my_zone]:net>end
zonecfg:[my_zone]>commitAlso, /etc/zones/[my_zone].xml can be directly modified.
Move a Zone
Keep in mind, the simple copy -r command will not work. You need to do some crazy tar command or even easier use the built in zone commands,
http://docs.sun.com/app/docs/doc/817-1592/gcgnc?a=view
More Information on Zones for Solaris 10
Here are some more details about zones. Zones are similiar to regular virtual machines except that the kernel and some of the file structure can be shared. By default there is already a global zone created which contains all other zones.
sparse:
/usr, /sbin, /platform and /lib directories are read-only loopback links to the global zone.
Disk savings over a whole root zone.
You can not install anything in loopbacked files system from within the local zone.
whole root:
All of the needed data is copied from the global zone.
container:
Whole root zone but given shares via fair-share scheduling.