raise enlastdel to 50
[unix-history] / .ref-BSD-3 / usr / doc / vmunix / setup.t
CommitLineData
be80b0b2
OB
1.bd S B 3
2.TL
3Setting up the Third Berkeley Software Tape*
4.AU
5William N. Joy
6Ozalp Babaoglu
7.AI
8Computer Science Division
9Department of Electrical Engineering and Computer Science
10University of California, Berkeley
11Berkeley, California 94720
12.PP
13.de IR
14\fI\\$1\fP\\$2
15..
16.de UX
17\s-2UNIX\s0\\$1
18..
19.FS
20*An early version of this paper appeared under the title
21``Setting up the Berkeley Virtual Memory Extensions to the
22\s-2UNIX\s0
23Operating System''
24and, no doubt, references to this paper by this name exist elsewhere
25in the documentation.
26Portions of this document are adapted from
27``Setting Up Unix/32V Version 1.0''
28by Thomas B. London and John F. Reiser.
29.FE
30The distribution tape can be used only a DEC VAX-11/780**
31with RM03 or RP06 disks and with
32TE16 tape drives.
33We have the ability to make tapes for systems with UNIBUS** disks, but
34.FS
35** DEC, VAX, UNIBUS and MASSBUS are trademarks of
36Digital Equipment Corporation.
37.FE
38.FS
39\(dg \s-2UNIX\s0 is a Trademark of Bell Laboratories.
40.FE
41such tapes are inherently rather system-specific, and will not be
42discussed here.
43The tape consists of some preliminary bootstrapping programs followed by
44one dump of a filesystem (see
45.IR dump (1))
46and one tape archive image (see
47.IR tar (1));
48if needed,
49individual files can be extracted
50after the initial construction of the filesystems.
51.PP
52If you are set up to do it,
53it is a good idea immediately to make a copy of the
54tape to guard against disaster.
55The tape is 9-track 1600 BPI and contains some 512-byte records
56followed by many 10240-byte records.
57There are interspersed tapemarks; end-of-tape is signalled
58by a double end-of-file.
59.PP
60The tape contains binary images
61of the system and all the user level programs, along with source
62and manual sections for them.
63There are about 4200
64.UX \(dg
65files altogether.
66The first tape file contains bootstrapping programs.
67The second tape file is to be put on one filesystem
68called the `root filesystem', and contains essential binaries and enough
69other files to allow the system to run.
70The third tape file has all of the source and documentation.
71Altogether the files provided on the tape occupy approximately 40000 512 byte
72blocks.\(dd
73.FS
74\(dd\s-2UNIX\s0 traditionally talks in terms of 512 character blocks, and
75for consistency
76across different versions of
77.UX
78and to avoid mass confusion, user programs in the Virtual Vax version of the
79system also talk in terms of 512 blocks, despite the fact that the file
80system allocates 1024 byte blocks of disk space.
81All user progras such as
82.IR ls (1)
83and
84.IR du (1)
85speak in terms of 512 byte blocks; only system maintenance programs such
86as
87.IR mkfs (1),
88.IR icheck (1),
89.IR dump (1),
90and
91.IR df (1),
92speak to 1024 byte blocks. It is true that i/o is most efficient in 1024
93byte quantities, but it is most natural for the user to think of this
94as ``2 blocks at a time.''
95In any case, packs remain sectored 512 bytes per sector, and at the lowest
96driver levels the system deals with 512 byte disk records.
97.FE
98.SH
99Making a disk from tape
100.PP
101This description is an annotated version of the `sysgen' manual
102page in section 8 of the UNIX Programmer's Manual.
103Before you begin to work on the remainder of this manual, be sure you
104have an up to date manual, and that you have applied all updates
105to the manual which were provided with it, in the correct order.
106.PP
107Perform the following bootstrap procedure to obtain
108a disk with a root filesystem on it.
109.IP 1.
110Mount the magtape on drive 0 at load point, making
111sure that the ring is not inserted.
112.IP 2.
113Mount a disk pack on drive 0.
114.IP 3.
115Key in at 50000 and execute the following boot program:
116You may enter in lower-case, the LSI-11 will echo in upper-case.
117The machine's printouts are shown in boldface,
118explanatory comments are within ( ).
119Terminate each line you type by carriage return or line-feed.
120.RT
121.DS
122\fB>>>\|\fRHALT
123\fB>>>\|\fRUNJAM
124\fB>>>\|\fRINIT
125\fB>>>\|\fRD 50000 20009FDE
126\fB>>>\|\fRD+ D0512001
127\fB>>>\|\fRD+ 3204A101
128\fB>>>\|\fRD+ C114C08F
129\fB>>>\|\fRD+ A1D40424
130\fB>>>\|\fRD+ 008FD00C
131\fB>>>\|\fRD+ C1800000
132\fB>>>\|\fRD+ 8F320800
133\fB>>>\|\fRD+ 10A1FE00
134\fB>>>\|\fRD+ 00C139D0
135\fB>>>\|\fRD+ 00000004
136\fB>>>\|\fRE 50000/NE:A
137\&... (machine prints out values, check typing)
138\fB>>>\|\fRSTART 50000
139.DE
140.IP
141The tape should move and the CPU should halt at location 5002A.
142If it doesn't, you probably have entered the program
143incorrectly.
144Start over and check your typing.
145.IP 4.
146Start the CPU with
147.DS
148\fB>>>\|\fRSTART 0
149.DE
150.IP 5.
151The console should type
152.DS
153.I
154\fB=\fR
155.R
156.DE
157If the disk pack is already formatted, skip to step 6.
158Otherwise, format the pack with:
159.DS
160(bring in standalone RP06 formatter)
161\fB=\|\fRrp6fmt
162\fBformat : Format RP06/RM03 Disk\fR
163
164\fBMBA no. : \fR0 (format spindle on mba \# 0)
165\fBunit : \fR0 (format unit zero)
166(this procedure should take about 20 minutes)
167(some diagnostic messages may appear here)
168
169\fBunit : \fR-1 (exit from formatter)
170\fB=\fR (back at tape boot level)
171.DE
172.IP 6.
173Next, verify the readability of the pack via
174.DS
175(bring in RP06 verifier)
176\fB=\|\fRrpread
177\fBdread : Read RP06/RM03 Disk\fR
178
179\fBdisk unit : \fR0 (specify unit zero)
180\fBstart block : \fR0 (start at block zero)
181\fBno. blocks :\fR (default is entire pack)
182
183(this procedure should take about 10 minutes)
184(some diagnostic messages may appear here)
185\fB# Data Check errors : nn\fR (number of soft errors)
186\fB# Other errors : xx\fR (number of hard errors)
187\fBdisk unit: \fR\-1 (exit from rpread)
188\fB=\fR (back to tape boot)
189.DE
190If the number of `Other errors' is not zero, consideration
191should be given to obtaining a clean pack before proceeding
192further.
193.IP 7.
194Create the root file system with the following procedure:
195.DS
196(bring in a standalone version of the \fImkfs\fR (1) program)
197\fB=\|\fRmkfs
198\fBfile sys size:\fR 7942 (number of 1024 byte blocks in root)
199\fBfile system:\fR hp(0,0) (root is on drive zero; first filsys there)
200\fBisize = 5072\fR (number of inodes in root filesystem)
201\fBm/n = 3 500\fR (interleave parameters)
202\fB=\fR (back at tape boot level)
203.DE
204You now have a empty UNIX root filesystem.
205To restore the data which you need to boot the system, type
206.DS
207(bring in a standalone \fIrestor\fR\|(1) program)
208\fB=\|\fRrestor
209\fBTape?\fR ht(1,1) (1600 bpi, second tape file)
210\fBDisk?\fR hp(0,0) (into root file system)
211\fBLast chance before scribbling on disk.\fR (just hit return)
212(30 second pause then tape should move)
213\&...
214\fB=\fR (back at tape boot level)
215.DE
216Now, you are ready to boot up
217.UX.
218.SH
219Booting UNIX
220.PP
221Now boot UNIX:
222.DS
223(load bootstrap program)
224\fB=\fR\|boot
225\fBBoot\fR
226\fB: \fRhp(0,0)vmunix (bring in \fIvmunix\fR off root system)
227.DE
228The bootstrap should then print out the sizes of the different
229parts of the system (text, initialized and uninitialized data) and then
230the system should start with a message which looks (like):
231.DS
232.B
23361656+61072+70120 start 0x4b4
234VM/UNIX (Berkeley Version 2.1) 1/5/80
235real mem = \fIxxx\fB
236avail mem = \fIyyy\fB
237ERASE IS CONTROL-H!!!
238\fB#\fR
239.R
240.DE
241The
242.I
243mem
244.R
245messages give the
246amount of real (physical) memory and the
247memory available to user programs
248in bytes.
249For example, if your machine has only 512K bytes of memory, then
250xxx will be 524228, i.e. exactly 512K.
251The ``ERASE-IS'' message is part of /.profile
252which was executed by the root shell when it started. You will
253probably want to change /.profile somewhat.
254.PP
255UNIX is now running,
256and the `UNIX Programmer's manual' applies;
257references below of the form X(Y) mean the subsection named
258X in section Y of the manual.
259The `#' is the prompt from the Shell,
260and indicates you are the super-user.
261You should first check the integrity of the root file system by
262giving the command
263.DS
264\fB#\fR chk /dev/rrp0a
265.DE
266which abbreviates
267.DS
268icheck /dev/rrp0a
269dcheck /dev/rrp0a
270.DE
271The output from
272.I chk
273should look something like:
274.DS
275.B
276icheck /dev/rrp0a
277/dev/rrp0a:
278files \0153 (r=111,d=12,b=8,c=22)
279used 1065 (i=27,ii=0,iii=0,d=1038)
280free 6558
281missing \0\0\00
282dcheck /dev/rrp0a
283/dev/rrp0a:
284 entries link cnt
2851 0 0
286.R
287.DE
288.PP
289The diagnostic from \fIdcheck\fR is normal, as inode number 1 is reserved for
290placement of bad blocks, but currently unimplemented.
291.PP
292The next thing to do is to extract the rest of the data from
293the tape.
294Comments are enclosed in ( ); don't type these.
295The number in the first command is the
296size of the filesystem to be created, in 1024 character blocks,
297just as given to the standalone version of
298.I mkfs
299above.
300(If you have an RM-03 rather than an RP-06 use ``41040'' rather than
301``145673'' in the procedure below.)
302.DS
303\fB#\|\fRdate \fIyymmddhhmm\fR (set date, see \fIdate\fR\|(1))
304\fB#\|\fR/etc/mkfs /dev/rrp0g 145673 (create empty user filesystem)
305\fBisize = 65488\fR (this is the number of available inodes)
306\fBm/n = 3 500\fR (freelist interleave parameters)
307(this takes a few minutes)
308\fB#\|\fR/etc/mount /dev/rp0g /usr (mount the usr filesystem)
309\fB#\|\fRcd /usr (make /usr the current directory)
310\fB#\|\fRcp /dev/rmt5 /dev/null (skip first tape file (tp format))
311\fB#\|\fRcp /dev/rmt5 /dev/null (skip second tape file (root))
312\fB#\|\fRumask 22
313\fB#\|\fRtar xbf 20 /dev/rmt1 (extract the usr filesystem)
314\fB#\|\fRdd if=/usr/mdec/uboot of=/dev/rrp0a bs=1b count=1
315(write boot block so \fIbproc\fR(8) disk boot scheme will work)
316\fB#\|\fRcd / (back to root)
317\fB#\|\fR/etc/umount /dev/rp0g (unmount /usr)
318.DE
319All of the data on the tape has now been extracted.
320The tape will rewind automatically.
321.PP
322You should now check the consistency of the /usr file system by doing
323.DS
324\fB#\fR chk /dev/rrp0g
325.DE
326In order to use the /usr file system, you should now remount it by
327saying
328.DS
329\fB#\fR /etc/mount /dev/rp0g /usr
330.DE
331Since all directories created by
332.IR tar (1)
333will have mode 755 (due to the
334.IR umask (1)
335above, you should run the commands
336.DS
337\fB#\fR cd /usr/src/cmd/Admin
338\fB#\fR DESTDIR=/
339\fB#\fR export DESTDIR
340\fB#\fR ./mk MODES
341.DE
342which will reset the permissions of several directories (such as /tmp)
343and also correctly set ownerships and modes of ``set-user-id'' programs
344(although they were correct already, this does no harm.)
345.SH
346Making a UNIX boot floppy
347.PP
348The next thing to do is to make a
349.UX
350boot floppy, by placing some files on a clean floppy using
351.IR arff (1).
352Place a clean floppy in the console, and issue the following commands:
353.DS
354\fB#\fR cd /usr/src/sys/floppy
355\fB#\fR arff cr *
356.DE
357This will put a copy of each file in the directory /usr/src/sys/floppy
358onto the floppy.
359You should now be able to reboot using the procedures in
360.IR boot (8).
361Try this after saying
362.DS
363\fB#\fR sync
364.DE
365which allows the system to initiate all i/o before you halt the CPU.
366It is traditional to say
367.DS
368\fB#\fR sync
369\fB#\fR sync
370.DE
371to give the system a little time, and to then reboot.
372.PP
373The boot floppy you created does not have enough files on
374it to deadstart the machine with. If your standard console floppy does
375not have a multi-segment RT-11 directory structure on it, and if you make
376a copy of it using
377.IR flcopy (1),
378delete unneeded files to make space for the
379.UX
380boot programs, and then add the files with
381.DS
382\fB#\fR cd /usr/src/sys/floppy
383\fB#\fR arff r *
384.DE
385you should be able to cold-start the machine from this floppy.
386The following set of files is believed to be adequate to cold-start
387the machine:
388.TS
389center;
390l l l.
391boot.exe restar.cmd wcsmon.sys
392consol.sys restar.ilv wcssrv.bin
393filea.pat vmb.exe
394pcs.pat wcs\fInnn\fR.pat
395.TE
396It is also useful to have the console help files on your floppy;
397their names end in ``.hlp''.
398.SH
399Taking the system up and down
400.PP
401To bring the system up to a multi-user configuration after a boot
402all you have to do is hit control-d on the console. The system
403will then perform
404/etc/rc,
405a multi-user restart script, and come up on the terminals which are
406indicated in /etc/ttys.
407See
408.IR init.vm (8)
409and
410.IR ttys (5).
411To take the system down to a single user state you can use
412.DS
413\fB#\fR kill 1
414.DE
415when you are up multi-user.
416This will kill all processes and give you a shell on the console,
417as if you had just booted.
418.PP
419If you wish to change the lines which are active you can edit the file
420/etc/ttys, changing the first characters of lines, and then do
421.DS
422\fB#\fR kill \-1 1
423.DE
424See
425.IR init.vm(8)
426for more information.
427.SH
428Adding devices
429.PP
430The UNIX system running is configured to run
431with the given disk
432and tape, a console, and 8 DZ11 lines.
433This is probably not the correct
434configuration.
435You will have to correct the configuration table to reflect
436the true state of your machine.
437.PP
438Before you mess with the source for the system it is wise to make
439a backup. The following will do this:
440.DS
441\fB#\fR cd /usr/src
442\fB#\fR mkdir distsys distsys/h distsys/sys
443\fB#\fR cd sys/sys
444\fB#\fR cp * /usr/src/distsys/sys
445\fB#\fR cd ../h
446\fB#\fR cp * /usr/src/distsys/h
447.DE
448This allows you to find out what you have done to the distribution
449system by later running the command
450.IR diffdir (1),
451comparing these directories.
452.PP
453\fBN.B.: Note that the system header files in /usr/src/sys/h are linked
454to the files in /usr/include/sys. Since programs which depend on constants
455in /usr/include/sys/param.h must correspond to the running system, you
456should be careful to not break these links.\fR
457.PP
458There are certain magic numbers and
459configuration parameters embedded in various
460device drivers that you may have to change.
461The device addresses of each device
462are defined in each driver.
463In case you have any non-standard device
464addresses,
465just change the address and recompile.
466Also, if the devices's interrupt vector address(es)
467are not currently known to the system (this is likely),
468then the file /usr/src/sys/sys/univec.c must be modified
469appropriately: namely, the proper interrupt routine addresses
470must be placed in the table `UNIvec'. Use the DZ11
471as an example (as distributed, the DZ11 vectors are
472assumed to be at locations c0 and c4 (hexadecimal)).
473.PP
474You will notice that the system, as distributed, has conditional code
475in it. The current Berkeley system, on ``Ernie Co-vax'' is made
476by defining IDENT in the ``makefile'' to be
477.DS
478IDENT= \-DERNIE \-DUCB
479.DE
480This enables the conditional code both for Berkeley and for this
481particular machine.
482It is traditional to pick a monicker for your machine, and change IDENT
483to reflect it, and to then put in changes conditionally whenever
484this makes sense.
485You can be guided by the ERNIE conditional code.
486.PP
487The system comes with 4 drivers which we are using:
488A KL/DL driver
489.I kl.c,
490a Versatec printer/plotter driver
491.I vp.c,
492and two copies of a (old and simpleminded) UNIBUS disk driver,
493named
494.I rm.c
495and
496.I rp.c.
497These last two are not in the most aesthetically pleasing of shapes,
498but are fully functional.
499There is also an RK driver
500.I rk.c,
501but we are not using it, and it may need a little work.
502.PP
503The disk and tape drivers
504for the MASSBUS devices
505(hp.c, ht.c)
506are set up to run 1 drive and should
507be changed if you have more.
508.PP
509Now, make sure you add any new drivers which you have to the list
510of DRIVERS here, and to the FILES and CFILES variables so they
511will be compiled and included in listings. You can also delete
512drivers which you don't need from FILES and CFILES, or change the code
513so that nothing will be compiled by using a ``#ifndef''.
514.PP
515The
516.I makefile
517has several useful entry points:
518.IP clean 15n
519Cleans out the directory, removing
520.B \&.o
521files and the like.
522.IP lint 15n
523Runs lint on the system; the system was almost lint-free as sent
524to you. See
525.I linterrs
526for the remaining
527.I lint
528when it was distributed.
529.IP depend 15n
530Creates a new makefile indicating dependencies on header files by
531running a search through
532.B \&.c
533files looking for ``#include'' lines.
534Make sure you format your code like the rest of the system so that
535this will work.
536.IP print 15n
537Produces a nice listing of most everything in the system
538directory in a canonical order.
539.IP symbols.sort 15n
540Creates a new file for sorting symbols in the system namelist.
541If you have locally written programs which use the system namelist
542you can put the symbols which they reference in
543.I symbols.raw
544and they will be moved at system generation to the front of the
545system namelist for quicker access.
546.IP tags 15n
547Creates a
548.I tags
549file for
550.I ex,
551to make editing of the system much easier.
552.PP
553Before running
554.I make,
555you should check the definition of the constants in
556/usr/src/sys/h/param.h
557The constants
558NBUF, NINODE, NFILE, NPROC, and NTEXT
559can be changed, and also TIMEZONE and perhaps HZ if you run on 50 cycles.\(dg
560.FS
561\(dg If you change NINODE, NFILE, NPROC or NTEXT, then the programs
562.IR analyze (1),
563.IR ps (1),
564.IR pstat (1)
565and
566.IR w (1)
567will have to be recompiled.
568A procedure for doing this is given below.
569.FE
570As distributed, the system is tuned for a fairly large machine.
571(There are also tunable constants in the file
572/usr/src/sys/h/vm.h
573but ignore them for the time being.)
574.PP
575To generate a new VM/UNIX do
576.DS
577\fB#\fR make clean
578\fB#\fR make depend
579\fB#\fR make
580.DE
581and when this works
582.DS
583\fB#\fR make lint
584.DE
585to discover any residual bugs.
586.PP
587The final object file (vmunix) should be
588moved to the root, and then booted to try it out.
589It is best to name it /newvmunix so as not to destroy
590the working system until you're sure it does work.
591It is also a good idea to keep the old working version around as
592/oldvmunix (and perhaps even a /oldervmunix) to guard against disaster.
593.PP
594\fBBe sure to always have the current system in /vmunix when you are
595running multi-user or commands such as \fIps\|\fR(1)\fB
596\fBand\fR \fIw\|\fR(1)\fB will not work.\fR
597.SH
598Special Files
599.PP
600Next you must put in special files for the new devices in
601the directory /dev using
602.IR mknod (1).
603Print the configuration file
604/usr/src/sys/sys/conf.c.
605This is the major
606device switch of each device class (block and character).
607There is one line for each device configured in your system
608and a null line for place holding for those devices
609not configured.
610The essential block special files were installed above;
611for any new devices,
612the major device number is selected by counting the
613line number (from zero)
614of the device's entry in the block configuration table.
615Thus the first entry in the table bdevsw would be
616major device zero.
617This number is also printed in the table along the right margin.
618.PP
619The minor device is the drive number,
620unit number or partition as described
621under each device in section 4.
622For tapes where the unit is dial selectable,
623a special file may be made for each possible
624selection.
625You can also add entries for other disk drives.
626.PP
627In reality, device names are arbitrary.
628It is usually
629convenient to have a system for deriving names, but it doesn't
630have to be the one presented above.
631.PP
632Some further notes on minor device numbers.
633The hp driver uses the 0100 bit of the minor device number to
634indicate whether or not to interleave a filesystem across
635more than one physical device.
636See
637.IR hp (4)
638for more detail.
639The ht driver uses the 04 bit to indicate whether
640or not to rewind the tape when it is closed. The
641010 bit indicates the density of the tape on TE16 drives.
642Again, see
643.IR ht (4).
644.PP
645The naming of character devices is similar to block devices.
646Here the names are even more arbitrary except that
647devices meant to be used
648for teletype access should (to avoid confusion, no other reason) be named
649/dev/ttyX, where X is some string (as in `0' or `d0').
650While it is possible to use truly arbitrary strings here, the accounting
651and noticeably the
652.IR ps (1)
653command make good use of the fact that tty names
654(at Berkeley) are distinct in the first 2 characters. In fact, we use
655the following convention:
656``ttyN'', with N a number for normal DZ ports. ``ttydX'' with X a single
657character (starting from 0) for dialups, ``ttykX'' with X a single letter
658for KL ports, and ``console'' (abbrev ``co'') for the console.
659This works out well.
660.PP
661The files console, tty0-tty7, mem, kmem, kUmem, floppy and null are
662already correctly configured, as are special files for the default
663paging are
664/dev/drum, and the raw and block versions of the root and /usr file
665systems.
666.PP
667The disk and magtape drivers provide a `raw' interface
668to the device which provides direct transmission
669between the user's core and the device and allows
670reading or writing large records.
671The raw device counts as a character device,
672and conventionally has the name of the corresponding
673standard block special file with `r' prepended.
674Thus the raw magtape
675files are called /dev/rmtX.
676.PP
677Whenever special files are created,
678care should be taken to change
679the access modes
680.IR (chmod (1))
681on these files to appropriate values.
682.SH
683Basics of Disk Layout
684.PP
685If
686there are to be more filesystems mounted than just the root
687and /usr,
688use
689.IR mkfs (1)
690to create any new filesystem and
691put its mounting in the file /etc/rc (see
692.IR init (8)
693and
694.IR mount (1)).
695(You might look at /etc/rc anyway to
696see what has been provided for you.)
697.PP
698There are several considerations in deciding how to adjust the arrangement
699of things on your disks:
700the most important is making sure there is adequate space
701for what is required;
702secondarily, throughput should be maximized.
703Paging space is an important parameter.
704The system
705as distributed has 33440 (512 byte) blocks in which to page.
706This should be large enough for most sites.
707You can change this if local wisdom indicates this is not good.
708.PP
709Many common system programs (C, the editor, the assembler etc.)
710create intermediate files in the /tmp directory,
711so the filesystem where this is stored also should be made
712large enough to accommodate
713most high-water marks.
714The root filesystem as distributed is quite large, and there should be
715no problem.
716All the programs that create files in /tmp take
717care to delete them, but most are not immune to
718events like being hung up upon, and can leave dregs.
719The directory should be examined every so often and the old
720files deleted.
721.PP
722Exhaustion of user-file space is certain to occur
723now and then;
724the only mechanisms for controlling this phenomenon
725are occasional use of
726.IR du (1),
727.IR df (1),
728.IR quot (1),
729threatening
730messages of the day, and personal letters.
731.PP
732The efficiency with which UNIX is able to use the CPU
733is largely dictated by the configuration of disk controllers.
734For general time-sharing applications,
735the best strategy is to try to split the root filesystem and system binaries
736(/usr), the temporary files and paging activity (/tmp and /dev/drum),
737and the user files among three disk arms.
738We will discuss such considerations more below.
739.PP
740Once you have decided how to make best use
741of your hardware, the question is how to initialize it.
742If you have the equipment,
743the best way to move a filesystem
744is to dump it
745.IR (dump (1))
746to magtape,
747use
748.IR mkfs (1)
749to create the new filesystem,
750and restore (\fIrestor\fR\|(1)) the tape.
751If for some reason you don't want to use magtape,
752dump accepts an argument telling where to put the dump;
753you might use another disk.
754Sometimes a filesystem has to be increased in logical size
755without copying.
756The super-block of the device has a word
757giving the highest address which can be allocated.
758For relatively small increases, this word can be patched
759using the debugger (\fIadb\fR\|(1))
760and the free list reconstructed using
761.IR icheck (1).
762The size should not be increased very greatly
763by this technique, however,
764since although the allocatable space will increase
765the maximum number of files will not (that is, the i-list
766size can't be changed).
767Read and understand the description given in
768.IR filesys (5)
769before playing around in this way.
770.PP
771If you have to merge a filesystem into another, existing one,
772the best bet is to
773use
774.IR tar (1).
775If you must shrink a filesystem, the best bet is to dump
776the original and restor it onto the new filesystem.
777However, this will not work if the i-list on the smaller filesystem
778is smaller than the maximum allocated inode on the larger.
779If this is the case, reconstruct the filesystem from scratch
780on another filesystem (perhaps using \fItar\fR(1)) and then dump it.
781If you
782are playing with the root filesystem and only have one drive
783the procedure is more complicated.
784What you do is the following:
785.IP 1.
786GET A SECOND PACK!!!!
787.IP 2.
788Dump the root filesystem to tape using
789.IR dump (1).
790.IP 3.
791Bring the system down and mount the new pack.
792.IP 4.
793Load the standalone versions of
794.IR mkfs (1)
795and
796.IR restor (1)
797from the floppy
798with a procedure like:
799.DS
800\fB>>>\fRUNJAM
801\fB>>>\fRINIT
802\fB>>>\fRLOAD MKFS
803 LOAD DONE, xxxx BYTES LOADED
804\fB>>>\fRST 2
805
806\&...
807
808\fB>>>\fRH
809 HALTED AT yyyy
810\fB>>>\fRU
811\fB>>>\fRI
812\fB>>>\fRLOAD RESTOR
813 LOAD DONE, zzzz BYTES LOADED
814
815\&... etc
816.DE
817.IP 5.
818Boot normally
819using the newly created disk filesystem.
820.PP
821Note that if you change the disk partition tables or add new disk
822drivers they should also be added to the standalone system in
823/usr/src/sys/stand.
824.SH
825System Identification
826.PP
827You should edit the files:
828.DS
829/usr/include/ident.h
830/usr/include/whoami.h
831/usr/include/whoami
832.DE
833to correspond to your system, and then recompile and install
834.IR getty.vm (8)
835via:
836.DS
837\fB#\fR cd /usr/src/cmd
838\fB#\fR DESTDIR=/
839\fB#\fR export DESTDIR
840\fB#\fR Admin/mk getty.vm.c
841.DE
842This will arrange for an appropriate banner to be printed on terminals
843before users log in.
844.SH
845Adding New Users
846.PP
847See
848.IR adduser (8);
849local needs will undoubtedly dictate a somewhat
850different procedure.
851.SH
852Multiple Users
853.PP
854If UNIX is to support simultaneous
855access from more than just the console terminal,
856the file /etc/ttys (\fIttys\fR\|(5)) has to be edited.
857To add a new terminal be sure the device is configured
858and the special file exists, then set
859the first character of the appropriate line of /etc/ttys to 1
860(or add a new line).
861You should also edit the file
862/etc/ttytype
863placing the type of the new terminal there (see \fIttytype\fR\|(5)).
864The file
865/etc/ttywhere is also a useful one to keep up to date.
866.PP
867Note that /usr/src/cmd/init.vm.c will have to be recompiled if there are to be
868more than 100 terminals.
869Also note that if the special file is inaccessible when \fIinit.vm\fR tries to create a process
870for it, the system will thrash trying and retrying to open it.
871.SH
872File System Health
873.PP
874Periodically (say every day or so) and always after a crash,
875you should check all the filesystems for consistency
876(\fIicheck, dcheck\fR\|(1)).
877It is quite important to execute
878.IR sync (8)
879before rebooting or taking the machine down.
880This is done automatically every 30 seconds by the
881.IR update (8)
882program when a multiple-user system is running,
883but you should do it anyway to make sure.
884.PP
885Dumping of the filesystem should be done regularly,
886since once the system is going it is very easy to
887become complacent.
888Complete and incremental dumps are easily done with
889.IR dump (1).
890See the scripts
891/etc/dumpusr
892and
893/etc/dumproot
894which we use to dump our file systems.
895You should arrange to do a towers-of-hanoi dump sequence; we tune
896ours so that almost all files are dumped on two tapes and kept for at
897least a week in most every case. We take full dumps every month (and keep
898these indefinitely).
899Note that
900/etc/dumpusr
901maintain the file /etc/lastdumpdone.
902This can be printed out at login by people who can easily then
903start dumps if one is needed.\(dg
904.FS
905\(dg More precisely, we have three sets of dump tapes: 10 daily tapes,
9065 weekly sets of 2 tapes, and fresh sets of three tapes monthly.
907We do daily dumps circularly on the daily tapes with sequence
908`3 2 5 4 7 6 9 8 9 9 9 ...'.
909Each weekly is a level 1 and the daily dump sequence level
910restarts after each weekly dump.
911Full dumps are level 0 and the daily sequence restarts after each full dump
912also.
913Thus a typical dump sequence would be:
914.TS H
915c c c c c
916n n n l l.
917tape name level number date opr size
918_
919.TH
920FULL 0 Nov 24, 1979 jkf 137K
921D1 3 Nov 28, 1979 jkf 29K
922D2 2 Nov 29, 1979 rrh 34K
923D3 5 Nov 30, 1979 rrh 19K
924D4 4 Dec 1, 1979 rrh 22K
925W1 1 Dec 2, 1979 etc 40K
926D5 3 Dec 4, 1979 rrh 15K
927D6 2 Dec 5, 1979 jkf 25K
928D7 5 Dec 6, 1979 jkf 15K
929D8 4 Dec 7, 1979 rrh 19K
930W2 1 Dec 9, 1979 etc 118K
931D9 3 Dec 11, 1979 rrh 15K
932D10 2 Dec 12, 1979 rrh 26K
933D1 5 Dec 15, 1979 rrh 14K
934W3 1 Dec 17, 1979 etc 71K
935D2 3 Dec 18, 1979 etc 13K
936FULL 0 Dec 22, 1979 etc 135K
937.TE
938We do weekly's often enough that daily's always fit on one tape and
939in fact never get to the sequence of 9's in the daily level numbers.
940.FE
941.PP
942Dumping of files by name is best done by
943.IR tar (1)
944but the number of files is somewhat limited.
945Finally if there are enough drives entire
946disks can be copied with
947.IR dd (1)
948using the raw special files and an appropriate
949block size.
950.SH
951Converting 32/V Filesystems
952.PP
953The best way to convert filesystems from 32/V
954to the new format
955is to use
956.IR tar (1).
957After converting, you can still restore files from your old-format dump
958tapes (yes the dump format is different, sorry about that), by using
959``512restor'' instead of ``restor''.
960If you wish, you can move whole file systems from 32/V to the new system
961by using ``dump'' and then ``512restor''.
962.SH
963Regenerating the system
964.PP
965It is quite easy to regenerate the system, and it is a good
966idea to try this once right away to build confidence.
967The system consists of three major parts:
968the kernel itself (/usr/src/sys/sys), the user programs
969(/usr/src/cmd and subdirectories), and the libraries
970(/usr/src/lib*).
971The major part of this is /usr/src/cmd.
972.PP
973We have already seen how to recompile the system itself.
974The three major libraries are the C library in /usr/src/libc
975and the \s-2FORTRAN\s0 libraries /usr/src/libI77 and /usr/src/libF77. In each
976case the library is remade by changing into the corresponding directory
977and doing
978.DS
979\fB#\fR make
980.DE
981and then installed by
982.DS
983\fB#\fR make install
984.DE
985Similar to the system,
986.DS
987\fB#\fR make clean
988.DE
989cleans up.
990The source for all other libraries is kept in subdirectories of
991/usr/src/lib; each has a makefile and can be recompiled by the above
992recipe.
993.PP
994Recompiling all user programs is accomplished by using
995a directory in /usr/src/cmd, called Admin, which contains
996two files: mk and destinations.
997The file mk is a shell script for recompiling files in /usr/src/cmd.
998For instance, to recompile ``date.c'',
999all one has to do is
1000.DS
1001\fB#\fR cd /usr/src/cmd
1002\fB#\fR Admin/mk date.c
1003.DE
1004this will place a stripped version of the binary of ``date''
1005in /usr/dist3/bin/date, since date normally resides in /bin, and
1006Admin is building a file-system like tree rooted at /usr/dist3.
1007You will have to make the directory dist3 for this to work.
1008It is possible to use any directory for the destination, it isn't necessary
1009to use the default /usr/dist3.
1010You can set the default by doing:
1011.DS
1012\fB#\fR DESTDIR=\fIpathname\fR
1013\fB#\fR export DESTDIR
1014.DE
1015.PP
1016To regenerate all the system source you can do
1017.DS
1018\fB#\fR DESTDIR=/usr/newsys
1019\fB#\fR export DESTDIR
1020\fB#\fR cd /usr
1021\fB#\fR rm -r newsys
1022\fB#\fR mkdir newsys
1023\fB#\fR cd /usr/src/cmd
1024\fB#\fR Admin/mk * > Admin/errs 2>& 1 &
1025.DE
1026This will take about 4 hours on a reasonably configured machine.
1027When it finished you can move the hierarchy into the normal places
1028using
1029.IR mv (1)
1030and
1031.IR cp (1),
1032and then execute
1033.DS
1034\fB#\fR DESTDIR=/
1035\fB#\fR export DESTDIR
1036\fB#\fR cd /usr/src/cmd/Admin
1037\fB#\fR mk ALIASES
1038\fB#\fR mk MODES
1039.DE
1040to link files together as necessary and to set all the right set-user-id
1041bits.
1042.SH
1043Making orderly changes
1044.PP
1045In order to keep track of changes to system source we migrate changed
1046versions of commands in /usr/src/cmd in through the directory /usr/src/new
1047and out of /usr/src/cmd into /usr/src/old for a time before removing them.
1048Locally written commands which aren't distributed are kept in /usr/src/local
1049and their binaries are kept in /usr/local. This allows /usr/bin /usr/ucb
1050and /bin to correspond to the distribution tape (and to the manuals that
1051people can buy). People wishing to use /usr/local commands are made
1052aware that they aren't in the base manual. As manual updates incorporate
1053these commands they are moved to /usr/ucb.
1054.PP
1055A directory /usr/junk to throw garbage into, as well as binary directories
1056/usr/old and /usr/new are very useful. The man command supports manual
1057directories such as /usr/man/manj for junk and /usr/man/manl for local
1058to make this or something similar practical.
1059.SH
1060Interpreting system activity
1061.PP
1062The
1063.I vmstat
1064program provided with the system is designed to be an aid to monitoring
1065systemwide activity. Together with the
1066.IR ps (1)
1067command (as in ``ps av''), it can be used to investigate systemwide
1068virtual activity.
1069You should modify
1070.IR vmstat (1m)
1071so that it prints out disk statistics for the disks
1072you have, changing the headers to something appropriate for your
1073system.
1074Examine the definitions of DK_UNIT in the disk drivers supplied to see
1075how the code in \fIvmstat\fR and \fIiostat\fR and the system correspond.
1076.PP
1077By running
1078.I vmstat
1079when the system is active you can judge the system activity in several
1080dimensions: job distribution, virtual memory load, paging and swapping
1081activity, disk and cpu utilization.
1082Ideally, most jobs should be either running (RQ) or sleeping (SL),
1083there should be little paging or swapping activity, there should
1084be available bandwidth on the disk devices (most single arms peak
1085out at about 30-35 tps in practice), and the user cpu utilization (US) should
1086be high (about 60%).
1087.PP
1088If the system is busy, then the number of active jobs may be large,
1089and several of these jobs may often be in disk wait (DW). If the virtual
1090memory is very active, then the paging demon may be running (SR will
1091be non-zero). It is healthy for the paging demon to free pages when
1092the virtual memory gets active; it is triggered by the amount of free
1093memory dropping below a threshold and increases its pace as free memory
1094goes to zero.
1095.PP
1096If you run
1097.I vmstat
1098when the system is busy (a ``vmstat 5'' is best, since that is how
1099often most of the numbers are recomputed by the system), you can find
1100imbalances by noting abnormal job distributions. If a large number
1101of jobs are in disk wait (DW) or page wait (PW), then the disk subsystem
1102is overloaded or imbalanced. If you have a large number of non-dma
1103devices or open teletype lines which are ``ringing'', or user programs
1104which are doing high-speed non-buffered input/output, then the system
1105time may go very high (60-70% or higher).
1106.PP
1107If the system is very heavily loaded, or if you have very little memory
1108relative to your load (512K is little in most any case), then the system
1109may be forced to swap. This is likely to be accompanied by a noticeable
1110reduction in system performance as the system does not swap ``working
1111sets'', but rather forces jobs to reinitialize their resident sets
1112by demand paging. If you expect to be in a memory-poor environment
1113for an extended period you might consider administratively limiting system
1114load.
1115.SH
1116Tunable constants
1117.PP
1118There is a modicum of tuning available in the paging replacement algorithm
1119if it appears to be badly tuned for your configuration.
1120The page replacement (clock) algorithm is run whenever there are
1121not LOTSFREE pages available
1122(this and all other constants discussed here are defined in the system
1123header file /usr/src/sys/h/vm.h).
1124This sets up resistance to consumption of the remaining free memory
1125at a minimal rate SLOWSCAN, which gives the desired number of seconds
1126between successive examinations of each page. The rate at which the clock
1127algorithm is run increases linearly to a desired rate of FASTSCAN when
1128there is no free memory. Thus as the available free memory decreases,
1129the clock algorithm works harder to hold on to what is left.
1130If less than DESFREE pages are available and the paging rate is high,
1131then the system will begin to swap processes out. If less than MINFREE
1132pages are available then the system will begin to swap, regardless of the
1133paging rate.
1134.PP
1135When it has to swap, the system first tries to find a process which has
1136been blocked for a long time and swap it out first. If there are no
1137jobs of this flavor, then it will choose among the remaining jobs in
1138a strictly round-robin fashion, based on core residency time. It attempts
1139to guarantee (during periods of very heavy load) enough core residency to
1140a process to allow it to at least rebuild its set of active pages (since
1141it must do so by demand paging). Processes which are swapped out
1142with large numbers of active pages similarly receive lower priority for
1143swapin, favoring small jobs to return to the core resident set quickly.
1144.PP
1145It is
1146.I very
1147desirable that the system run under reasonably heavy load with little
1148swapping, with the memory partitioning being done by the clock replacement
1149algorithm, rather than by the swapping algorithm. The costs associated
1150with paging activity are the time spent in the paging demon, the overhead
1151associated with reclaim page faults (RE), and the extra disk activity
1152associated with pagins and pageouts.
1153We will discuss disk considerations later; when kept to about 40 reclaim
1154faults per second, the cost of reclaims is less than 1% of total processor
1155time. The cpu time (shown by ``ps l2'') accumulated by the pageout demon
1156will show how much overhead it is generating.
1157.PP
1158The system, as distributed, runs the replacement algorithm whenever less
1159than 1/8 of the total user memory is free.
1160This is done starting with a 30 second revolution time of the clock
1161algorithm and increasing to a 20 second revolution time when there is no
1162free memory.
1163The goal here is to use as much memory as possible (i.e. have the
1164free list short) but to not have the system run out and start to swap.
1165You can experiment with changing the writable copies of these variables
1166(e.g. ``lotsfree'' is the writable copy of LOTSFREE) using
1167.I adb,
1168as in:
1169.DS
1170\fB#\fR adb \-w /vmunix /dev/kmem
1171/m 0 #ffffffff
1172lotsfree/D
1173---adb prints value of lotsfree---
1174/W 0t100
1175.DE
1176Here the ``/W 0t100'' command changed the value of
1177.I lotsfree
1178to be 100 (decimal).
1179.SH
1180Balancing disk load
1181.PP
1182It is critical for good performance to balance disk load.
1183There are at least five components of the disk load which you can
1184divide between the available disks:
1185.DS
11861. The root file system.
11872. The /tmp file system.
11883. The /usr file system.
11894. The user files.
11905. The paging activity.
1191.DE
1192In our system we currently have 1.75M bytes of memory and 2 disks:
1193an RP06 and an AMPEX 9300. We run with the root, /tmp, and paging activity
1194on the RP-06, while the
1195/usr
1196file system and user files are on the 9300.
1197This gives a fairly even split of file activity in our environment.
1198.PP
1199A split such as this is a good initial guess if you have two arms.
1200If you are fortunate to have three arms, you can try splitting the
1201files up various ways. The most important things to remember are to
1202even out the disk load as much as possible, and to do this by
1203decoupling file systems (on separate arms) between which heavy copying occurs.
1204Note that a long term average balanced load is not important... it is
1205much more important to have instantaneously balanced
1206load when the system is busy.
1207.PP
1208Intelligent experimentation with a few file system arrangements can
1209pay off in much improved performance. It is particularly easy to
1210move the root, the
1211/tmp
1212file system and the paging area. Place the
1213user files and the
1214/usr
1215directory as space needs dictate and experiment
1216with the other, more easily moved file systems.
1217.PP
1218Finally, when you have your configuration worked out, you should set
1219the constant MAXPGIO based on the maximum number of transfers you can
1220expect from your paging device. The system assumes that if more transfers
1221than this occur, then the system is overloaded, and unless there is
1222a reasonable amount of free memory, it then begins to swap. The swap scheduler
1223also consider jobs small if their size when they were swapped out was less
1224than twice this constant. Such small jobs have a better chance of getting
1225swapped back in when the core situation is tight, since they can be
1226expected to be able to run in a small number of page frames.
1227.SH
1228Process size limitations
1229.PP
1230As distributed, the system provides for a maximum of 64M bytes of
1231resident user virtual address space. The size of the text, and data
1232segments of a single process are currently limited to 4M bytes each, and
1233the stack segment size is limited to 512K bytes. These
1234can be increased by changing the constants MAXTSIZ, MAXDSIZ and MAXSSIZ
1235in the file
1236/usr/src/sys/h/vm.h.
1237You must be careful in doing this that you have adequate paging space.
1238As configured above, the system has only 16M bytes of paging area.\(dg
1239.FS
1240\(dg Recovery from running out of paging area is currently
1241not handled gracefully: the system panics.
1242.FE
1243.PP
1244To increase the amount of resident virtual space possible,
1245you can alter the constant USRPTSIZE (in
1246/usr/src/sys/h/vm.h)
1247and by correspondingly change the definitions of
1248.I Usrptmap
1249and
1250.I Syssize
1251in
1252/usr/src/sys/sys/locore.s
1253.PP
1254The 4M byte limitation on individual segment size is enforced by
1255the constants MAXTSIZ, MAXDSIZ and MAXSSIZ for the text, data and stack
1256segments respectively. These can be increased, given the availability of
1257adequate amounts of swap space, up to 16M bytes.
1258In order to increase the size of the stack or data
1259segments beyond 16M, you will have to increase the amount of space which can be
1260mapped by the corresponding disk map. To increase, for instance, the
1261maximum segment size to 32M bytes it would be adequate to double both
1262the initial and maximum sizes for the diskmap. Thus defining (in
1263/usr/src/sys/h/dmap.h)
1264.DS
1265#define DMMIN 32
1266#define DMMAX 8192
1267.DE
1268(i.e. a minimum segment size of 16K bytes and a maximum size of 4M bytes)
1269would allow the 16 diskmap slots to map 32M bytes.
1270.SH
1271Other limitations
1272.PP
1273Due to the fact that the file system block numbers are stored in
1274page table
1275.B pg_blkno
1276entries, the maximum size of a file system is limited to
12772^20 1024 byte blocks. Thus no file system can be larger than 1024M bytes.
1278.PP
1279The number of system buffers is limited to be less than 64
1280because of the way that the MASSBUS adaptor map registers are initialized.
1281The construct ``(128<<9)'' appears in the
1282/usr/src/sys/sys/mba.c
1283and
1284/usr/src/sys/sys/hp.c
1285code, silently enforcing this restriction.
1286.SH
1287Scaling down
1288.PP
1289If you have less than 1M byte of memory you may wish to scale the
1290paging system down, by reducing some fixed table sizes not directly
1291related to the paging system.
1292For instance, we have raised NBUF from 32 to 48, NCLIST from 150 to 500,
1293(also increasing the basic clist block size CBSIZE from 12 to 28)
1294and NPROC, NINODE and NFILE for a fairly large system from the way
1295they were distributed for \s-2UNIX/32V\s0.
1296We also increased TTLOWAT (from 50 to 125) and TTHIWAT (from 150 to 650.)
1297If you
1298pull NCLIST down, you should adjust these also.
1299You can use
1300.IR pstat (1m)
1301to find out how much of these structures are typically in use.
1302Although the document is pretty much obsolete for the \s-2VAX\s0,
1303you can see the last few pages of ``Regenerating System Software''
1304in Volume 2B of the programmers manual for hints on setting some of these
1305constants.
1306.SH
1307Odds and Ends
1308.PP
1309The programs
1310dump,
1311icheck, quot, dcheck, ncheck, and df
1312(source in /usr/source/cmd)
1313should be changed to
1314reflect your default mounted filesystem devices.
1315Print the first few lines of these
1316programs and the changes will be obvious.
1317You will probably want to amend some of /usr/lib/crontab, and will
1318certainly want to add to /usr/lib/Mail.rc.
1319.PP
1320You should periodically examine the file /usr/adm/messages, which acts
1321as a system error log (see dmesg(1m)).
1322In particular, memory controller errors are checked for every 10 minutes
1323and a diagnostic is produced (printing memory controller register C)
1324if there were any errors.
1325.in +4i
1326.sp 3
1327Good Luck
1328.sp 1
1329William N. Joy
1330.br
1331Ozalp Babaoglu