Devzones, short for development zones, is a type of virtualization found in the Nexenta distribution. It can be used to define a base developer environment, which can be easily cloned many times. These copies can easily be destroyed and recreated.
Devzones are built upon Opensolaris Zones, which are extensions of a chroot-like environment for the entire installed system. In other words, it allows for virtualization of an Opensolaris environment (and variants of Linux), without the performance hit that is generally associated with virtualization.
This article gives a practical introduction into using Devzones.
John is a developer on project X, and wants to involve A, B, C and D from around the world to the project. However, project X requires that the environment variables be set, certain packages be installed, and source code be setup. It also requires build machines be installed with an operating system, accounts be created with the right permissions, and care taken to see that the users cannot inadvertently bring down the machine. How can John create such a setup, and reduce the time required to initiate A, B, C and D to project X close to 0?
One way is to setup a build machine, setup all the relevant packages, and hope A, B, C and D use the resources and privileges given to them correctly. Setting this up takes the initial time. If the system is corrupted, taken down for any reason by user A, the others would be hit, and time is also lost with setting up the environment again.
Another solution is to create a virtual machine, and install relevant packages, and set them up so A, B, C and D can pick it up immediately and start working. This however involves playing with big VM files, and takes up disk space 4 times. Another downside is that virtualization takes a performance hit.
What if there was a method where:
- You can easily create and destroy an installed system.
- Lose no disk space when you create copies of a system.
- The creation and deletion of these systems took under 3 seconds.
- You have access to Ubuntu’s stack of server and other applications
Devzones, short for development zones, is a type of virtualization found in the Nexenta distribution. It can be used to define a base developer environment, which can be easily cloned many times. These copies can easily be destroyed and recreated.
Devzones are built upon Opensolaris Zones, which are extensions of a chroot-like environment for the entire installed system. In other words, it allows for virtualization of an Opensolaris environment (and variants of Linux), without the performance hit that is generally associated with virtualization. For a detailed look at Nexenta, take a look at an earlier article on Nexenta here. For more information on Zones, take a look at it’s community page.
Nexenta is a FOSS distribution that combines the Opensolaris kernel with Ubuntu’s userland. It contains packages from Ubuntu LTS 8.04 (hardy). More information at the Nexenta homepage.
In this article we’ll take a step-by-step look at how we can setup Devzones on Nexenta.
Installation
Devzones are simple to install, simply run:
sudo apt-get install Devzones
NOTE: The latest NCP2 beta1 distribution includes Devzones by default.
Devzones consists of a set of applications that interact with the lower-level Opensolaris Zone commands.
For the administrator
- Devzone_adm
- Devzone_adm init
- Devzone_adm add
- Devzone_adm del
- Devzone_adm list
- Devzone_adm create
- Devzone_adm free
- Devzone_adm uninit
For the user
- Devzone_create
- Devzone_enter
- Devzone_free
Zones
To understand how Devzones work, lets understand how zones work on Opensolaris. A zone is a virtualized environment where you can run applications. The application run in this sand-boxed environment, and as far as it is concerned, it is running in a brand new install of the operating system. Devzones configures one such base zone as a template to create other Devzones. Thus, you can customize this base environment to your needs (Ex: installing build tools, custom apps, etc).
Setting up the base zone
If you’re already familiar with Opensolaris zones, you can generate a zone manually for your needs. If you aren’t, run the following in the Nexenta shell. If you want to setup base zone on a different IP address, change the “set address=” line. Also change bge0 to reflect your network interface (can be found by running the ‘ifconfig -a’ command )
sudo zonecfg -z base_zone << EOD create -b set zonepath=/zones/base_zone set ip-type=shared add net set address=172.24.101.56 set physical=bge0 end commit verify EOD
You’ve now created the configuration for your base zone, named base_zone. The next step is to install it, which can be done by the following command:
#installing the zone. This will take a little while sudo zoneadm -z base_zone install
NOTE: the first line of output should say:
A ZFS file system has been created for this zone.
This means the zone is ready for use with ZFS snapshots and clones. If this message is missing, the zone is not setup properly with ZFS and would be duplicated by copying which is slow and uses more disk space than ZFS snapshots and clones.
The final step is to add your special magic to the base zone, and configuring the environment for your needs. This is done by booting the zone, and logging in:
#boot the zone so you can login. sudo zoneadm -z base_zone boot #Once done, login normally sudo zlogin base_zone
Customizations
Once you run zlogin, you are dropped into the zone as a root user. Go ahead and customize the environment to your taste. Various tasks you might do are:
- Installing compilers and build tools: apt-get install build-essential
- Installing your favourite tools: apt-get install screen irssi
- Customizing rc files (.vimrc, .bashrc, .screenrc)
- Etc..
Once you’ve made your changes, run logout to go back to the global zone
Setting up the Devzones
We now move to the final step: stopping the zone, and creating Devzones. The Devzone has to be stopped before it can be cloned. To stop the base zone, run:
sudo zoneadm -z base_zone halt
Initialize the Devzone database
sudo Devzone_adm init
You will now have to decide how many Devzones the machine can support (i.e, how many users can be logged in at the same time working in their own Devzone). A good rule of thumb is to give 512 MB of RAM to a zone, and thus the number of zones you can have
Number of Devzones = Free memory / 512
You can modify the memory usage number depending on the amount of resources you think your typical Devzone tasks will require. Also decide on a name and IP address for each zone and run:
sudo Devzone_adm add zonename
show the text of a created zone
Do this for each zone. Devzones are now setup!
The User
A normal user, to create a Devzone, runs:
Devzone_create anilg@mybox:~$ Devzone_create Reserving zone: lanai setting up zone: lanai Cloning snapshot tank/zones/base_zone@SUNWzone4 Instead of copying, a ZFS clone has been created for this zone.
This will reserve a Devzone for the user. He can then enter and exit the zone using the following:
#Entering the Devzone Devzone_enter #Coming out of a Devzone, run the following when inside logout
A user can also run a command inside the Devzone
Devzone_enter command anilg@mybox:~$ Devzone_enter hostname Zone state: running Entering zone... lanai anilg@mybox:~$
Once a user is done using the zone, he simply runs the following to destroy his zone, and free it up for someone else:
Devzone_free
If an administrator wants to free a Devzone, he can free it using the Devzone_adm free command:
sudo Devzone_adm list Zone User UID global root 0 lanai anil 1001 fiji -1 kauai -1 maui -1 midway -1 oahu -1 tahiti -1 sudo Devzone_adm free zonename anil@gnusolaris:~$ sudo Devzone_adm free lanai Running Releasing zone... taking down zone: lanai halting... uninstalling... The ZFS file system for this zone has been destroyed. deleting configuration... Releasing zone completed
Try it
This was a simple guide to Devzones on Nexenta. To recount the advantages of Devzones
- Easily deployable environment: create and delete instances of a devzone in a jiffy
- Resource efficient: if you have 50 developers, with a maximum of 10 actually developing at any given time, invest only on the resources of 10.
- Space efficient: creation of a new instance of a devzone does not take up space. It is only consumned for new content created.
- Instant update: changes made to the base zone are reflected to all devzones.
- Peace of mind: Your users can run an rm -rf *, in their devzone, without affecting the others. Also setting up after a screw-up takes an instant.
Give it a shot, and reduce the time required for your developers setup the working environment. You can grab Nexenta from:
- Webpage: http://www.nexenta.org
- All things nexenta: http://blogs.nexenta.org
To try out a live demo of Devzone, join our IRC channel below and ask for our build machine’s community login/pass. Devzone is primarily developed and maintained by Tim Spriggs and he can be found
on the Nexenta IRC channel on freenode for any questions/comments/suggestions you have.
- IRC: #[email protected]
- Devzone project: http://sourceforge.net/projects/Devzone/
Duke Nukem 3d was the last game with any story. That game really kicked arse… especially in co-op mode. I’ve tried playing the modern 3d equivalents, and they all suck. They’re to busy trying to make the graphics look real instead of making a good game. Dukes graphics never looked real but it was funny as hell, I don’t plan on playing any other game until Duke Nulem forever comes out.
from what i can see this has nothing ot do with the article, but as i too am a duke nukem fan I will give you this piece of advice. If you are waiting to get back into gaming until Duke Nuken Forever is realeased, well you may never get back into gaming. at least not until Q2 of 2010.
I’m sure he meant to post this in Thom’s rant about modern gaming.
This is a long standing bug in the new version of OSNews it seems. I’ve seen it happen several times. They have problems with their Web flow getting confused about where you are and where you are trying to post a comment. If I had to guess, (cause I’ve run into similar problems in my own Web applications), it probably has to do with having multiple tabs or windows open on the same site that are sharing the same session cookie. This can cause race type conditions if you aren’t really careful about knowing which tab or window the request came from.
Edited 2008-12-22 18:09 UTC
Should actually be:
http://devzone.sourceforge.net
Thanks for writing the article Anil!
Fixed, and added reference to you at the bottom of the article. Keep up the good work!
This is interesting! Do these zones function like freebsd jails? Jails are the goodness, and I wanted to try out solaris so that may help me cross over faster
They are just ordinary Zones in Solaris/OpenSolaris. You can install Solaris 10 in a Zone, or Solaris 9, Solaris 8 or Linux v2.4. There is rudimentary support for Linux v2.6 in Zones.
Try Nexenta or OpenSolaris or Solaris 10 if you want to play with Zones.
One guy booted 1000 zones in 1 GB RAM. It worked, but very slowly. Rock solid. Rock stable.