Friday, September 25, 2015

Solaris 9 Sparc


Qemu 2.4.0 came out on August 11th and I've been so busy that I didn't even notice. This week though, I've been sick, all week. ...and my mind just hasn't been up to its customary level of problem solving. Feeble attempts to get work done gave way to browsing the web, and eventually to sleep. During one of those periods of consciousness though, I noticed that Qemu 2.4.0 had been released. And the ChangeLog included something that piqued my interest.

In the SPARC notes:

     Fix SunOS 4.1.4 boot on sun4m with OpenBIOS

SunOS 4.1.4 is also known as Solaris 1.something-or-other. Last I checked, OpenBIOS couldn't boot anything except Solaris 7, 8 and 9, in single-user mode, and there were even some limitations to that. Older versions of Solaris were completely unsupported.

I knew that Artyom Tarasenko and friends had been poking at OpenBIOS and QEMU over the years, and bit-by-bit it could boot more and more things, but the last I'd heard, a year ago, they'd just barely gotten it to boot Solaris 9 in full single-user mode.

What's this I hear about SunOS 4.1.4? Has a bunch of progress been made since the last time I checked?

I would have to find out.

But I didn't. Not at first. Instead I slept and slept and tried to kick this cold. But later in the week, I improved somewhat, and rather than spending my conscious moments browsing the web, I nudged along some projects, including an attempt to get some version of Solaris for Sparc running.

I started with Solaris 9. I'm not sure why, really. I own copies of 1.1.1B, 2.1 and versions 7 through 11. No idea why I settled on 9. My subconscious was making most of my decisions at the time. I think it's because I'd also read that 9 sort-of-boots further and 9 was still on my mind.

At any rate, I gave 9 a try.

VM Configuration

I sort-of followed some of the directions at Artyom's Solaris/sparc under qemu how-to but with a few modifications. I had a few false starts, but it didn't take long, or much effort (thankfully) to work my way through them.

So here's what I ultimately did...

I created a 36G disk.

qemu-img create solaris9_sparc.img 36G

Why 36G in particular? Wait and see...

This is the QEMU command that I ended up using too.

qemu-system-sparc -drive file=solaris9_sparc.img,format=raw \
-cdrom solaris-9-sparc-installation.iso \
-nographic -net bridge -net nic,macaddr=aa:00:00:00:00:a0 \
-prom-env "auto-boot?=false"

Modern QEMU complains if you use a raw disk but don't tell it that you're using a raw disk, thus the -drive argument rather than just using -hda.

The -nographic option basically runs it in the terminal window rather than simulating the framebuffer, which is great because it runs much faster and the only supported framebuffer resolution is big and unwieldy.

I'm also using bridged networking. Here's a little info on that.

The weird -prom-env argument keeps it from trying to boot. There are various issues related to using the QEMU -boot option. If you tell it to boot to the CD, it does ok, but it universally attempts to boot to the wrong disk partition. It seems better to boot manually from the OpenBIOS prompt.

Also, the Solaris 9 distribution comes with a bunch of CD's, including an Installation disc, 2 Software discs, a Supplements disc, and Companion CD. I configured QEMU to boot to the installation disc here.


Running that QEMU command dropped me to an OpenBIOS prompt, where I booted to the CD, in single-user mode.

boot cdrom:d -vs

(-v means verbose, -s means single-user)

If you do this, and you look carefully, you'll notice something like this scroll up the screen:

        Corrupt label; wrong magic number

As neozeed has pointed out before, Sun-provided disks were apparently pre-formatted, but if you used a non-Sun disk, you had to format it yourself, or the installer won't recognize it. My QEMU disk image was certainly a non-Sun-provided disk.

The single-user boot dropped me at a root prompt, and I ran the "format" command.


Which disk? Disk 0. What disk type? Other.

And then it prompted me for a dozen odd parameters. The important ones were:

  • data cylinders: 24622
  • heads: 27
  • data sectors/trac: 107
  • disk type name: qemu

I accepted defaults for the others.

BTW, the reason I used a 36G disk, in particular, is because those parameters are known to work with a 36G disk. Sun disks apparently have odd geometries, and the old geometry calculator web page is long gone.

After that, I labelled the disk, quit and rebooted.

format> label
Ready to label disk, continue? y

WARNING: /iommu@0,10000000/sbus@0,10001000/espdma@5,8400000/esp@5,8800000/sd@0,0 (sd0):
        Corrupt label; wrong magic number
format> quit
# reboot

Ok. Disk formatted. Time to get down to business for real.


At the OpenBIOS prompt, I booted to the CD normally:

boot cdrom:d -v

This time, no "Corrupt label" errors.

The installer ran, I chose to install in English. Then it wanted a location to copy the installation software to. I allowed it to repartition the disk, accepted the default 512MB swap slice size, and allowed it to start the slice at beginning of the disk. The installer then copied itself to the disk and attempted to reboot.

But, since I'd disabled auto-boot, I had to tell it where to boot:

boot disk:b -v

At this point, the installer would sometimes just run, or other times crash. If it crashed, I could restart it by running disk0_install, and then it would run fine. I never figured out exactly why it was crashing sometimes. Later I read that maybe giving QEMU more memory (using -m 256) might have fixed the problem. I never tried that though. Your mileage may vary.

When the installer came up, it was intuitive. I supplied various networking parameters, time zone parameters, and a root password.

Then, after the weird (but familiar) Web Start message...

Solaris Web Start will assist you in installing software for Solaris.

(Whatever Web Start means)

...the installer asked a few more intuitive questions and asked for Software Disc 1.

If I'd been installing on real hardware, the CD tray would have been ejected and it would have been clear that I needed to change CD's. Everything being virtual, I didn't realize that I needed to do anything, and forgot that there are like 5 CD's with software on them, so it took me a while to realize that I needed to switch into the QEMU monitor and change CD's.

(qemu) change scsi0-cd2 solaris-9-sparc-software-disc1.iso

But after I figured that out, and hit return, and went through a few more prompts, the installer continued with a crude (but familiar) progress bar.


Then it wanted Software Disc 2.

(qemu) change scsi0-cd2 solaris-9-sparc-software-disc2.iso

And there was more of the same, before it finally tried to reboot again.

Once again, I had to specify the disk and partition to boot to:

boot disk:a

Though this time to a different partition, and without the verbose flag.

The installer wasn't done yet though, it wanted the Supplements CD.

(qemu) change scsi0-cd2 solaris-9-sparc-software-supplement.iso

And it installed a some stuff that I recognized like Java3D and OpenGL, but then also stuff like PC Launcher, PCfileviewer, RSC, SunForum, SunHSI PCI, and SunVTS. What are these things?

After a few more prompts, it tried to reboot again, and again I told it to boot to disk:a...

boot disk:a

But this time, everything started up for real.


I could log in as root, and networking worked on the first try!

Post-Install Tweaks

So, I now had a working Solaris 9 Sparc installation. I hadn't seen such a thing in more than 10 years.

But the system as it was, wasn't all that useful yet. I wanted languages (well, other than java) and compilers and web servers. Companion CD to the rescue...

I swapped the CD again:

(qemu) change scsi0-cd2 solaris-9-sparc-software-companion.iso

And, after a bit of trial and error, figuring out which device was the CD, mounted it and ran the installer.

mount -F hsfs /dev/dsk/c0t2d0s0 /cdrom
cd /cdrom

But it failed miserably because it's requires a graphical environment to run. Fortunately, I had one of those, just not on that machine.

Locally, I gave the VM permission to use my display:

xhost +

And then ran the installer, piping it's display here:

DISPLAY= ./installer



It took a while to start up, and there were a bunch of intuitive prompts, and it took a really long time to install, but eventually, it did, and I had most of the utilities I'm so accustomed to having.

I did need to tweak a few things though.

First, sudo had the wrong permissions.

chmod u+s /opt/sfw/bin/sudo

Second, even though I had a 36G disk, the root division is only 2G, and it was getting full, so I moved /opt/sfw to /export/home (which had a ton of space), and symlinked it back to /opt.

cd /opt
mv sfw /export/home
ln -s /export/home/sfw sfw

I also wanted to add some paths to everyone's PATH, but vi didn't work very well. The TERM environment variable is set to "sun" by default, but even setting it to xterm, vt100 or vt220 didn't help. I'm not sure why exactly, but I was eventually able to get it to work by running a dtterm (which supports the "sun" terminal type) and editing /etc/profile from there:

DISPLAY= /usr/dt/bin/dtterm

And then in that terminal:

vi /etc/profile

I added the following, near the top:


I also created a user for myself:

useradd -m -d /export/home/dmuse dmuse
passwd dmuse

And I gave myself some sudo privileges, though the sudoers file was in /usr/sfw/etc/sudoers rather than /etc/sudoers.

ssh appeared to be running, but I enabled X11 forwarding in /etc/ssh/sshd_config

X11Forwarding yes

...and restarted it.

/etc/init.d/sshd stop
/etc/init.d/sshd start

I was then able to ssh into the VM, and run X apps without having to fiddle with the DISPLAY variable.

All right!

The Web

Solaris 9 comes with some version of Apache. I copied the example config file.

cd /etc/apache
cp httpd.conf-example httpd.conf

And tweaked a few things (in httpd.conf):

AddHandler cgi-script .cgi
Options Indexes FollowSymLinks MultiViews ExecCGI
DirectoryIndex index.html index.cgi

And restarted apache.

/etc/init.d/apache restart

And wrote a quick and dirty CGI (/var/apache/htdocs/env.cgi)

echo "Content-type: text/plain"

And it worked!


Solaris 9 also comes with Netscape Communicator 4.78 which tries to go to and crashes unless you manage to stop it in time. It appeared to support png's but that's about the most modern thing it could do.


Ok, so all that had been fun, but could I get any of my software to run?

Turns out yes. I'd gotten it to work on Solaris 9 x86 long ago, and wrung out all the endian, alignment, and 32/64-bit issues over the years. The companion CD provided all the dev tools that I needed, including gcc 2.95.3. Pretty old, but good enough.

I was able to build and install Rudiments and SQL Relay and access Oracle 12 via an SQL Relay server on another machine.


The companion CD came with MySQL too, Relay found it, and built a connection plugin for it, but it was such an old version that it was incompatible with modern MariaDB:

mysql_real_connect failed: Client does not support authentication protocol requested by server; consider upgrading MariaDB client

Yeah, pretty old:

/opt/sfw/mysql/bin/mysql  Ver 11.15 Distrib 3.23.43, for sun-solaris2.9 (sparc)

I have various versions of Oracle for Sparc Solaris. One of them probably works on Solaris 9.

Fun for another day.


Having used Solaris 9 on x86 quite a bit, it was very familiar on Sparc. Backspace is delete and /home is /export/home, but I'm used to that. The most difficult thing to deal with was the inability to use vi on the console, and that wasn't too big of an issue. Other than that, it does slam the host cpu, so I can't just leave it running, but I think it does that on real hardware too, so it's not unexpected.

I've been collecting versions of Sparc Solaris for a few years now, in the hopes that someday QEMU/OpenBIOS might support it. Yeah, I know you can use the Sun ROMs but the dubious legality of those isn't my style. It's really great to find that it all works now. I'll have to try out some of the other versions soon too.

No comments:

Post a Comment