COMPUTER AND NETWORK
SYSTEM ADINISTRATION
CIS 5406-01
Summer 1997 - Lesson 9
Configuring a Kernel
A. The UNIX kernel
1. in one sense, the kernel is the operating system
2. manages the hardware
3. provides low level interface to the hardware (through
system calls)
4. contents vary - usually performs:
- process management
- memory management
- secondary storage management (free-space, storage
allocation, disk scheduling)
- I/O system management (device drivers)
- file system implementation
- interrupt handler
- protection mechanism
- networking
5. microkernel approach
- microkernel contains bare minimum
- acts as a message passer or arbitrator for other
modules
- many functions are implemented modularly outside of the
kernel
- example: CMU Mach microkernel, with a UNIX macrokernel above it
Another example is the MkLinux project, a Linux port with
a microkernel underneath. A popular port is to the
Macintosh PowerPC platform.
6. layered approach
- limits paths of information flow to modules in
contiguous layers
- Minix is an example:
0 kernel
1 FS MM
2 task task task task task task
- OS/2 is also layered
- protects hardware from direct user access
- helps keep kernel from crashing if one module
fails
- allows the addition or modification of modules without
rewriting the whole kernel
- for example, one could add a different file system to Minix
by replacing the FS module
- debugging new version of a layered OS is simplified by
a layered modular approach
- disadvantages
> if there are too many layers the
paradigm fails because there are exceptions to
information flow
> for example, there may be an instance where it makes
sense for layer 2 to talk directly to layer 5
B. Differences between BSD and AT&T;
1. Original BSD systems
- require that kernel be configured and recompiled before use
2. AT&T; systems
- attempt to load parts of kernel at boot time depending on:
+ hints given in system file
+ hardware actually located when kernel probes the system
C. When to configure BSD systems (see "man config" on SunOS 4.x)
1. New system installation
- mainly want to remove all unnecessary device drivers
- reduce size since kernel memory is not usable by
user processes
- don't need to understand a lot about device addresses, flags,
priority levels, etc.
- start with a GENERIC kernel configuration
- when in doubt, don't remove it!
- make sure you have a backup kernel
2. adding device drivers
- you don't always need to add a device driver when you add
a device
- the new device may already be in the current kernel
configuration
- if not, the new device may already be in the GENERIC kernel
configuration
- if device is in GENERIC kernel then copy its entry
line from the GENERIC configuration file
- rarely will you have to create a configuration entry
from scratch
3. tuning table sizes
- the number of kernel data structures is static
- if you want a:
larger process table, or a
larger disk quota table, or a
larger number of file table entries
then you must rebuild the kernel
- how do you know if you need larger tables?
use: pstat -T
example xi (compute and file server):
219/3628 files -- 6%
140/1946 inodes -- 7%
78/1034 processes -- 7%
10868/66524 swap -- 15%
example pi (file server only):
123/1235 files -- 10%
100/670 inodes -- 15%
39/330 processes -- 12%
3712/51236 swap -- 7%
- define MAXUSERS in configuration file (/sys->/usr/sys/->/usr/kvm/sys)
> this will increase number of all tables
according to formulae on page 227
> number of MAXUSERS on xi = 64
- to fine tune SunOS 4.x tables modify param.c in your new
configuration directory (which we'll see in a minute)
- one example:
+ the size of the quota table is defined
in param.c to be a function of MAXUSERS
+ in reality, it should be a function of the number
of total users (accounts)
D. SunOS 4.x configuration walk-through
- assume we want to try and reduce kernel size
1. look at kernel size: # ls -l /vmunix
2. look at current config: # strings /vmunix | grep SunOS
3. cd /usr/sys/sun4c/conf (or /usr/sys/sun4m/conf)
4. cp current config file to new config file
5. edit the new config file
6. run the config program: # /etc/config
7. cd ../
8. type: # make
9. save old kernel in root directory
10. copy new kernel to root directory as vmunix
11. warn users & reboot
E. Solaris (SunOS 5.x) configuration walk-through
1. Intro
- BSD loads all modules defined in the configuration file
- AT&T; only loads drivers for devices that it finds when probing
the system
- loads other modules at first reference
- can override this and can dynamically load modules
- first, how can you tell current configuration?
2. sysdef - tells you more than you want to know :)
- lists all loadable modules
part of output:
Node 'options', unit #0
Node 'aliases', unit #-1 (no driver)
Node 'memory', unit #-1 (no driver)
Node 'virtual-memory', unit #-1 (no driver)
Node 'TI,TMS390S10', unit #-1 (no driver)
Node 'openprom', unit #-1 (no driver)
Node 'iommu', unit #0
Node 'sbus', unit #0
Node 'espdma', unit #0
Node 'esp', unit #0
Node 'sd', unit #-1 (no driver)
Node 'st', unit #-1 (no driver)
Node 'sd', unit #0 (no driver)
Node 'sd', unit #1 (no driver)
Node 'sd', unit #2 (no driver)
Node 'sd', unit #3
Node 'sd', unit #4 (no driver)
Node 'sd', unit #5 (no driver)
Node 'sd', unit #6 (no driver)
Node 'audio', unit #-1 (no driver)
Node 'SUNW,bpp', unit #-1 (no driver)
Node 'ledma', unit #0
Node 'le', unit #0
Node 'cgthree', unit #0
Node 'obio', unit #0
Node 'zs', unit #0
Node 'zs', unit #1
- also lists all loadable modules
Similar info from "prtconf"
3. /usr/sbin/modinfo - currently loaded modules
Id Loadaddr Size Info Rev Module Name
1 fc045000 3ba0 1 1 specfs (filesystem for specfs)
2 fc04c000 1340 - 1 swapgeneric (root and swap configuration)
3 fc058000 1a56 1 1 TS (time sharing sched class)
4 fc04a000 49c - 1 TS_DPTBL (Time sharing dispatch table)
5 fc05d000 15248 2 1 ufs (filesystem for ufs)
6 fc055000 ad4 1 1 rootnex (sun4m root nexus)
...
15 fc0b4000 c4f0 61 1 esp (ESP SCSI Host Bus Adapter Drive)
...
76 fc535000 6fdd 36 1 fd (Floppy Driver)
77 fc46a800 17a4 - 1 klmmod (KLM misc module)
"modinfo displays information about the loaded modules. The
format of the information is as follows:
Id Loadaddr Size Info Rev Module Name
where Id is the module ID, Loadaddr is the starting text
address, size is the size of text, data, and bss in bytes,
Info is module specific info, Rev is the revision of the
loadable modules system, and Module Name is the filename and
description of the module.
The module specific information is the block and character
major numbers for drivers, the system call number for system
calls, or, for other module types, the index into the
appropriate kernel table:"
< the "Info" field is driver specific
- the character major numbers for drivers
- the system call number for system calls
- for other module types, the index into the appropriate kernel table
4. /usr/sbin/modload - can use this command to load a module into a
running kernel
5. /etc/system ("man -s 4 system")
- this file is used for customizing the operation of the kernel
- allows you to override the dynamic loads
- make a backup (can use boot -a to access backup file)
- /etc/system key words:
moddir: Set the search path for modules
rootfs: Set the filesystem type of the root
rootdev: Set the root device
exclude: Exclude this module - do NOT load
forceload: Loaded at boot time rather than at first reference
set: Set an integer variable in the kernel or a module to a
new value. ** Be careful **
F. Linux configuration walk-through
1. look in /linux or /usr/src/linux; details in README file. You
may need to run the steps in the section named "INSTALLING the kernel".
2. make menuconfig - configures new kernel
- this runs the script: Configure
- the completed configuration is in a file
named .config (shell script variables)
- a backup is in .config.old
3. make dep - sets up dependences for compilation
4. make clean - remove any old object files
5. make zdisk - creates bootable floopy
- actually, this command will execute
#2 above if you don't have a current
.config file
Another popular variation is "make zlilo", which will install your
new kernel in a known place and run "lilo".
6. keep a backup boot disk!
Linux also has loadable modules! Consult
/usr/src/linux/README.modules for details. In particular,
note the "mod" commands - depmod, insmod, lsmod, modprobe,
and rmmod.
Configuring the Windows NT Kernel
Configuring Windows NT does not mean having to rebuild the kernel, since
the source code is not available. NT does make extensive use of Dynamic
Loadable Libraries -- DLL files, which provides a convenient way to extend
the kernel's capabilities.
As for tuning parameters, one place is in the Settings/System dialog box.
One tab, named "Performance", allows you to modify the priority of the
foreground application and modify the paging disk space, as well as the
size of the Registry file. Other tabs allow you to modify other system
parameters, such as the "Environment" (system and user variables),
"Hardware Profiles" (Control Sets that describe different hardware configurations),
"User Profiles" (per user desktop settings), "General" (read-only machine
characteristics) and "Startup/Shutdown" (set BOOT.INI parameters, set
recovery options).
Another place where system parameters are viewed and modified is the Registry.
Chapter 11 of MWNTS4 provides the details. Note that the Registry is a common
database for hardware and software configuration information. It supercedes
the older DOS/WIN config files CONFIG.SYS, AUTOEXEC.BAT, SYSTEM.INI, WIN.INI
and PROTOCOL.INI.
Two GUI-based Registry editors are available: REGEDIT.EXE (16-bit) and
REGEDT32.EXE (32-bit). Use the latter, as it understands more of the native
data types.
The Registry Editor uses the same Explorer paradigm for viewing a database tree
with five roots:
HKEY_LOCAL_MACHINE - configuration information particular
to the computer (for any user).
HKEY_LOCAL_MACHINE\HARDWARE - binary info about the machine;
easier to view info via Windows NT Diagnostics tool
HKEY_LOCAL_MACHINE\SAM - Security Account Manager (SAM)
database; user and group account info. Note that passwords
are stored here, in an encrypted form.
HKEY_LOCAL_MACHINE\SECURITY - user rights, group membership and
passwords (encrypted)
HKEY_LOCAL_MACHINE\SOFTWARE - Installed software configuration
HKEY_LOCAL_MACHINE\SYSTEM - Startup process (book has comment
that you shouldn't tamper with these)
HKEY_CLASSES_ROOT - window is a subkey of HKEY_LOCAL_MACHINE\Software.
The information stored here is used to open the correct application
when a file is opened using the Windows NT Explorer and for
Object Linking & Embedding (OLE) -- for backward compatability.
HKEY_CURRENT_USER - root of the configuration information for the
user who is currently logged on. The user's folders, screen colors,
and Control Panel settings are stored here. This information is referred to
as a user's profile. HKEY_CURRENT_USER is a subkey of HKEY_USERS.
HKEY_USERS - root of all user profiles on the computer.
HKEY_CURRENT_CONFIG - hardware profile used by the local computer
at system startup.
Registry entries contain keys with values. The values are native data types,
containing binary and string data (see page 300 of MWNTS4).
Hive - A single file (with ".LOG" ending; in \WINNT\SYSTEM32\CONFIG) that
contains keys, subkeys and values.
Note comment about backing up the Registry on page 306 and the use of
special utilities (REGBACK.EXE and REGREST.EXE) that come with the Windows NT
Resource Kit.