Back in the 80's and 90's, there was this OS floating around called Coherent. Don't call it Coherent Unix because it's not, it's just Coherent. It is very unix-like but as far as I know, it's a clean-room implementation of a unix'ish system, not a derivative of any prior work. From what I've heard, early versions were less unix'ish than later versions, but I've never seen any of those, so who knows?
I'm not sure where I first saw Coherent. I know that I never saw it running anywhere. I think I saw a set of installation disks at a company I worked for in New Orleans in the 90's, but that could be a false memory. I know that it's impossible, but it seems like I've just always known about it. Funny how memory works.
I know for sure that I've run into it archived at The Unix Heritage Society. I was always a nervous about giving it a run it though, as distribution would require permission but it was unclear whether that had ever actually been given. There's open-source software in the archive and updates which Robert Chalmers got permission to distribute, but no word about the install disks themselves...
In 2012 Hans Bezemer tracked down the right guy (Bob Schwartz) and got permission to put together a redistributable root image. Sort-of. He's allowed to distribute it. But just him. Not you!
From The Beez's post:
I've had permission from Robert Swartz himself to distribute the first perfectly legal Coherent 4.2.10 QEMU image as long as you comply with the following conditions: You may use the software on this image free of charge for personal, non-commercial use. You may NOT redistribute this image or the software it contains without written permission from the copyright holder. The software is provided on an "as is" basis without warranty of any kind.
Well, maybe you could distribute it if you got permission too.
I wasn't looking to go bugging people for that though. I just downloaded the image and started playing with it.
That was like a year ago or more.
It ran great, but it was a little small, 42mb I think. I wanted to play with X and gcc. X barely fit on the root and I only got gcc to install after making a copy of the image, mounting it at /u1 and deleting all of the files. There was barely any room left on root, the kernel didn't appear to support more than 2 disks, no support for cross-partition links or symlinks... Red lights at every turn.
There had to be a better way.Making More Space
I tried in vain to create a larger disk image but for some reason, every time I'd run a mkfs it would hose the root. I'm not sure if I was doing something wrong, or if there were bugs in QEMU back then, but a few days ago I got the urge to fiddle with it again, and, under QEMU 2.1.0, it worked great.
So, to make a bigger root, here's what you do...
Create a 512m disk image on the VM host.
dd if=/dev/zero of=coherent-bigger.img bs=1024 count=524288
I had all kinds of problems with larger disks, but 512m worked fine.
Boot qemu with the public image and the bigger disk image.
qemu -hda coherent.public.img -hdb coherent-bigger.dd -boot c -m 32
Log in as root with password rootroot
Partition the bigger drive and, while you're at it, install a master boot record.
fdisk -b /conf/mboot /dev/at1x
The -b option specifies the a master boot record to use. /conf has a bunch of bootloader images in it. mboot is the master boot record. /dev/at1x refers to the second drive. /dev/at0x is the first drive. The "x" means "whole drive" as opposed to individual partitions which are "a","b","c" and "d".
fdisk is interactive and friendly but very different from fdisk on other unixes.
- zero the partition table
- change active partition to partition 4
- change one logical partition (partition 4)
- specify partition sizes in cylinders
- yes, create a coherent partition
- accept defaults for base cylinder and partition size
- make note of the number of blocks in the partition
- write the partition table
Now that the partition is defined, it's accessible via /dev/at1a. Format it!
mkfs /dev/at1a 1032129
What's that crazy number off the end there? That's the number of 512-byte blocks in the partition. It ought to still be on the screen from fdisk. Yes, it's essential to provide that number. Yes, it will hose all kinds of things if you use too large of a number.
Now, mount the new partition, copy everything from the root over to it, then sync and unmount it.
mount /dev/at1a /mnt tar cvfp mnt/root.tar .exrc .lastlogin .profile autoboot bin coherent* conf dev etc f0 f1 home lib lost+found tboot tmp tmp.pipe update usr cd mnt tar xvfp root.tar rm root.tar mkdir mnt chmod 777 mnt cd / sync umount /dev/at1a
About the boot process... Coherent has a three-stage boot. The master boot loader looks for a bootable partition and runs whatever boot loader is installed in the first sector. This secondary boot loader looks on the root file system for /tboot and runs it. tboot (the tertiary boot loader) looks for autoboot which is usually a link to the current coherent kernel and runs that. At various points you have the option to specify a different partition or kernel to boot, but that's the general idea.
fdisk installed the master boot loader, but we still need the secondary boot loader on the primary partition. Fortunately that's easy to install.
dd if=/conf/boot of=/dev/at1a count=1
Also fortunately (for me), the man pages for "boot" and "fdisk" described all of this very clearly.
And that's it. Now we just need to shut down...
cd / shutdown halt 0
...and restart qemu with the larger disk as hda.
qemu-system-i386 -hda coherent-bigger.img -boot c -m 32
And look at all that space!
The Beez created a user for himself in the public image but I'm not him, so I wanted to get rid of him and add myself. Turns out that you have to manually edit /etc/passwd, /etc/shadow and /etc/group to do this and then run passwd on the command like to set the new user's password. You also have to manually remove and create the home directories too, and there's no /etc/skel to copy into the new home.
Also, the chown command doesn't support setting the group, so you have to run chown and chgrp to properly set permissions for the home directory.
Ok! I did all of that, and I could now log in as me and poke all around the system.
There was a C compiler, an older vi clone (elvis), some games in /usr/games (but sadly no advent), uucp, and the standard set of unixy commands.
Disk access was exceptionally slow though. Exceptionally. File caching on the host helped a lot, but things were slow until it kicked in, and then got slow again as blocks got pushed out. Seems unlikely that Coherent would have run that way on real hardware. I imagine that QEMU's virtual disk controller doesn't emulate some particular thing that Coherent's looking for to decide whether to use DMA or something. Ehh. What are you going to do? Try SCSI instead of IDE? Seems like I tried that once, long ago. Might be worth checking into again though.X Windows
I really wanted to get X and gcc installed. Both were tricky. After much trial and error, here's what I ended up with...
Install X first. The gcc installer asks you to swap the linker post-install and the new linker causes problems for the X installer. Also, X ONLY supports serial mice. Fortunately QEMU does too, but you have to shutdown Coherent and restart QEMU using:
qemu-system-i386 -hda coherent-bigger.img -boot c -m 32 -chardev msmouse,id=msmouse -device isa-serial,chardev=msmouse
The X installer disk images are available in the TUHS Archive.
The installation process is simple except for 1 thing. You have to tell the installer the name of the package you want to install. You can't just tell it "install everything on the disk". There's no apparent way to do that at least. How does one determine the name of the package provided by the set of floppies? Maybe it was written on the outside of the physical media. It's definitely not in any of the FAQ's or any other obvious place. I randomly discovered the names of the X and gcc packages when googling for something else, unrelated. Some guy had torn his hair out figuring them out and happened to mention them in a post about something else. As far as I know, that post is the only place on the internet that the package names are given.
But! Once you know them, the installation process is straightforward.
install CohX /dev/fva0 2
CohX is the name of the X package. /dev/fva0 is floppy drive 0. 2 is the number of disks in the set.
Use the QEMU monitor to insert and swap disk images when prompted.
The installation is interesting. It relinks some binaries and builds others from source. When prompted, select a Microsoft Serial Mouse, at 1200 baud. Uncompress the manual pages.
When the installation is complete, add /usr/X11/bin to the PATH in /etc/profile. Then edit /usr/X11/lib/Xconfig and remove "640x480" from the two lines that it's found in. Then log out and back in to reset your PATH.
To get an X session, run:
Backspace doesn't work properly in the xterm, nor does vi, but xcalc does and xeyes does and so do various other X Windows distractions.
This is X11R5 though, and a seemingly stripped down version of it. ftp.x.org is still around though, so maybe some day I'll try to get some other software running.
The color X server doesn't work, but if you want to try it, remove /usr/X11/bin/X and create a hard link to X386color.
cd /usr/X11/bin/X rm X ln X386color X
Maybe it can be made to work under bochs or some other emulator. Something to try later.GCC
The GCC installer disk images are also available in the TUHS Archive.
GCC was a little trickier to install than X. CohGCC is the name of the package. Knowing that, the install command was straightforward:
install CohGCC /dev/fva0 4
However disks 3 and 4 are mislabeled. Disk 4 is Disk 3 and vice versa. Ha!
When the installation is finished, replace the default linker with a gcc-compatible linker.
mv /bin/ld /bin/ld.pregcc mv /bin/ld.pre11 /bin/ld
Add /u1/gnu/bin to PATH in /etc/profile, relogin and bam!
Unfortunately there's not too much to compile. There are some programs under /usr/src, but ideally I'd want to try to get some modern software running.File Transfer
Hmmm... According to the FAQs, Coherent supports NE2000 ethernet cards, TCP/IP and SLIP. If it does though, the version I have doesn't. The kernel doesn't appear to and there don't appear to be any networky programs installed anywhere. If any of that was available on the original 4.2 distribution, it didn't get installed. I don't imagine it was though, being only 4 floppies and all.
So, what options did I have?
The Beez recommends a floppy image formatted for MSDOS. Coherent has various utilities for reading those, you can loopback mount the image under most unixes, and QEMU allows you to insert and eject the image easily. But what if I want to transfer 15 meg of data. No way I'm tarring, splitting, dd'ing, copying and catting those together.
Coherent appears to come with various serial-line file transfer solutions though. Taylor UUCP was on there, but UUCP is a nightmare to set up. Kermit was also available though. Hmmm...
I set up a getty on com2 by editing /etc/ttys and updating the second line:
That cryptic jumble means: run a login (1), local device (l), 38400 baud (S), device /dev/com2l (com2l). 38400 is unfortunately the fastest speed available.
Then I re-ran qemu with a second serial port redirected to a telnet server on port 10000.
qemu-system-i386 -hda coherent-bigger.img -boot c -m 32 -chardev msmouse,id=msmouse -device isa-serial,chardev=msmouse -chardev socket,id=socket,host=0.0.0.0,port=10000,ipv4,nodelay,server,nowait -device isa-serial,chardev=socket
And then I could use kermit on linux and ckermit on Coherent to transfer files. It's a little tricky and long-winded to explain, but basically you connect over, log in, run kermit over there, start a receive process, escape back locally, start a transfer, and wait...
And I do mean wait.
No way I'm waiting that long...
It was cool for small files, but not for anything big.
In the end, it was faster to tar up a bunch of files, reboot QEMU using the tar file as the second disk...
qemu-system-i386 -hda coherent-bigger.img -hdb files.tar -boot c -m 32 -chardev msmouse,id=msmouse -device isa-serial,chardev=msmouse
...and then untar it in Coherent as root.
tar xvf /dev/at1x
Unfortunately this requires a reboot every time you want to transfer a bunch of files, but it's faster than any of the alternatives.Software?
I really hoped to get bash working and a newer version of vi, and maybe eventually some of my own software, but it was a losing battle from the start. Even bash 1.14.7 requires a lot of tweaking, and I still haven't gotten it to fully compile. There's a 14 character filename limit too. C++ source has to have a .C extension rather than .cpp ...
Not the downhill run I'd hoped for. But, on the bright side, it's something to look forward to tinkering with later.Endearing Features
Coherent has a lot of these.
- QEMU doesn't detect the idle loop and slams the host cpu.
- It only appears to support 2 drives.
- Disk access is incredibly slow.
- Symlinks are not supported.
- Cross-device links are not supported.
- X only supports serial mice.
- backspace and vi don't work in xterms.
- The shutdown command is odd - shutdown halt|reboot
- Gcc requires .C extensions on C++ sources.
- There's a 14 character filename limit.
- The filesystem appears to be quite sensitive. Any improper reboot hoses the filesystem. Fsck is not automatically run at startup. When you run it manually, it ends up asking you to remove corrupted files almost every time.
- Y2K issues galore.
There were more too but those were the most significant. Sounds like a lot, but given the age of the distribution, I expected even more.
I guess it's also worth mentioning that The Mark Williams Company was a small outfit, tiny compared to SCO and the Linux community with whom they ultimately had to compete. That they were able to build a unix-like OS for PC with the features that it had and maintain it for so long is quite a feat.And Finally...
All right! I finally have a working Coherent installation. It seems pretty stable. There's plenty of space to play with. Lots of stuff works and lots of opportunities remain for tinkering. Hopefully I'll figure out color graphics and get some more modern software to compile soon. Maybe I'll even find some vintage software to run on it. I'd ideally like to get some kind of networking going too. I might have to wait on The Beez to finagle that though.