Tag Archives: C

Installing BSD 2.9 on a DEC Pro-350, Part V – Building the kernel

A great test of whether a UNIX operating system is installed correctly is if you can recompile the kernel and then run that kernel. Like most UNIX Operating Systems, BSD 2.9 provides a mechanism for rebuilding the kernel. The procedure is documented here in section 5:

http://minnie.tuhs.org/PUPS/Setup/2.9bsd_setup.pdf

But I will provide a walk-through of the necessary steps below.

Note that you will need to the 16 disk usr set in order to get the kernel sources. You can either use this set during the installation of BSD, or install them at a later time using the restor command. Note that if you choose the latter, the contents of /usr will be destroyed. The command to restore the 16 disk set is the same as documented earlier:

restor rf /dev/rr51 /dev/rrd0c

You can, of course, substitute /dev/rr50 if you like.

The instructions work, but the BSD distribution is missing some files that are needed for building the kernel. Those files are:

/usr/bin/awk
/usr/bin/sed
/usr/include/sys/wait.h
/usr/include/sys/cnio.h
/usr/include/sys/dcreg.h
/usr/lib/libovc.a

Unfortunately, you will not (yet) be able to find all of these files in a single distribution. One of the goals of this blog is to put together one distribution that has everything needed, but that will have to wait until I know everything that is needed!

The good news is everything I’ve needed so far is somewhere under this directory structure:

http://www.tuhs.org/Archive/PDP-11/Distributions/ucb

Even better, it seems all you need is these two distributions:

http://www.tuhs.org/Archive/PDP-11/Distributions/ucb/2.9-derivatives/2.9bsd4pro350-kcwellsc
http://www.tuhs.org/Archive/PDP-11/Distributions/ucb/2.9BSD

If you extract the contents of the tar files from the tarfiles directory in the first link, you will have 95% of what you need. If you also extract the root.tar.gz and usr.tar.gz files from the second link, you can then find the remaining 5%. Note that the files aren’t really gzipped – they are simply tar files with a .gz extension.

Once you have the kernel sources installed and the above missing files in place, you need to configure the kernel. To do that, cd to /usr/net/sys/conf and type config PRO. This process creates the necessary files in /usr/net/sys/PRO and takes about 5 minutes.

Once the configuration is done, you need to edit a couple of files in the /usr/net/sys/PRO directory. Those files are:

param.c
localopts.h
Makefile

And depending on what usr set you installed, you may need to edit this file:

/usr/include/sys/koverlay.h

In param.c, change this line:

#define HZ 60 /* Ticks/second of the clock */
to:
#define HZ 66 /* Ticks/second of the clock */

In localopts.h, uncomment this line:

#define SMALL /* for small sys: smaller hash queues, etc. */

In Makefile, remove r5.o from this line:

OV2 = text.o ureg.o malloc.o sys1.o main.o mem.o sig.o trap.o clock.o rd.o r5.o xp.o hp.o

And add it to this line:

OV4 = ttyold.o ttynew.o tty.o prim.o kl.o partab.o nami.o hk.o pc.o r5.o

Failure to do so results in a message similar to below:

size unix
text data bss dec oct
7424 + 6356 + 13940 = 27720 = 66110 unix
103296 total text, overlays: (13056,16448,15808,10368,12928,15040,12224)
./checksys -b unix
Overlay 2 too large 16448 bytes.
System will occupy 173056 bytes of memory (incl buffers, clists and net).
**** SYSTEM IS NOT BOOTABLE.
*** Error code 1

Next, check the value of OVLY_TABLE_BASE in /usr/include/sys/koverlay.h. If it’s set to 01000, change it to 0450. If you don’t, you will end up with a kernel that hangs at the DIGITAL splash screen.

To avoid this warning during compilation of checksys.c:

cc -V -I. -I/usr/include -O -o checksys checksys.c
ld:/usr/lib/libovc.a(__.SYMDEF): out of date (warning)

you may want to run ranlib on /usr/lib/libovc.a before continuing.

With the configuration out of the way, the next step is to cd to /usr/net/sys/PRO and type make depend. This builds the module dependencies and takes about 15 minutes.

The last step is to simply type make in the /usr/net/sys/PRO directory. This step actually builds the kernel and takes about 3 hours. If during compilation you get an error such as this:

Make: Don't know how to make /usr/include/signal.h. Stop.
*** Error code 1

It means that the code you are compiling is newer than the include files, which shouldn’t be the case. When I received this error, the date on my system include files were the year 1910! Considering that the UNIX epoch didn’t start until 1/1/1970, I’m not sure how this happened. Ensuring that the date is something more recent and then issuing a touch on the include files fixes the problem. While we’re on the subject of UNIX dates, you can make BSD 2.9 somewhat Y2K compliant by changing the base year from 1900 to 2000 inside of date.c. Then all years issued to the date command will be based off the year 2000. There’s probably some work in the kernel that needs to be done to be fully Y2K compliant, but changing only the date code has been working thus far.

Once the build is finished, you will have a new kernel named unix in the /usr/net/sys/PRO directory. To be safe, rename this file to something other than unix to prevent accidentally clobbering the stock unix kernel. Something like prounix is good. Then copy the prounix file to /. Now you have a new kernel installed and it’s time to test it.

To test your new kernel, you need to have the maintenance cable installed as described previously. With the cable installed, bring the system to single-user mode, sync the disks, and power off the Pro-350. You must power off the Pro-350 – a soft reboot will not work.

# shutdown +1
# sync
# sync
Power off the Pro

Now, fire up your terminal program, set the comm parameters to 9600,7,N,1 and turn on the Pro-350. In a moment, you will see the 40boot message. At the prompt, type rd(0,64)prounix. If all goes well, in a minute or so you will see messages similar to this on the console:

mem=351872

Berkeley UNIX (Rev. 2.9.54) Thu Nov 14 12:32:20 EST 1985

CONFIGURE SYSTEM:
/unix is not the running version
Configuration setup error
Erase=^?, kill=^U, intr=^C
#

Note that you are in single-user mode. The error message is not really an error – it’s just a warning that the booted kernel (prounix) is not the same as the configured kernel (unix). If after testing you want to install your new kernel, rename the original kernel (DO NOT DELETE IT) to something memorable like stockunix, and then rename your test kernel from prounix to unix. Then follow the installation instructions we did earlier to make the kernel bootable. Refer to section 2.4 of the BSD documentation for more information.