The Complete Magazine on Open Source

Virtualisation and Disk Management in OpenIndiana

, / 124 2

Let's play the disk

In the previous part, we got acquainted with OpenIndiana — how to install the base system, find and deploy packages, and perform maintenance tasks with ZFS. This part is devoted to isolated and virtualised environments, and disk management.


Sun Microsystems, and now Oracle, oversee the development of the emulation project called VirtualBox. However, this package couldn’t be found in the OpenIndiana (OI) repositories. To install it in OI, grab the gzipped package here and manually install it. The archive is called “VirtualBox 4.1 for Solaris hosts x86/amd64”. Please unpack it, and then run pkgadd:

[email protected]:/home/anton/Install# pkgadd -d VirtualBox-4.1.0-SunOS-r73009.pkg

The following packages are available:
1  SUNWvbox     Oracle VM VirtualBox
                  (i386) 4.1.0,REV=2011.

Select package(s) you wish to process (or 'all' to process
all packages). (default: all) [?,??,q]: a

Processing package instance <SUNWvbox> from </home/anton/Install/VirtualBox-4.1.0-SunOS-r73009.pkg>


The following files are being installed with setuid and/or setgid
/opt/VirtualBox/amd64/VBoxBFE <setuid root>
/opt/VirtualBox/amd64/VBoxHeadless <setuid root>
/opt/VirtualBox/amd64/VBoxNetAdpCtl <setuid root>
/opt/VirtualBox/amd64/VBoxNetDHCP <setuid root>
/opt/VirtualBox/amd64/VBoxSDL <setuid root>
/opt/VirtualBox/amd64/VirtualBox <setuid root>
Do you want to install these as setuid/setgid files [y,n,?,q] y

This package contains scripts which will be executed with super-user
permission during the process of installing this package.

Do you want to continue with the installation of <SUNWvbox> [y,n,?] y

Installing Oracle VM VirtualBox as <SUNWvbox>


Installation of <SUNWvbox> was successful.

Running VirtualBox in OpenIndiana

Running VirtualBox in OpenIndiana

File operations, and the general VirtualBox used in OI, are no different than on Linux. You can even exchange VMs created in OI with Linux, and vice-versa.


However, some developers need to deal with platforms other than x86 — for example, ARM and PowerPC. So, what’s the alternative to VirtualBox? The solution is straightforward — QEMU. It can emulate x86 systems and a dozen other architectures; e.g., Linux for ARM with qemu-system-arm, or MacOS X with qemu-system-ppc64.

The build process for QEMU 0.15 requires the [email protected] package, as well as developer packages that contain definitions of mathematical functions. I performed the following operations:

[email protected]:/home/anton# pkg info | egrep "math|gettext"
Name: developer/gnome/gettext
FMRI: pkg:[email protected],5.11-0.151:20110523T143743Z
Name: system/library/math
FMRI: pkg:[email protected],5.11-0.151:20110523T150249Z
Name: system/library/math/header-math
FMRI: pkg:[email protected],5.11-0.151:20110523T150250Z

I was able to build QEMU 0.15 without problems. However, I have to disable GuestAgents support, mainly because QEMU 0.15 calls functions with O_ASYNC parameters, which isn’t supported on Solaris.

QEMU 0.15 compiled on OI; VM with Ubuntu Server

QEMU 0.15 compiled on OI; VM with Ubuntu Server

Windows 2003 EE in QEMU 0.15

Windows 2003 EE in QEMU 0.15

You could compile the previous version, 0.14, or do a quick hack on line 493 in qemu-ga.c, from:

fd = qemu_open(s->path, O_RDWR | O_NONBLOCK | O_ASYNC);


fd = qemu_open(s->path, O_RDWR | O_NONBLOCK);

Or, as mentioned earlier, compile it without GuestAgents support:

./configure --prefix=/opt/qemu-0.15 –disable-guest-agent
make && make install ## run as root

After that, you should prepare a file image for the virtual OS to install to, and run it as follows:

/opt/qemu-0.15/bin/qemu-img create ubuntu2.img 2000M
/opt/qemu-0.15/bin/qemu -hda ubuntu2.img -cdrom /home/anton/ISO/ubuntu-10.10-server-i386.iso -M pc -m 768 -vga cirrus -no-acpi

Similarly, you can use other OSs, for example, Windows 2003 EE:

/opt/qemu-0.15/bin/qemu -hda windows2003.img -cdrom /home/anton/ISO/win2003_sp2.iso -M pc -m 1024 -vga cirrus
A small tip: If you can’t press the keyboard Ctrl+Alt+Del, then go to the QEMU console with Ctrl+Alt+2. Here, type  sendkey ctrl-alt-delete and press Enter. The OS in the VM will receive the keyboard combination.

Disk management

Let’s imagine that you have a new drive to be used for data storage. It could be a special, dedicated database storage pool. This drive should be initialised first, partitioned with a file format that is used by OI. You can use the format command (it can be used in interactive mode):

[email protected]:/home/anton# format
Searching for disks...
Failed to inquiry this logical diskdone

       0. c1d0 < cyl 2868 alt 2 hd 255 sec 63>
          [email protected],[email protected],[email protected][email protected],0
       1. c2d1 <QEMU HAR-QM0000-0001-2.00GB>
          [email protected],[email protected],[email protected][email protected],0

We can format the whole drive with the format option in the menu (not shown), or assign a label using volname.

The last step is to add the drive to the ZFS pool—and the new storage space is ready to use:

[email protected]:/home/anton# zpool create pool c2d1

You can list the available pools and see that both
pools (i.e., disks) are online:

[email protected]:/home/anton# zpool list
pool   1.98G   124K  1.98G     0%  1.00x  ONLINE  -
rpool  21.9G  9.17G  12.7G    41%  1.00x  ONLINE  -

Zones management

In addition to VirtualBox and QEMU virtualisation, OI (and OpenSolaris) offers fairly well-developed virtualisation within the OS, called Solaris Zones. Unfortunately, OI does not yet support zones that can run Linux (though it was available in the previous OpenSolaris version). OI supports mere native zones — when the system runs zones (or containers) with OI inside them. Let’s explore how to create them. Begin by using the following code:

[email protected]:/home/anton# zonecfg -z NewZone
NewZone: No such zone configured
Use 'create' to begin configuring a new zone.
zonecfg:NewZone> create
zonecfg:NewZone> add net
zonecfg:NewZone:net> set physical = rtls0
zonecfg:NewZone:net> set address =
zonecfg:NewZone:net> end
zonecfg:NewZone> set zonepath=/pool/NewZone
zonecfg:NewZone> commit
zonecfg:NewZone> exit

You have created a new zone. It is stored under /pool/NewZone on the disk you just attached and initialised. For a zone to be complete, you must install the bare OI system into this area:

[email protected]:/home/anton# zoneadm -z NewZone install
A ZFS file system has been created for this zone.
   Publisher: Using ( ).
       Image: Preparing at /pool/NewZone/root.
Refreshing catalog 1/1
Caching catalogs ...
       Cache: Using /var/pkg/download.
Sanity Check: Looking for 'entire' incorporation.
  Installing: Core System (output follows)

               Packages to install:     1
           Create boot environment:    No


Postinstall: Copying SMF seed repository ... done.
Postinstall: Applying workarounds.
        Done: Installation completed in 771.344 seconds.

Next Steps: Boot the zone, then log into the zone console (zlogin -C)
              to complete the configuration process.

The system is installed into an isolated container. Let’s run it!

[email protected]:/home/anton# zoneadm -z NewZone boot

zone 'NewZone': WARNING: rtls0:1: no matching subnet found in netmasks(4):; using default of

Now, perform a minimal configuration of this zone.
Connect to a virtual console with zlogin -C NewZone:

[email protected]:/home/anton# zlogin -C NewZone
[Connected to zone 'NewZone' console]
Hostname: NewZone

Loading smf(5) service descriptions: 3/3

What type of terminal are you using?
 1) ANSI Standard CRT
 2) DEC VT100
 3) PC Console
 4) Sun Command Tool
 5) Sun Workstation
 6) X Terminal Emulator (xterms)
 7) Other
Type the number of your choice and press Return: 6
Creating new rsa public/private host key pair
Creating new dsa public/private host key pair
Configuring network interface addresses: rtls0.

System identification is completed.

rebooting system due to change(s) in /etc/default/init

[NOTICE: Zone rebooting]

SunOS Release 5.11 Version oi_151 64-bit
Copyright (c) 1983, 2010, Oracle and/or its affiliates. All rights reserved.
Hostname: NewZone

NewZone console login: root
Aug  8 14:09:54 NewZone login: ROOT LOGIN /dev/console
OpenIndiana (powered by illumos)    SunOS 5.11    oi_151    July 2011

The one-time configuration of the new zone is done. Review the new zone’s available resources. They’re completely isolated, like the whole environment, in general:

[email protected]:~# df
/                  (pool/NewZone/ROOT/zbe): 3007372 blocks  3007372 files
/dev               (/dev              ):       0 blocks        0 files
/proc              (proc              ):       0 blocks    29917 files
/system/contract   (ctfs              ):       0 blocks 2147483588 files
/etc/mnttab        (mnttab            ):       0 blocks        0 files
/system/object     (objfs             ):       0 blocks 2147483418 files
/etc/svc/volatile  (swap              ): 5920888 blocks   578264 files
/lib/     (/usr/lib/libc/ 3007372 blocks  3007372 files
/dev/fd            (fd                ):       0 blocks        0 files
/tmp               (swap              ): 5920888 blocks   578264 files
/var/run           (swap              ): 5920888 blocks   578264 files

Restarting NewZone does not interrupt the core system;
rebooting takes less than a minute:

[email protected]:/# reboot
Aug  8 14:15:37 NewZone reboot: initiated by root on /dev/console

[NOTICE: Zone rebooting]

SunOS Release 5.11 Version oi_151 64-bit
Copyright (c) 1983, 2010, Oracle and/or its affiliates. All rights reserved.
Hostname: NewZone

NewZone console login: root
Aug  8 14:16:18 NewZone login: ROOT LOGIN /dev/console
Last login: Mon Aug  8 14:09:54 on console
OpenIndiana (powered by illumos)    SunOS 5.11    oi_151    July 2011
[email protected]:~# date
Mon Aug  8 14:16:22 CEST 2011

I propose to build a QEMU package, so it can be installed later inside NewZone. Why is this so important? It could sometimes be essential to have a standalone package, if it’s new and not in the OI repository yet. Or, in the opposite case — for your own corporate program which you don’t wish to redistribute. As an example, let’s analyse how to create a package from the set of programs in /opt/qemu-0.14.

The first step is to prepare two files, prototype and pkginfo.

# echo 'i pkginfo' > prototype
# pkgproto /opt/qemu-0.14/  >> prototype

In prototype, you should specify those files and directories that the future package will contain. The pkginfo file will contain all information about this package:

[email protected]:~/pkg# cat pkginfo
DESC=QEMU virtualization
[email protected]

Begin building the package itself:

[email protected]:~/pkg# pkgmk -b /opt/qemu-0.14 -r /
## Building pkgmap from package prototype file.
## Processing pkginfo file.
WARNING: missing directory entry for </opt>
WARNING: parameter <PSTAMP> set to "openindiana20110814071557"
WARNING: parameter <CLASSES> set to "none"
## Attempting to volumize 84 entries in pkgmap.
part  1 -- 123944 blocks, 428 entries
## Packaging one part.
## Validating control scripts.
## Packaging complete.

The package is ready, and is stored in /var/spool/pkg. The last step is to convert it to a special pkg format:

[email protected]:~/pkg# pkgtrans -s /var/spool/pkg/ qemu.pkg

The following packages are available:
  1  qemu     qemu
              (x86) 0.14

Select package(s) you wish to process (or 'all' to process
all packages). (default: all) [?,??,q]: 1
Transferring <qemu> package instance
[email protected]:~/pkg# ls -l /var/spool/pkg/
total 58668
drwxr-xr-x 3 root root        5 2011-08-14 08:15 qemu
-rw-r--r-- 1 root root 59996160 2011-08-14 08:19 qemu.pkg

Now, transfer qemu.pkg to the isolated area, and install it in NewZone:

[email protected]:/export# pkgadd -d qemu.pkg

The following packages are available:
  1  qemu     qemu
              (x86) 0.14

Select package(s) you wish to process (or 'all' to process
all packages). (default: all) [?,??,q]: 1

Processing package instance <qemu> from </export/qemu.pkg>

qemu(x86) 0.14
## Processing package information.
## Processing system information.
## Verifying disk space requirements.
## Checking for conflicts with packages already installed.
## Checking for setuid/setgid programs.

Installing qemu as <qemu>

## Installing part 1 of 1.
[ verifying class <none> ]

QEMU installation in the zone was successful. You’ll also notice that the core system now has a new virtual device rtls0:1, which will filter all traffic in and out of the isolated container:

[email protected]:~# ifconfig rtls0
rtls0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 3
        inet netmask ffffff00 broadcast
        ether e2:62:0:a4:d5:24
[email protected]:~# ifconfig rtls0:1
rtls0:1: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 3
        zone NewZone
        inet netmask ffffff00 broadcast

OI combines tools from the Linux world (ls, bash, gcc) and those native to Solaris (svcadm, pfexec, newtask, beadm). The CDDL licence (similar to GPL) made possible the emergence of the Nexenta distribution, which uses the OS/Net (OpenSolaris) core, much like OI. However, Nexenta has only GNU applications, and isn’t built on mixed technology like OI.

However, as we have already seen, this mixed environment is closer to Linux than to Solaris. The use of interesting options like ZFS and zones lets you look differently at existing solutions in Linux — for instance, LVM and lxc. Who knows, maybe one day, we’ll see a Linux distribution offering ZFS as the default root filesystem!