COMPUTER AND NETWORK
SYSTEM ADINISTRATION
CIS 5406-01
Summer 1998 - Lesson 9

Configuring a UNIX 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.
 
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
 
      - 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
  
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 5 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 (see page 328 in MWNTS4).
 
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
 
    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 339 and the use of
special utilities (REGBACK.EXE and REGREST.EXE) that come with the Windows NT
Resource Kit, as well as the NTBackup program that comes with NT.