Solaris-Zones: Linux IT Marbles Get a New Bag
Listing 5. Log In to a Zone
# Connect to zone's console g-zone# zlogin -C -e '#' red-zone # Login without a console (must always be root) g-zone# zlogin red-zone ... r-zone# zonename red-zone
We now have a zone defined, installed and running. The examples presented here illustrate some of the administrative tasks associated with zones: reboot, shutdown, halt and deletion of an lx branded zone. Pay close attention to the shell prompts to identify the zone in which each command is run.
Listing 6. Zone Administration
# By default a zone will *not* auto boot when the system boots g-zone# zonecfg -z red-zone set autoboot=true # Reboot/stop a zone gracefully g-zone# zlogin -C -e '#' red-zone # Login, then use a normal Linux command (examples) r-zone# reboot r-zone# shutdown -r now r-zone# telinit 6 r-zone# telinit 0 (once halted boot it from global zone) # Bring down a zone hard (stop all execution now!) g-zone# zoneadm -z red-zone halt # Same as halt and boot (hard stop then boot) g-zone# zoneadm -z red-zone reboot # Uninstall the OS from a zone (still defined) g-zone# zoneadm -z red-zone halt g-zone# zoneadm -z red-zone uninstall [ -F ] # Clone an installed zone's OS into another defined zone # (when the source is on ZFS the clone takes seconds to # install the new zone, otherwise may take many minutes!) g-zone# zonecfg -z red-eye create -t red-zone g-zone# zonecfg -z red-eye set zonepath=/zpool01/zones/red-eye g-zone# zonecfg -z red-eye zonecfg:red-eye> select net address=192.168.1.10 zonecfg:red-eye:net> set address=192.168.1.11 zonecfg:red-eye:net> end zonecfg:red-eye> exit g-zone# zoneadm list -cv ID NAME STATUS PATH BRAND IP 0 global running / native shared - red-zone installed /zpool01/zones/red-zone lx shared - red-eye configured /zpool01/zones/red-eye lx shared g-zone# zoneadm -z red-eye clone red-zone Cloning zonepath /zpool01/zones/red-zone... g-zone# zoneadm list -cv ID NAME STATUS PATH BRAND IP 0 global running / native shared - red-zone installed /zpool01/zones/red-zone lx shared - red-eye installed /zpool01/zones/red-eye lx shared # Remove a zone (No undo) g-zone# zoneadm -z red-eye halt g-zone# zoneadm -z red-eye uninstall -F g-zone# zonecfg -z red-eye delete -F
The zone creation steps are straightforward and simple. The process may take only a few steps, but they are manual and error-prone. The zonetool.pl utility (see Resources) automates the zone creation process and includes detailed POD documentation. Run zonetool.pl without arguments or with the --help option to display usage details. Listing 7 shows an example of using zonetool.pl.
Listing 7. Zone Definition Using zonetool.pl
$ sudo zonetool.pl \ [ --debug ] \ --create \ --zonename green-zone \ --brand SUNWlx[,server ] \ --zonepath /zpool01/zones \ [ --autoboot ( true | false ) ] \ [ --clone red-zone | --media /path/to/ISOs ] \ --network 'e1000g0=192.168.1.10'
With relatively small amounts of disk and memory resources, a single physical server can host hundreds of zones. Each zone is usable by any number of users, and a single-user zone provides extreme flexibility. A single user can create more than one zone to test both server and client environments, and the applications will believe they are on unique physical hosts. A zone user may have use of the zone's unique root password or unfettered sudo access within that zone without concern for security and stability of the global zone and other non-global zones.
The lx branded zone does have its limitations. Much of the zone's power comes from securely shared resources with the global zone. The zone shares a kernel with the global zone and, therefore, places limits on kernel modules and drivers. Because zones are not full VMs, the Linux distributions that can be installed in an lx branded zone are limited. Support for other Linux releases is possible, and further interest in this technology will inspire continued development and support for additional Linux distributions. Review the Resources section of this article for more information on this and related topics.
- Free Today: September Issue of Linux Journal (Retail value: $5.99)
- The Tiny Internet Project, Part I
- Bitcoin on Amazon! Sort of...
- Machine Learning with Python
- Download "Linux Management with Red Hat Satellite: Measuring Business Impact and ROI"
- Android Browser Security--What You Haven't Been Told
- Epiq Solutions' Sidekiq M.2
- Securing the Programmer
- Returning Values from Bash Functions