Tag Archives: Sun Studio

Solaris in qemu

For some time I wanted to try Solaris mainly because all the buzz around it, going open source then with the buzz around ZFS, but I never got the chance to do it until today when I had to make a perl script work on solaris 9 ( this is a outdated but that's what the client had installed ).

The perl script was using the Net-SSH-Perl module and the module had some requirements that had to be installed.

The problem is that the system where this script had to run had no C compiler so I had to install solaris9 in qemu, compile the requirements and send them all in one package.

Geting Solaris 9

So I went to solaris 9 download page and downloaded the DVD version ( split over 5 zip files suffixed with a-e ) , decompressed each file, then cat them all in one big file respecting the alphabetical order of the names and I got my big .iso file.

Qemu Scripts

When I use qemu ( and I use it a lot ) I have these 3-4 scripts that I use everywhere:

1 ) the start script : start.sh . I use this script to basically boot the guest system

  2. #!/bin/bashb="c"if [ -n "$1" ] ; then
  3. b=$1
  4. fi
  6. cd $(dirname $0)./restart_dhcp.sh &
  7. qemu-system-x86_64 -m 712 -hda solaris9.img -cdrom DU_sol9.iso -boot $b
  8. -net nic,vlan=1,macaddr=7E:B2:2A:3F:75:0F -net tap,vlan=1,ifname=tap11,script=./qemu-ifup.sh

I run this like "./start.sh" or "./start.sh d" if I want to boot from cd instead of the disk. DU_sol9.iso contains some drivers i will discuss later in this post. macaddr is optional but I set it so that my dhcp server knows what ip to provide for this system.

2) restart_dhcp.sh : this script restarts my dhcp server so that the server will start answering requests coming in from the tap devices created by qemu. this way the guest systems can get their ips from my dhcp server.

  1. #!/bin/sh
  2. sleep 10
  3. /etc/init.d/dhcpd restart

Sleeps a bit before restarting the dhcp server because qemu does not create the interface right at the start and we have to make sure the interface ( tap11 ) exists before we restart the dhcp server.

3) qemu-ifup.sh and if I want two interfaces in the guest system then I will have qemu-if2up.sh. This script just sets the ips on the host side of the tunnel between the host and the guest system

  2. #!/bin/bash
  3. /sbin/ip a a broadcast dev $1 &&
  4. /sbin/ifconfig $1 up

I can't remember exactly why I wanted to use ip tools, I think ifconfig $1 would work just as well.

Installing Solaris 9

Installing solaris went pretty smooth in qemu. I just modified the start.sh script to use the solaris9.iso for -cdrom and ran "./start.sh d" and a few F2 keys hit and a reboot later the system was up and running. Everything seemed to be fine but I had no network access to the guest os and the CDE ( Common Desktop environment ) locks from time to time .

I am unable to determine the problem with CDE but so I just killed the X server and then I ran /usr/openwin/bin/xdm which gave me an X session in a minimal window manager ( Twm ) but that was enough for me to install Sun Studio and get a C compiler.

There was no network access because solaris 9 does not have the drivers required for the network cards that qemu emulates ( NE2000 rtl 8139 and a few others ). I found this page providing a community network drivers for those card. the page also contains instructions about how to add the drivers and at the official sun documentation site you can find out more about configuring network interfaces in solaris

When trying to install Sun Studio, qemu just crashed at about %30 with "qemu: fatal: Trying to execute code outside RAM or ROM". Luckily the C compiler was in the first %30 of studio's files and I managed to uses to for compiling the requirements ( modules ) for my perl script, but when I was finished, the client thought he should mention that his server was SPARC not x86 ( what I tried ) 🙂 . Why didn't I think of that, I guess most servers out there running solars are sparc....

Next I'm going to install the SPARC version of solaris 9 in qemu and I'll let you know how it goes in another post...