(This is a guest post by xorhash.)
ChuckMcM on Hacker News (https://news.ycombinator.com/item?id=15990351) reacted to my previous entry here about trying to typeset old troff sources with groff. It was said that â€˜â€˜you really canâ€™t appreciate troff (and runoff and scribe) unless you do all of your document preparation on a fixed width font 24 line by 80 column terminalâ€™â€™.
â€˜â€˜Challenge acceptedâ€™â€™ I said to myself. However, it would be quite boring to just do my document preparation in this kind of situation. Thus, I raised the ante: I will do my document preparation on a fixed width font 24 line by 80 column terminal on an ancient UNIX . That document is the one you are reading here.
While it would have been interesting to run my experiment on SIMH with a genuine UNIX , I was feeling far too lazy for that. Another constraint I made for myself is that I wanted to use the Internet as little as possible. Past the installation phase, only resources that are on the filesystem or part of the Seventh Edition Manual should be consulted. However, if I have to work with SIMH, chances are Iâ€™d be possibly fighting the emulator and the old emulated hardware much more than the software.
My first thought was that I could just go for FreeBSD 1.0 or something. FreeBSD 1.0 dates from around 1993. That was surprisingly recent, but I needed a way to get the data off this thing again, so I did want networking. As luck would have it, FreeBSD 1.0 refused to install, giving me a hard read error when trying to read the floppy. FreeBSD 2.0 was from 1995 and already had colorful menus to install itself (!). Thatâ€™s no use for an exercise in masochism.
I turned to browsing http://gunkies.org/wiki/Main_Page for a bit, hoping to find something to work with. Lo and behold, it pointed me to http://www.nordier.com/v7x86/! V7/x86 is a port of UNIX version 7 to the x86. It made some changes to V7, among those are:
including the more pager,
including the vi editor,
providing a console for the screen, rather than expecting a teletype, and
including an installation script.
The version of vi that ships with it is surprisingly usable, even by todayâ€™s standards. I believe I wouldâ€™ve gone mad if Iâ€™d had to use ed to write this text with.
The V7/x86 installer requires that a partition exists with the correct partition type. It ships with a tool called ptdisk to do that, but because /boot/mbr does not exist on the installation environment, it cannot initialize a disk that does not already have a partition table (http://www.nordier.com/v7x86/files/ISSUES). Thus I used a (recent) release of FreeBSD to create it. At first, FreeBSD couldnâ€™t find its own CD-ROM, which left me quite confused. As it turns out, it being unable to find the CD-ROM was a side effect of assigning only 64 megabytes of RAM to the virtual machine. Once Iâ€™d bumped the RAM to 1GB, the FreeBSD booting procedure worked and I could create the partition for V7/x86. V7/x86 itself comes packaged on a standard ISO file and with a simple installation script. It seems it requires an IDE drive, but I did not investigate support for other types of hard drives, in particular SATA drives, much further. There seem to be no USB drivers, so USB keyboards may not work, either.
During the installation, my hard drive started making a lot of scary noises for a few minutes, so I aborted the installation procedure. After moving the disk image to a RAM disk (thank you, Linux, for giving me the power of tmpfs), I restarted the installation and it went in a flash. The scary noises were probably related to copying data with a block size of 20, which I assume was 20 bytes per block: The virtual hard disk was opened with O_DIRECT, i.e., all writes got flushed to it immediately. Rewriting the hard drive sector 20 bytes at a time mustâ€™ve been rather stressful for the drive.
I thought I knew my UNIX , but the 70s apparently had a few things to teach me. Fortunately, getting the system into a usable state was fairly simple because http://www.nordier.com/v7x86/doc/v7x86intro.pdf got me started. The most important notes are:
V7 boots in single-user mode by default. Only when you exit single-user mode, /etc/rc is actually run and the system comes up in multi-user mode.
Using su is recommended because root has an insane environment by default. To erase, # is used, rather than backspace (^H). The TERM variable is not set, breaking vi. /usr/ucb is not on the path, making more unavailable.
The character to interrupt a running command is DEL, not ^C. It does not seem possible to remap this.
more is a necessity on a console. I do not have a teletype, meaning I cannot just â€˜â€˜scrollâ€™â€™ by reading the text on the sheet so far. Therefore, man is fairly useless without also piping its output to more.
Creating a user account was simple enough, though: Edit /etc/passwd, run passwd for the new user, make the home directory, done. However, my first attempt failed hard because I was not aware of the stty erase situation. I now have a directory in /usr that reads â€˜â€˜xorhashâ€™â€™, but is definitely not the ASCII string â€˜â€˜xorhashâ€™â€™. Itâ€™s â€˜â€˜o^Hxorhashâ€™â€™. The same problem applies to hitting the arrow keys out of habit to access the command history, only to butcher the partial command you were writing that way.
Another mild inconvenience is the lack of alternative keyboard layouts. There is only the standard US English keyboard layout. Iâ€™m not used to it and it took me a while to figure out where some relevant keys ($, ^, &, / and – in particular) are. Though I suppose if I really wanted to, I could mess around with the kernel and the console driver, which is probably the intended way to change the keyboard layout in the first place.
Equipped with a new user, I turned to writing this text down before my memory fails me on the installation details.
I am infinitely thankful for having vi in the V7/x86 distribution. Truly, I cannot express enough gratitude after just seeing a glimpse of ed in the V7/x86 introduction document. It has some quirks compared to my daily vim setup, though. Backspacing across lines is not possible. c only shows you until where youâ€™re deleting by marking the end with $. You only get one undo, and undoing the undo is its own undo entry. And of course, thereâ€™s no syntax highlighting in that day and age.
And now for the guests of this show for which the whole exercise was undertaken. The information in volume 2A of the 7th Edition manuals was surprisingly useful to get me started with the ms macros. I didnâ€™t bother reading the troff/nroff Userâ€™s Manual as I only wanted to use the program, not write a macro package myself. The ms macro set seemed to be the way to go for that. In this case, nroff did much more heavy lifting than troff. After all, troff is designed the Graphic Systems C/A/T phototypesetter. I donâ€™t have one of those. M. E. Leskâ€™s Typing Documents on the UNIX System: Using the âˆ’ms Macros with Troff and Nroff and Brian W. Kernighanâ€™s A TROFF Tutorial proved invaluable trying to get this text formatted in nroff.
The â€˜â€˜testingâ€™â€™ cycle is fairly painful, too. When reading the nroff output, some formatting information (italics, bold) is lost. more can only advance pagewise, which makes it difficult to observe paragraphs in their entirety. It also cannot jump or scroll very fast so that finding issues in the later pages becomes infuriating, which I solved by splitting the file up into multiple files, one for each section heading.
Since I was writing this in roff anyway, I figured I might as well take advantage of its capabilities â€“ I wanted to use refer. It is meant to keep a list of references (think BibTeX). Trying to run it, I got this:
/bin/refer: syntax error at line 1: â€˜)â€™
The system was trying to run the file as shell script. This also happens for tbl. It was actually an executable for which support got removed during the port (see https://pastebin.com/cxRhR7u9). I contacted Robert Nordier about this; he suggested I remove the -i and -n flags and recompile refer. Now it runs, exhibiting strange behavior instead: https://pastebin.com/0dQtnxSV For all intents and purposes, refer is quite unusable like this. Fixing this is beyond my capacity, unfortunately, and (understandably) Robert Nordier does not feel up to diving into it, either. Thus, weâ€™ll have to live without the luxury of a list of references.
Iâ€™m writing this text on V7/x86 in a virtual machine. There are multiple ways I could try to get it off the disk image, such as via a floppy image or something. However, that sounds like effort. Iâ€™ll try to search for it in the raw disk image instead and just copy it out from there. Update: Iâ€™ve had to go through the shared floppy route. The data in this file is split up on the underlying file system. Fortunately, /dev/ entries are just really fancy files. Therefore, I could just write with tar to the floppy directly without having to first create an actual file system. The host could then use that “floppy” as a tar file directly.
Even when I have these roff sources, I still need to get them in a readable format. Iâ€™ll have to cheat and use groff -Thtml to generate an HTML version to put on the blog. However, to preserve some semblance of authenticity, Iâ€™ll also put the raw roff source up, along with the result of running nroff over it on the version running on V7/x86. That version of nroff attributes the trademark to Bell Laboratories. This is wrong. UNIX is a registered trademark of The Open Group.
ChuckMcM was right. When youâ€™re grateful for vi, staring at a blob of text with no syntax highlighting and with limited space, you start appreciating troff/nroff much more. In particular, LaTeX tends to have fairly verbose commands. Scanning through those without syntax highlighting becomes more difficult. However, â€˜â€˜parsingâ€™â€™ troff/nroff syntax is much easier on oneâ€™s mind. Additionally, the terse commands help because
stands out much less than
That can be helped by adding whitespace, but then you remove some precious context on your tiny 80×24 screen. troff/nroff are very much children of their time, but theyâ€™re not as bad as I may have made them look last time. Having said that, thereâ€™s no way youâ€™ll ever convince me to actually touch troff/nroff macros.
As for the system as a whole, I was positively surprised how usable it was by todayâ€™s standards. The biggest challenge is getting the system up and shutting it down again, as well as moving data to and from it. I did miss having a search function whenever I was looking for information on roff in volume 2A of the manual.
I have the greatest of respect for the V7/x86 project. Porting an ancient operating system that hardcoded various aspects of the PDP-11 in scattered places must have been extremely frustrating. The drivers were written in the ancient version of C that is used on V7 (see /usr/sys/dev).