COMPUTER AND NETWORK SYSTEM ADMINISTRATION Summer 1996 - Lesson 09 Configuring a Kernel A. the 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 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 pi = 20 > it doesn't always make sense to increase all tables > for example, as pi gets more loaded we may need more file table entries and inode table entries > but, will number of processes increase? > no, we'll just waste the space taken by 1,000 process table entries - 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/config7. 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 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 config - 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 6. keep a backup boot disk! Linux also has loadable modules! Consult /usr/src/linux/README.modules for details.