Sunday, March 23, 2014

Solaris 8 x86

Background

Years and years ago, Sun (when they were still Sun) made Solaris 8 freely available for download and development use. I had always wanted my software to run on Solaris, but could never afford Sun hardware, so I was excited to discover that Solaris 8 was available for both Sparc and x86 platforms. Back then, I had a PC dedicated to it, but when virtualization became practical, I migrated it to VMware. Years passed. I installed 9, 10 and 11, and during some migration, neglected 8 entirely.

About a month ago though, out of the blue, I began to miss it and decided to reinstall it in VMware 8.0.6. Much to my surprise, the installer crashed and rebooted over and over, no matter how much I tweaked VMware. What the heck? I was confident that it worked in an older version, I ran it for years. QEMU wasn't any more helpful. The installer failed there too. Bochs got a little further, but eventually crashed and rebooted too.

It was a terrible state of affairs. All available emulators appeared to be incompatible. I wanted to cry.

Instead, I did a whole bunch of digging and debugging, and at infinite length, discovered the following:

  • The install kernel and installer software are finicky enough with ATAPI and LBA that the installer can't be run from the DVD image under any modern emulator.
  • The distro came with several discs including an installer, disk1 and disk2. Disc1 is apparently also bootable and contains a more capable kernel and installer, but the installer still can't be run from the DVD image.
  • It can be run from a disk image though.

I'll spare you the details, but it was nothing short of a miracle that I discovered some of that. For example, the installer eventually prints an error on the screen that only one document on the entire internet knows anything about, and that document is for Solaris 9, not 8. The prescribed solution alludes to disc1 also being bootable. If it weren't for that document, I doubt I'd have ever known.

So... To make a long story short, here's how to get it to run.

Installation

Convert the disc1 iso to a vmdk disk image using QEMU's qemu-img:

qemu-img convert solaris-8-u7-disc1.iso -O vmdk solaris-8-u7-disc1.vmdk

Set up a typical VMware VM, accept the defaults - 8g hard drive and 256m of RAM. I removed the sound card and floppy but you don't have to. Don't let it auto-start though. Instead, make sure the hard drive is on IDE 0:0 and cdrom is on IDE 1:0. Then add a second hard drive and aim it at solaris-8-u7-disc1.vmdk, that disk image you created a minute ago and set that disk to be at IDE 1:1. If it's at IDE 0:1 then VMware will attempt to boot to it directly, which will fail.

Start the VM. It should boot to the DVD. The initial prompts should be straightforward. On the "Boot Solaris" screen though, arrow down and hit space to select:

[ ] DISK: Target 1:...

Select a "Solaris Interactive" installation and follow the prompts.

There are a few quirks.

  • Over and over, the installer will try to get you to run kdmconfig. In each case, select Bypass or Bypass&Suppress.
  • The installer doesn't ask for a default route. You'll have to add it manually later.
  • The interface for selecting the Geographical Region is odd. You have to press space on the V to expand a section, then move over using the arrows and hit space to select a specific region. It wasn't intuitive to me but it might be to you. I was tired at the time.

Formatting and partitioning is REALLY quirky.

On the "Select Disks" screen, deselect and reselect c0d0 (that's c-zero-d-zero). Failure to do so appears to confuse the installer into thinking that the disk is already partitioned and causes filesystem creation to fail with a cryptic error.

If you accept the default filesystem layout, you will get a small root partition and very large /export/home partition. This makes it tricky to install much software on the root partition. If you don't want to play games with symlinks later, remove the /export/home partition and expand the root partition.

The interface for editing file systems isn't intuitive though. You have to actually delete the word /export/home using the delete key and set the size to 0 to actually delete it. There's no "fill-remaining space" option to expand the root and file system creation will fail (and thankfully return you to the editor) if you set it to an invalid size. With an 8G disk, and the default swap size, I had to set my root size to 8031, which I figured out after a few failed attempts.

The rest of the installation is straightforward.

solaris 8 x86 - 1. install part 1

At some point it asks you to insert disc2 and then it installs a bunch of stuff from there too.

solaris 8 x86 - 2. install part2

And, eventually you get a login.

solaris 8 x86 - 3. first login

It's not too happy that you didn't configure X, but that's OK. If you had, it would have been even more confusing.

Post-Install Tweaks

Ok, now that the OS is installed, a few post-install tweaks are necessary.

If you didn't tell the installer to use DHCP, then it didn't ask you for a default route. You can set it manually though:

echo 192.168.123.254 > /etc/defaultrouter

I'm sure there's some way to restart networking without a reboot but I couldn't figure it out, so I rebooted. When the system came back up, I could ping yahoo and telnet to port 80 at various sites.

There are various paths that are helpful to add to the default PATH too. Edit /etc/profile and modify as follows:

PATH=$PATH:/usr/ccs/bin:/usr/ucb:/usr/openwin/bin:/usr/openwin/demo:/usr/dt/bin
...
export LOGNAME PATH

Software

Back when Solaris 8 was out, there were actually 4 DVD images available: installation, disc1, disc2 and "companion". The companion disc contained a ton of open source software packages including a bunch of GNU tools that anything approaching modern computing is really hard to do without.

If you aim VMware's fake CDROM drive at the companion DVD, Solaris should mount it automatically. The installer is graphical though, and we intentionally skipped configuring graphics during the install, so you have to aim the DISPLAY at a different computer.

Run xhost + on that other computer, then run, as root, on Solaris:

DISPLAY=192.168.123.2:0
export DISPLAY
/cdrom/s8_software_companion/installer

After a few seconds, the installer will pop up. It's intuitive.

solaris 8 x86 - 4. companion

After installing the software there are a few things to configure.

Sudo has the wrong permissions. Fix that:

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

And, nobody can actually use any of this software unless you add /opt/sfw/bin to everybody's PATH and /opt/sfw/lib to everybody's LD_LIBRARY_PATH. Edit /etc/profile as follows:

PATH=$PATH:/usr/ccs/bin:/usr/ucb:/usr/openwin/bin:/usr/openwin/demo:/usr/dt/bin:/opt/sfw/bin
LD_LIBRARY_PATH=/opt/sfw/lib
...
export LOGNAME PATH LD_LIBRARY_PATH

Woohoo! Now we have bash, gcc, gzip, gtar, gmake... everything!

Adding A User

So far everything has been done as root, but that's not going to work in the long term.

Solaris likes to put home directories in /export/home but since we told the installer not to create an /export/home filesystem, that directory doesn't even exist. Create it:

mkdir /export/home

And create a user:

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

The useradd command was confusing to me. It seemed to require the -d option, even though the -m option tells it to create a home directory, and the default place to create them is in /export/home. It's possible that I just misunderstood something though. It was pretty late when I was working on it.

The sudoers file is /opt/sfw/etc/sudoers if you want to give the user sudo access.

Remote Access

I was all "Woohoo! ... everything!" earlier, but the companion CD didn't really give us everything. Remote access is a little lacking on Solaris 8. It comes with ftp and telnet clients and servers, but SSH is conspicuously absent. This is forgivable, considering it was released in 2000, but it's hard to live without SSH these days.

Fortunately we have everything necessary to build and install OpenSSH from source. I used OpenSSL 0.9.6h and OpenSSH 2.9p2 because I'd recently had good luck with them on old linux systems. Do not expose a server running these old versions to the internet though, as they undoubtedly have vulnerabilities.

To build:

wget http://www.openssl.org/source/openssl-0.9.6h.tar.gz
gtar xfz openssl-0.9.6h.tar.gz
cd openssl-0.9.6h
./config
make
sudo make install
cd ..
wget http://ftp.usa.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-2.9p2.tar.gz
gtar xfz openssh-2.9p2.tar.gz
cd openssh-2.9p2
./configure --prefix=/usr/local/openssh-2.9p2
make
sudo make install

To configure it to start at boot, create /etc/init.d/sshd

#!/bin/sh

case "$1" in
  start)
        /usr/local/openssh-2.9p2/sbin/sshd
        ;;
  stop)
        killall sshd
        ;;
  *)
        echo $"Usage: $0 {start|stop}"
        exit 1
esac

exit 0

And symlink it to into /etc/rc3.d

cd /etc/rc3.d
sudo ln -s ../init.d/sshd S90sshd

To configure X forwarding, edit /usr/local/openssh-2.9p2/etc/sshd_config and change the X11Forwarding line to:

X11Forwarding yes

To make all of this available to everybody, update the PATH in /etc/profile

PATH=$PATH:/usr/ccs/bin:/usr/ucb:/usr/openwin/bin:/usr/openwin/demo:/usr/dt/bin:/opt/sfw/bin:/usr/local/openssh-2.9p2/bin

And to start the server without a reboot, run:

sudo /etc/init.d/sshd start

solaris 8 x86 - 7. ssh

NOW we're getting somewhere.

The Web

Solaris 8 comes with Apache 1.3.12 and it's configured to start at boot, but it's disabled by default because the config file is missing. To enable it, just copy the example config file to a real config file:

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

And start it up:

sudo /etc/init.d/apache start

The default DocumentRoot is /var/apache/htdocs. The "It Worked!" page came up immediately. After a few tweaks to the config file, I got CGI's working too.

From the client side, things weren't as good. The companion DVD provides workable versions of wget and lynx but as far as graphical web browsers go, Netscape 4.76 was all that was available. It supports PNG's, but struggles with CSS and javascript and was hilariously unusable.

solaris 8 x86 - 10. netscape

I didn't really expect it to work though, so I wasn't all that disappointed.

Graphics

The default Xsun server doesn't support SVGA or VESA, so the best you can get with it is 16 colors at 640x480.

But!

Thanks to:

  • Sun releasing the "Solaris XFree86 Video Drivers and Porting Kit" source
  • Jürgen Keil adapting it to XFree86 4.3.0.1
  • ...and allowing the guy that runs VM Back (who's name I can't find anywhere on the site) to distribute a binary package of it

We have: solaris-xf86-4.3.0.1-vmware.tar.gz

The page says you have to apply patches 109401-14, 119068-02 and 112786-43 from SunSolve before using it, but SunSolve is long gone, the Russian mirrors are sketchy and I haven't run into any issues yet without them. Your mileage may vary.

I downloaded and extracted the package, and installed it with:

pkgadd -d `pwd` SUNWxf86u SUNWxf86r

Then I ran kdmconfig and had all kinds of fun getting it configured correctly. This worked for me:

  • Video card: XF86-VMWARE VMware SVGA virtual video cards
  • Monitor: Super VGA 35.5 Hz (800x600 @ 56Hz and 1024x768 Interlaced)
  • Screen: 15-inch
  • Resolution: 800x600 - 16777216 colors @ 56Hz
    • The number of colors must match the host. 256 colors also works but leaves the cursor with a weird black box around it.
  • Virtual Resolution: 800x600

To just get an X session from the command line, create a .xinitrc file in your home directory with:

/usr/dt/bin/Xsession

and run:

xinit

And you should get a beautiful CDE session like this:

solaris 8 x85 - 5. cde

If you prefer OPENLOOK, remove your .xinitrc and run:

openwin

solaris 8 x86 - 6. openlook

Oh yeah, that looks old.

As a side effect of running kdmconfig, a graphical login will start up when the machine is rebooted.

You can disable this using:

sudo /usr/dt/bin/dtconfig -d

Or re-enable it using:

sudo /usr/dt/bin/dtconfig -e

I tried running CDE to a nested X server on a remote machine but something doesn't run properly. I got the splash screen and nothing else. Some of the other programs were running, but not everything necessary for a session, and what did run didn't show up on the screen. Openlook was even worse. It forces itself to run on the console by default, no matter what DISPLAY is set to. It seemed like it would take more time than I cared to spend to get either of them working.

Development

Yes, development. What I'm actually up to here... I wanted to get SQL Relay running.

The companion CD gave me most of the tools I needed: vim, cvs, gcc, gmake, readline, tcl... Solaris just comes with Java too. Databases were conspicuously absent though. I managed to build freetds from source, but current versions of postgresql, mysql and sqlite all failed for one reason or another and though unixodbc built just fine, it was useless without drivers from one of the other packages.

I guess Oracle 8.something.or.other was out when Solaris 8 was popular, and it might have been freely available for development purposes, like the Linux version, but I didn't have the presence of mind back then to download it. Actually, it's possible that Oracle only made Windows and Linux versions available for download. It was a long time ago and I don't remember it clearly.

At any rate, I got most of my software to compile. I had to disable SSL support in Rudiments because, for some reason, OpenSSL 0.9.6h didn't build shared object versions of its libraries. Ironically, I couldn't get the SQL Relay Java API to build either because of a compiler warning in the JNI header. The version of Python provided by the Companion CD was too old too.

I have a little tweaking to do, but that's part of the fun.

I was able to get SQL Relay to talk to MS SQL Server and Sybase using FreeTDS, and I was able to talk to Oracle via SQL Relay on a nearby Linux machine.

solaris 8 x86 - 9. sqlrsh

I guess that last screenshot isn't as interesting as similar shots usually are, as Solaris 8 x86 was once an Oracle-supported platform.

Quirks

Solaris 8 was substantially less quirky than other OS'es of similar vintage. The only really badly noticeable issue was the filesystem performance. When untarring or running rm -rf, it drags badly. It's probably slow when compiling too, but it's really noticeable when extracting or deleting lots of files.

Other quirks:

  • You have to use the Delete key rather than Backspace on the console.
  • The default shell doesn't understand ~/ but does understand $HOME.
  • The ping command is /usr/sbin/ping and /usr/sbin is not in a non-root user's path.

I'm sure I'll run into more quirks as I play with it more.

I hope so. It's odd little details that make older OS'es so much fun.

2 comments:

  1. Hello, Great job, but I cannot reproduce it. Can you share your initial VMware ?

    ReplyDelete
  2. Hi, nice post! I'd be interested to learn 'the details' as to why it wouldn't boot from ISO. I'm trying to do something similar, i.e. boot Solaris 8 x86 on QEMU using ISO image, but it fails quickly. Anyway, thanks for the post.

    ReplyDelete