VirtualBox on Solaris 10

[Image]
Windows XP running under VirtualBox

About VirtualBox

VirtualBox is an open source hardware virtualization software for Linux, Solaris and Windows. Using VirtualBox, you can run Linux and Windows programs inside Solaris operating system, or vice versa. You can even run another version of Solaris inside Solaris 10!

Using VirtualBox 1.6.2 on Solaris

Stability and Keyboard Issues

The Qt front-end launched with the VirtualBox command offers an easy way to create virtual machines. However, the Qt front-end seems to be a little unstable at the moment and you will do better if you run your virtual machine in the SDL front-end once the operating system is installed. I get occasional lockups when using Qt menus, key presses involving the host key are not registered, and some keys only work in the SDL front-end. Be especially careful when entering password in the Qt front-end as some keys might not be registered.

Using the SDL front-end is simple. For example, a virtual machine named LINUX could be launched as

VBoxSDL -vw LINUX &

Press hostkey + h to power off the virtual machine or hostkey + s to save the current execution state and exit. By default, the right shift key acts as the host key.

Using CDs/DVDs

Avoid using the host CD/DVD drive in VirtualBox: changing disks is difficult as Solaris does not allow you to eject a disk as long as a program (VirtualBox) is using it. Furthermore, VirtualBox does not allow you to reconfigure the disk drive when the virtual machine is powered on. Hence, you will find it easier to avoid using the host CD/DVD drive altogether. Instead, create images of your CDs/DVDs and use those. Disk images, unlike real disks, can be mounted and unmounted while the virtual machine is running, but only in the Qt front-end.

To create images, find the name of the CD/DVD device first. To do that, insert a disk in drive and use the df command to print disk information. You should find the device name from the output.

Once you know the device name, eject the disk and disable volume manager as root

eject
/etc/init.d/volmgt stop

Insert CD/DVD to the drive and use dd to create an image of your CD or DVD. For example, if your CD/DVD device is named c2t0d0, then create ISO image file as

dd if=/dev/rdsk/c2t0d0s2 of=image.iso bs=2048

You can create several images in a row by changing disks and re-running dd. However, note that the eject command normally used to eject a disk does not work as the volume manager is not running. To change disks, you will have to use the eject button of the disk drive (which would not work if the volume manager were running).

Once you have created enough images, enable volume manager as root to resume normal operations

/etc/init.d/volmgt start

Note that dd is unable to copy certain copy protected disks.

Sharing Data Between Operating Systems

VirtualBox provides shared folders to simplify data transfer between the host and the guest operating systems. Shared folders are easy to set up and can be used for occasional file transfers. However, shared folders are not stable enough for everyday work, and I recommend that you install Samba file server to the host operating system and configure the guest operating system to share data through Samba.

Samba is installed by default in Solaris 10 and you only need to create /etc/sfw/smb.conf file as root

cd /etc/sfw/
cp smb.conf-example smb.conf

Edit the smb.conf file to match your system. For example, a minimal configuration file might contain

[global]
   workgroup = TUXNET
   server string = SMB
   security = user
   hosts allow = 192.168.0. 127.
   hosts deny = 0.0.0.0/0
   load printers = no
   log file = /var/samba/log/log.%m
   log level = 1
   max log size = 50
   passdb backend = tdbsam
   passdb expand explicit = no
   socket options = TCP_NODELAY

[homes]
   comment = Home Directories
   browseable = no
   writable = yes

Once the configuration file is OK, enable Samba as root

svcadm enable samba

Add Samba user accounts as root (replace USER with your user name)

/usr/sfw/bin/smbpasswd -a USER

Mapping Samba Shares from Windows

In order to use the Samba share from Windows, open My Computer and select Map Network Drive from the tools menu. Pick a letter and type the name of the network share such as \\10.0.2.2\homes where 10.0.2.2 is the IP address of host in the simulated VirtualBox network (10.0.2.2 by default) and homes is the name of the share from the smb.conf file.

Beware: guest operating systems do not necessarily write data immediately to the network. It is therefore advisable to disconnect any network shares before taking snapshots or closing VirtualBox. In Windows, you can do this simply by logging off before you close or save the state of the virtual machine.

Mapping Samba Shares from Linux

First log in as root and create a mount point for the network share

mkdir /mnt/homes

You can then mount the network share homes from the host as (replace USER with your user name)

mount -t cifs -o rw,user=USER //10.0.2.2/homes /mnt/homes

To prevent possible loss of data, unmount the share before you save the state of the virtual machine or close VirtualBox as

umount /mnt/homes

Getting VirtualBox 1.6.2 for Solaris

A ready-made VirtualBox installation package is available for OpenSolaris and Solaris 10 at VirtualBox.org. Download and install the package from VirtualBox.org to get VirtualBox running quickly.

However, if you want to compile VirtualBox by yourself, then follow the instructions below. The instructions help you compile and install 32-bit version of VirtualBox 1.6.2 for Sun Solaris 10 u4.

Prerequisites

You will need the following tools to compile VirtualBox

Make sure that the tools are present and found in PATH. If necessary, add /usr/sfw/bin:/opt/sfw/bin to PATH and /usr/sfw/lib:/opt/sfw/lib to LD_LIBRARY_PATH so that the Freeware tools work.

Tip: you can use the check buttons at the end of each step to mark your progress. Reset all ticks

Prerequisites OK

GNU C/C++

VirtualBox does not work correctly when compiled with gcc 3.4.3 from Sun Freeware. Instead, gcc 3.4.6 must be installed temporarily. (Note that gcc 3.4.3 shared libraries are still required at run-time.)

Get gcc and configure

wget ftp://ftp.gnu.org/gnu/gcc/gcc-3.4.6/gcc-3.4.6.tar.bz2
bunzip2 -c gcc-3.4.6.tar.bz2 | gtar xf -
cd gcc-3.4.6/
mkdir obj
cd obj
../configure --prefix=/tmp/build  \
    --with-as=`which gas` --enable-languages=c,c++

Compile (~15 min)

time gmake

Install

gmake install
PATH=/tmp/build/bin:$PATH
cd ../..

Note that the compiler is installed to directory /tmp/build, which is removed automatically at boot.

Done

SDL

VirtualBox requires SDL version 1.2.7 or higher

wget http://www.libsdl.org/release/SDL-1.2.13.tar.gz
gunzip -c SDL-1.2.13.tar.gz | tar xf -
cd SDL-1.2.13/
./configure --disable-shared --prefix=/tmp/build
gmake install
PKG_CONFIG_PATH=/tmp/build/lib/pkgconfig
export PKG_CONFIG_PATH
cd ..

Done

Qt

Required by VirtualBox

wget ftp://ftp.trolltech.com/qt/source/qt-x11-free-3.3.8.tar.bz2
bunzip2 -c qt-x11-free-3.3.8.tar.bz2 | tar xf -
cd qt-x11-free-3.3.8
./configure -v -platform solaris-g++ --prefix=/tmp/build -static \
     -thread -stl -largefile -tablet -sm -disable-sql \
    -qt-imgfmt-jpeg -qt-imgfmt-png -qt-imgfmt-mng -system-libjpeg \
    -system-libpng -qt-libmng -system-zlib \
    -L /tmp/build/lib -L /usr/X11R6/lib -L /usr/openwin/sfw/lib \
    -I /tmp/build/include -I /usr/sfw/include -I /usr/openwin/share/include \
    -I /usr/X11/include

Accept license terms by typing yes.

Compile and install separately (~45 min)

time gmake
gmake install
cd ..

Done

VirtualBox

Compile

Download VirtualBox 1.6.2 source code from virtualbox.org and unpack the distribution

umask 022
bunzip2 -c VirtualBox-1.6.2-OSE.tar.bz2 | gtar xf -
cd VirtualBox-1.6.2

Apply my patch for Solaris 10

wget http://softagalleria.net/download/virtualbox/virtualbox-1.6.2.diff
gpatch -p 1 -i virtualbox-1.6.2.diff

Configure

bash ./configure --build-libxml2 --build-libxslt
source env.sh
SDK_LIBSDL_LIBS="SDL Xext Xrender X11"
PATH_SDK_LIBSDL=/tmp/build/lib
VBOX_XCURSOR_INCS=/tmp/build/include
export SDK_LIBSDL_LIBS PATH_SDK_LIBSDL VBOX_XCURSOR_INCS

Configure for Qt and dependent libraries

QTDIR=/tmp/build
LIB_QT="qt-mt Xrandr Xrender Xinerama Xft fontconfig freetype \
    png jpeg z ICE SM Xi X11"
export QTDIR LIB_QT

Compile (~30 min)

time kmk all

Check the output once again and do not continue if you see any errors. VirtualBox installs a kernel module, and your system may crash or fail to boot if VirtualBox does not compile cleanly.

Done

Install

Download guest additions

wget -O out/solaris.x86/release/bin/VBoxGuestAdditions.iso \
    http://virtualbox.org/download/1.6.2/VBoxGuestAdditions_1.6.2.iso

Login as root, cd to the package directory and install the VirtualBox kernel module

umask 022
cp out/solaris.x86/release/bin/vboxdrv /platform/i86pc/kernel/drv/
cp src/VBox/HostDrivers/Support/solaris/vboxdrv.conf /platform/i86pc/kernel/drv
add_drv vboxdrv
chmod a+rw /devices/pseudo/vboxdrv*
ln -s /devices/pseudo/vboxdrv\@0:vboxdrv /dev/vboxdrv

Install the run-time files as root

ver=1.6.2
cd out/solaris.x86/release/bin
mkdir -p /opt/virtualbox-$ver
cp -r * /opt/virtualbox-$ver/
rm -fr /opt/virtualbox-$ver/tst* /opt/virtualbox-$ver/testcase

You should now be able to run VirtualBox as

/opt/virtualbox-$ver/VirtualBox

If VirtualBox works, you can remove the /tmp/build directory and sources as those are no longer needed.

Complete

Uninstalling VirtualBox

Use the instructions below to remove VirtualBox from your computer. If you are removing VirtualBox for the purpose of upgrading to a later version, be sure to shut down all virtual machines before uninstalling VirtualBox. You cannot pick up the guest operating system from a saved state once you install an newer version of VirtualBox. Instead, you will need to discard the saved state and this may have adverse effects to the guest operating system.

If you do want to remove VirtualBox, then first remove the kernel module as root

rem_drv vboxdrv
rm /platform/i86pc/kernel/drv/vboxdrv* 
rm /dev/vboxdrv

Remove program files as root

ver=1.6
rm -fr /opt/virtualbox-$ver

Version History

Jun 26, 2008: Updated the instructions and the patch file for VirtualBox 1.6.2. The installation instructions for VirtualBox 1.6.0 are also available.

May 13, 2008: Updated these instructions and the patch file for VirtualBox 1.6.0.

Apr 12, 2008: Updated the patch file. The latest version of VirtualBox now supports audio.

Mar 31, 2008: Checked that the patch file still compiles. Minor clarifications to this document.

Mar 21, 2008: Updated the patch file.

Mar 2, 2008: Added some tips on using VirtualBox on Solaris.

Feb 29, 2008: Updated the patch file. The patch disables some Solaris specific additions to cope with missing source files.

Feb 27, 2008: Innotek provides installation package for 32-bit OpenSolaris. The very same package might work for Solaris 10 too.

Feb 24, 2008: Compiled succesfully on Solaris u4.

Feb 20, 2008: Compiled succesfully on Solaris u1.