Running Solaris in VMs

Occasionally I need a Solaris machine to do some testing. Over the past two weeks, I’ve been setting up images so that I have machines ready to go. Here are some useful resources.

Using Qemu

To make life easier, I have a script that will run a Qemu virtual machine. Please see also my general page on Qemu. The first time it will run it will attempt to mount the installation ISO and boot the VM from it. The second time, it will run the VM as normal and attempt to boot from the filesystem. You can find the tool on Github along with some wrapper scripts for other virtual machine types. The script has tweaks in it for each OS – for example, Solaris 2.6 will not boot on a VM with 1GB of RAM and we workaround that. Here are some examples of use:

# Run Solaris 10
sh use-qemu-vm.sh Solaris i386 10
# Boot Solaris 10 mounting the install ISO
sh use-qemu-vm.sh -i Solaris i386 10
# Boot Solaris 7 with a terminal console
sh use-qemu-vm.sh -n Solaris SPARC 7

Solaris 10

  • Solaris 10/x86 will boot on both Qemu and VirtualBox.
  • I have not been able to get Solaris 10/sparc to work on Qemu using the installation media available from Oracle and apparently this is related to the chipset that Qemu emulates. Older installation discs of 10 may work.

Solaris 11

  • I have not had much luck with using the Solaris 11 installation media. I cannot get either 11/x86 or 11/sparc to boot on Qemu, and I cannot even get the 11/x86 installation to boot on VirtualBox
  • There are pre-made VMs available from Oracle.

Solaris 2.6, 7, 8 and 9

Four vintages of Solaris

You can use the Qemu scripts above to install and work with Solaris VMs on Qemu. These scripts simply call qemu-system-sparc with some known parameters. For the installer to work, the disk image will need a valid Sun disklabel. To save you the pain, I’ve done the work for you – I’ve made an sparse 8GB disk image (significantly smaller for download). I’ve tested this with a Solaris 7 installation but it should work for the other versions.

To use it, download it, unzip it and put it in the directory you run the VM. It will grow up to 8GB. If you are using my scripts, this will be in ~/VM/Qemu/Solaris/sparc. Here’s an example:

chris@MacMini-4856% pwd
/Users/chris/VM/Qemu/Solaris/sparc/7
chris@MacMini-4856% ls
Solaris7-sparc.iso 
chris@MacMini-4856% cp ../sol-dl.img solaris-disk-sparc.img
chris@MacMini-4856% sh ~/src/emulators/use-qemu-vm.sh -i Solaris sparc 7
Using existing hard disc solaris-disk-sparc.img
Installation Solaris7-sparc.iso file present
Starting emulator
..... 

If you don’t want to use this file and prefer the pain of doing it yourself, I’ve written up the instructions below. The good news is that once you’ve done it you can copy the disk image and use it as a base file system for the other Solaris versions.

Once you are installed, you should patch the system to the recommended patch level. Unfortunately I have not been able to find the recommended patch bundles. The good news is that at least two individuals are working on ready-made binary packages for Solaris. Tgcware has binary packages for all the systems below and OpenCSW is actively maintaining a package system for Solaris 9 and up. Both of these include compilers, so you can get started easily from there. I would suggest you archive the packages in case they disappear.

gekk.info has a page on Solaris 2.6 and the author has put together an ISO containing various software packages and the 2.6 Recommended cluster.

Solaris on SparcSolaris 2.6Solaris 7Solaris 8Solaris 9
Installation Mediaarchive.orgarchive.orgarchive.org
Get Software (1 of 2)
archive.org
The MDF file can be renamed
to ISO and be used to install
Useful Binariestgcware

gekk.info – useful binaries and 2.6
Recommended patches
tgcwaretgcwareOpenCSW
tgcware
QuirksKeep RAM to default
(won’t boot with 1G)
Keep RAM to default
(won’t boot with 1G)

The Disklabel Dance

The Solaris installer is very prickly about disk labels. You will need to adjust the disk image file so that it has a valid Sun Disklabel before the installer can proceed – it needs to be formatted. This took me hours to figure out because I had to remind myself about disk geometrics (cylinders, tracks, sectors). Hopefully one of you out there has a better solution. If you see this message you are likely to have the problem:

WARNING: /iommu@f,e0000000/sbus@f,e0001000/espdma@f,400000/esp@f,800000/sd@1,0 (sd1):
 corrupt label - wrong magic number

I’m assuming you are using an 8G disc image. If you are not, you’ll need to recalculate the values. If this puts you off, I have a pre-made blank image available – see above. When the installer exits to a shell because it can’t cope, run format and relive the exciting experience of a sysadmin from the 90s. Choose 0 for the disc, then 18 – Other. Use these values which are sort of right for an 8G disc image.

Enter number of data cylinders: 17700
Enter number of alternate cylinders[2]:
Enter number of physical cylinders[17702]:
Enter number of heads: 15
Enter physical number of heads[default]:
Enter number of data sectors/track: 63
Enter number of physical sectors/track[default]:
Enter rpm of drive[3600]:
Enter format time[default]:
Enter cylinder skew[default]:
Enter track skew[default]:
Enter tracks per zone[default]:
Enter alternate tracks[default]:
Enter alternate sectors[default]:
Enter cache control[default]:
Enter prefetch threshold[default]:
Enter minimum prefetch[default]:
Enter maximum prefetch[default]:
Enter disk type name (remember quotes): Q

Then use the label command twice. The first time you will get a corruption grumble. The second time it should be clean.

Then you can use suninstall to install Solaris.

When asked about rebooting, I recommend that you choose Manual Reboot and when the installer has finished, install boot blocks manually yourself. I had trouble getting Solaris to boot from the disc otherwise.

cd /usr/platform/sun4m/lib/fs/ufs
install boot* /dev/rdsk/c0t0d0s0

You can now use poweroff and then boot the VM normally.