VirtualBox
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
:
root@openindiana:/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.07.19.12.47.73009 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> [...snip...] The following files are being installed with setuid and/or setgid permissions: /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> [...snip...] Installation of <SUNWvbox> was successful.
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.
QEMU
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 gettext@0.5.11
package, as well as developer packages that contain definitions of mathematical functions. I performed the following operations:
root@openindiana:/home/anton# pkg info | egrep "math|gettext" Name: developer/gnome/gettext FMRI: pkg://openindiana.org/developer/gnome/gettext@0.5.11,5.11-0.151:20110523T143743Z Name: system/library/math FMRI: pkg://openindiana.org/system/library/math@0.5.11,5.11-0.151:20110523T150249Z Name: system/library/math/header-math FMRI: pkg://openindiana.org/system/library/math/header-math@0.5.11,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.
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);
…to:
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
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):
root@openindiana:/home/anton# format Searching for disks... Failed to inquiry this logical diskdone AVAILABLE DISK SELECTIONS: 0. c1d0 < cyl 2868 alt 2 hd 255 sec 63> /pci@0,0/pci-ide@1,1/ide@0/cmdk@0,0 1. c2d1 <QEMU HAR-QM0000-0001-2.00GB> /pci@0,0/pci-ide@1,1/ide@1/cmdk@1,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:
root@openindiana:/home/anton# zpool create pool c2d1
You can list the available pools and see that both
pools (i.e., disks) are online:
oot@openindiana:/home/anton# zpool list NAME SIZE ALLOC FREE CAP DEDUP HEALTH ALTROOT 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:
root@openindiana:/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 = 192.168.254.200 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:
root@openindiana:/home/anton# zoneadm -z NewZone install A ZFS file system has been created for this zone. Publisher: Using openindiana.org (http://pkg.openindiana.org/dev-il/ ). Image: Preparing at /pool/NewZone/root. Refreshing catalog 1/1 openindiana.org 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 [...snip...] 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!
root@openindiana:/home/anton# zoneadm -z NewZone boot zone 'NewZone': WARNING: rtls0:1: no matching subnet found in netmasks(4): 192.168.254.200; using default of 255.255.255.0.
Now, perform a minimal configuration of this zone.
Connect to a virtual console with zlogin -C NewZone:
root@openindiana:/home/anton# zlogin -C NewZone [Connected to zone 'NewZone' console] 61/99 85/99 99/99 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 Password: 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:
root@NewZone:~# 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/libc.so.1 (/usr/lib/libc/libc_hwcap1.so.1): 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:
root@NewZone:/# 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 Password: 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 root@NewZone:~# 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:
root@openindiana:~/pkg# cat pkginfo BASEDIR=/opt/qemu-0.14 TZ=PST PATH=/sbin:/usr/sbin:/usr/bin:/usr/sadm/install/bin PKG=qemu ARCH=x86 NAME=qemu VERSION=0.14 CATEGORY=application DESC=QEMU virtualization VENDOR=QEMU.ORG EMAIL=qemu@qemu.org PKGSAV=/var/sadm/pkg/qemu/save
Begin building the package itself:
root@openindiana:~/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. /var/spool/pkg/qemu/pkgmap /var/spool/pkg/qemu/pkginfo /var/spool/pkg/qemu/root/opt/qemu-0.14/bin/qemu [...snip...] /var/spool/pkg/qemu/root/opt/qemu-0.14/share/qemu/vgabios-stdvga.bin /var/spool/pkg/qemu/root/opt/qemu-0.14/share/qemu/vgabios-vmware.bin /var/spool/pkg/qemu/root/opt/qemu-0.14/share/qemu/vgabios.bin ## 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:
root@openindiana:~/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 root@openindiana:~/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:
root@NewZone:/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 QEMU.ORG ## 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. /opt/qemu-0.14/bin/qemu ... /opt/qemu-0.14/share/qemu/vgabios.bin [ 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:
root@openindiana:~# ifconfig rtls0 rtls0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 3 inet 10.1.0.136 netmask ffffff00 broadcast 10.1.0.255 ether e2:62:0:a4:d5:24 root@openindiana:~# ifconfig rtls0:1 rtls0:1: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 3 zone NewZone inet 192.168.254.200 netmask ffffff00 broadcast 192.168.254.255
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!
[…] In a subsequent article in this series, we will discuss the virtualisation, disk and zone management aspects of OpenIndiana. […]
Just what I was looking for, a simple zone explanation…
Thank you
r3N0oV4