Friday Feb 10, 2012

Solaris and VirtualBox: No Heads Is Better Than One

VirtualBox is a great method of running Solaris in a virtualized environment. However, it shares resources with the host system, and a laptop with 4GB of RAM can't afford to give up too much memory. This is why I usually will run VirtualBox from a server with more RAM and diskspace (and a faster CPU is always nice).

The VirtualBox GUI is easy to use, but trying to run it remotely from the server onto my laptop lacks quite a bit in performance. I'm not a graphics expert, so I can't say why. But I do know that one solution for overcoming remote GUI performance is to use VNC. That allows a whole virtual desktop session to be run on the server. But it also requires running a VNC client locally, and it is a lot of overhead for just being able to run the single VirtualBox application.

Using VBoxManage to Create a VM

I found the best solution for my work is to use the VirtualBox command line interfaces. These will let you work in a terminal window on the server, and just display the virtual console on your local system. The GUI is completely bypassed. The two commands are VBoxManage and VBoxHeadless. The VirtualBox user guide has all the details, but here is how I use them to automate creation of a Solaris virtual machine.

The basic steps for creating a virtual machine (VM) using VBoxManage are as follows:

  • create a virtual hard drive
  • create a VM
  • add memory, NIC and a disk controller
  • link the virtual hard drive with the VM
  • mount an ISO install image

Here is a simple script with the options I used for Solaris 11. These values could be used for Solaris 10 as well, though RAM requirements may differ slightly. It assumes that the ISO image is in the current directory, and it creates the VDI file in the current directory. This example uses the Solaris 11 Live Media (desktop) image, but the other Solaris 11 installation ISOs can also be used, as well as Solaris 10 images.

VMNAME=solaris11
VBoxManage createhd --filename $VMNAME.vdi --size 64000
VBoxManage createvm -name "$VMNAME" -register
VBoxManage storagectl  "$VMNAME" --name "IDE Controller" --add ide
VBoxManage modifyvm  "$VMNAME" --memory "2048" --acpi on --boot1 dvd \
--nic1 nat --pae on --hda "$VMNAME.vdi"
VBoxManage storageattach "$VMNAME" --storagectl "IDE Controller" --port 0 \
--device 1 --type dvddrive --medium sol-11-1111-live-x86.iso

Using the VM with VBoxHeadless

Now you have a VM that can be run remotely using VBoxHeadless. In the server terminal window, type:

$ VBoxHeadless -s solaris11 
Oracle VM VirtualBox Headless Interface 4.1.4
(C) 2008-2011 Oracle Corporation
All rights reserved.

VRDE server is listening on port 3389.

Then on your desktop, use a remote desktop application connect to the server port that VBoxHeadless displays (3389 in the example above, which is the default). You will then get the VM's console on your desktop. At that point you can follow the standard Solaris installation instructions (found here for Solaris 11).

The remote desktop application will depend on the operating system that you are using on your desktop. If you are running Solaris, you can use the rdesktop command. On Solaris 11 this is found in the aptly named rdesktop package (which is simple to install if not already on your desktop).

MyDesktop$ rdesktop myserver:3389

Newer versions of Microsoft Windows has the "Remote Desktop Connection" application which will allow you to specify the server host name and port number.

Adding Guest Additions

After installation of Solaris is complete, you will want to install the VirtualBox Guest Additions. This is also easy to do with the help of VBoxManage. The steps to follow are:

  • shut down the system after installation
  • detach the installation ISO file
  • attach the GuestAdditions ISO file
  • restart the VM
  • install the Guest Additions from the virtual CDROM

Shutting down the system is a bit tricky. If you use the "reboot" option after installation, it will try to boot off of the install media again. You can either halt it through the grub menu, or select "quit" instead of "reboot" and then perform a shutdown through the pulldown system menu or commandline (depending on which type of installation is performed).

Detaching the install ISO and attaching the Guest Additions ISO can be done as follows:

# VBoxManage storageattach "$VMNAME" --storagectl "IDE Controller" --port 0 \
--device 1 --medium emptydrive
# VBoxManage storageattach "$VMNAME" --storagectl "IDE Controller" --port 0 \
--device 1 --type dvddrive --medium /opt/VirtualBox/additions/VBoxGuestAdditions.iso

Then reboot using VBoxHeadless again, and you will find the GuestAdditions ISO mounted in your VM. You then just use the SVR4 pkgadd utility inside your VM to install the Guest Additions package:

# pkgadd -d /media/*/*.pkg all

Then just log off (no need to shut down) and log back on to reap the benefits of the Guest Additions.

About

Insights on Solaris from the Release Engineering view. We aren't upstream in development, or downstream in QA. We're in the middle of each Solaris build.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today