Unix V4

Today the long awaited image of the UNIX V4 tape from University of Utah was published. And it actually contained Unix – that must’ve been such a relief. Anyway, I had to try it on PDP2011. Yes, it works.

There’s some trickery involved in converting the tape image to a bootable RK image, and that was figured out very quickly by the collective wisdom of the people on the PiDP-11 mailing list. Read up there, or find a very concise summary here http://squoze.net/UNIX/v4/

Working with it is a lesson in anger management, to be honest. No, the ‘cd’ command didn’t exist yet, you have to type ‘chdir’ – typos are not allowed, and to make sure you get that message loud and clear a backspace lets you start all over. Guess how many tries it took me to type ‘chdir /usr/src/conf’, and then finding out that it’s sys instead of src. Still it is super interesting to see this earlier version.

A short session log then:

boot from rk:

Hello, world [PDP2011 boot]: cpu 11/45 fpu
177776 psw
177774 slr
177772 pir
177770 mbr
177676 - 177600 pdr/par
177576 - 177572 mmu
177570 sdr
177566 - 177560 kl
177546 kw
177416 - 177400 rk
173776 - 173000 m9312
172516 mmu
172376 - 172300 pdr/par
172276 - 172200 pdr/par
165776 - 165000 m9312

boot from rk:
k
unix

login: bin
% chdir /usr/sys/conf
% ./mkconf
rk
tc
tm
dh
pc
mem

% sh rc
rm mkconf.c and rc when done
% cat conf.c
/*
* Copyright 1974 Bell Telephone Laboratories Inc
*/

int (*bdevsw[])()
{
&nulldev, &nulldev, &rkstrategy, &rktab,
&nulldev, &tcclose, &tcstrategy, &tctab,
&tmopen, &tmclose, &tmstrategy, &tmtab,
0
};

int (*cdevsw[])()
{
&klopen, &klclose, &klread, &klwrite, &klsgtty,
&nulldev, &nulldev, &rkread, &rkwrite, &nodev,
&tmopen, &tmclose, &tmread, &tmwrite, &nodev,
&dhopen, &dhclose, &dhread, &dhwrite, &dhsgtty,
&pcopen, &pcclose, &pcread, &pcwrite, &nodev,
&nulldev, &nulldev, &mmread, &mmwrite, &nodev,
0
};

int rootdev {(0<<8)|0};
int swapdev {(0<<8)|0};
int swplo 4000;
int nswap 872;
% ^D
login: root
# chdir /dev
# ls
null
tty8
# rm null
null: 0100444 mode y
# /etc/mknod mem c 5 0
# /etc/mknod kmem c 5 1
# /etc/mknod null c 5 2
# sync
# sync

Hello, world [PDP2011 boot]: cpu 11/45 fpu
177776 psw
177774 slr
177772 pir
177770 mbr
177676 - 177600 pdr/par
177576 - 177572 mmu
177570 sdr
177566 - 177560 kl
177546 kw
177416 - 177400 rk
173776 - 173000 m9312
172516 mmu
172376 - 172300 pdr/par
172276 - 172200 pdr/par
165776 - 165000 m9312

boot from rk:
k
unix

login: root
# ps al
31 -100 127 0 0 2 60416 ?? e?????a??Tal?<Z? ????? l? ?
12 40 127 0 1 6 60454 /etc/init
12 40 127 8 7 9 60500 -
13 100 1 8 30 12 ps al
12 90 127 0 6 5 60160 /etc/update
# mv . x
values of B will give rise to dom!
#

What did I just do?

The kernel on the tape doesn’t include the mem driver – and thus, the ps command doesn’t work, and neither is there a /dev/null – there is a file named that on the image from the tape, but it is a regular file.

To correct that, we need to make a config (ie, run mkconf) and type in a list of drivers to its standard input. I’ve kept the list of devices the same as the tape kernel has (I think!) and just added the mem. Then relink the kernel. All this is done under the bin account as intended, it won’t work nicely if you run it as root. You’ll have to be root to add the device special files in /dev though. The major number of 5 is the number of the line in the conf.c cdevsw array; the minor numbers are 0 for mem, 1 for kmem, 2 for null.

Having done that, reboot, login as root and check if the ps command now works. And if the easter egg in mv was already present in V4. Yes, it is.

Leave a Reply