VirtualBox is an open source hardware virtualization software for Linux, Solaris and Windows. Using VirtualBox, you can run Linux and Windows under Solaris, or vice versa. You can even run another version of Solaris under Solaris 10!
VirtualBox is still an evolving product, and some features may not work on Solaris 10. Here are a few tips on using VirtualBox effectively on Solaris 10.
VirtualBox allows you to map host CD/DVD drive to the guest operating system. Thus, you may insert a CD to the drive and then use it immediately under the guest operating system.
However, this feature does not really work. The problem is that you cannot change disks freely if you use the host drive. Solaris does not allow you to eject a disk as long as a program (VirtualBox) is using it and VirtualBox does not allow you to reconfigure the disk drive when the virtual machine is powered on. As such, it is almost impossible to install a program that comes with multiple CDs.
Instead of using the host CD/DVD drive, create images of the disks you want to use and map those to VirtualBox. Disk images, unlike real disks, can be mounted and unmounted while the virtual machine is running.
To create a disk image, find the name of the CD/DVD device
first. To do that, insert a disk in to the 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 back 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 that is 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.
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.
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 comes pre-installed 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
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.
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
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 2.1.2 for Sun Solaris 10.
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
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.
VirtualBox requires SDL version 1.2.7 or higher. Compile and install SDL as
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-static --prefix=/tmp/build --libdir=/opt/virtualbox-2.1.2 umask 022 gmake install mv /opt/virtualbox-2.1.2/pkgconfig /tmp/build/lib PKG_CONFIG_PATH=/tmp/build/lib/pkgconfig export PKG_CONFIG_PATH LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/virtualbox-2.1.2 export LD_LIBRARY_PATH cd ..
Get Qt and configure it as
wget ftp://ftp.trolltech.no/qt/source/qt-x11-opensource-src-4.4.3.tar.gz
gunzip -c qt-x11-opensource-src-4.4.3.tar.gz | gtar xf -
cd qt-x11-opensource-src-4.4.3
./configure -v -platform solaris-g++ --prefix=/tmp/build -shared \
-libdir /opt/virtualbox-2.1.2 -L /opt/virtualbox-2.1.2 \
-stl -largefile -tablet -sm -no-fontconfig \
-nomake examples -nomake demos -nomake docs \
-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 Qt separately (~1 hour)
time gmake umask 022 gmake install mv /opt/virtualbox-2.1.2/pkgconfig/* /tmp/build/lib/pkgconfig/ cd ..
Download VirtualBox 2.1.2 source code from virtualbox.org and unpack the distribution
umask 022 bunzip2 -c VirtualBox-2.1.2-OSE.tar.bz2 | gtar xf - cd VirtualBox-2.1.2_OSE
Apply my patch for Solaris 10
wget http://softagalleria.net/download/virtualbox/virtualbox-2.1.2.diff gpatch -p 1 -i virtualbox-2.1.2.diff
Configure
bash ./configure --build-libxml2 --build-libxslt --disable-hardening 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 VirtualBox (~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 the kernel module does not work.
Download guest additions
wget -O out/solaris.x86/release/bin/VBoxGuestAdditions.iso \ http://download.virtualbox.org/virtualbox/2.1.2/VBoxGuestAdditions_2.1.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 0666 /devices/pseudo/vboxdrv* ln -s /devices/pseudo/vboxdrv\@0:vboxdrv /dev/vboxdrv
Install the run-time files as root
ver=2.1.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 chown -R root:root /opt/virtualbox-$ver
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.
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=2.1.2 rm -fr /opt/virtualbox-$ver
Feb 15, 2009: Updated the instructions for VirtualBox 2.1.2. The instructions for VirtualBox 1.6.2 are also available.
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.