Red Hat Linux 6.1: The Official Red Hat Linux Reference Guide | ||
---|---|---|
Prev | Chapter 2. System Administration | Next |
This section contains information on what happens when a Red Hat Linux system is booted and shut down. Let's start with information on the files in /etc/sysconfig.
The following information outlines the various files in /etc/sysconfig, their function, and their contents.
The following files are normally found in /etc/sysconfig:
/etc/sysconfig/clock
/etc/sysconfig/keyboard
/etc/sysconfig/mouse
/etc/sysconfig/network
/etc/sysconfig/pcmcia
/etc/sysconfig/amd
/etc/sysconfig/tape
Let's take a look at each one.
The /etc/sysconfig/clock file controls the interpretation of values read from the system clock. Earlier releases of Red Hat Linux used the following values (which is deprecated):
CLOCKMODE=mode, where mode is one of the following:
GMT -- indicates that the clock is set to UTC.
ARC -- on Alpha only indicates the ARC console's 42-year time offset is in effect.
Currently, the correct values are:
UTC=boolean, where boolean is one of the following:
true -- indicates that the clock is set to UTC. Any other value indicates that it is set to local time.
ARC=boolean, where boolean is one of the following:
true -- (for Alpha-based systems only) Indicates the ARC console's 42-year time offset is in effect. Any other value indicates that the normal UNIX epoch is assumed.
The /etc/sysconfig/keyboard file controls the behavior of the keyboard. The following values may be used:
KEYTABLE=file, where file is the name of a keytable file. For example: KEYTABLE="/usr/lib/kbd/keytables/us.map"
The /etc/sysconfig/mouse file is used to specify information about the available mouse. The following values may be used:
MOUSETYPE=type, where type is one of the following:
microsoft -- A Microsoft mouse.
mouseman -- A MouseMan mouse.
mousesystems -- A Mouse Systems mouse.
ps/2 -- A PS/2 mouse.
msbm -- A Microsoft bus mouse.
logibm -- A Logitech bus mouse.
atibm -- An ATI bus mouse.
logitech -- A Logitech mouse.
mmseries -- An older MouseMan mouse.
mmhittab -- An mmhittab mouse.
XEMU3=emulation, where emulation is one of the following:
yes -- Three mouse buttons should be emulated.
no -- The mouse already has three buttons.
In addition, /dev/mouse is a symlink that points to the actual mouse device.
The /etc/sysconfig/network file is used to specify information about the desired network configuration. The following values may be used:
NETWORKING=answer, where answer is one of the following:
yes -- Networking should be configured.
no -- Networking should not be configured.
HOSTNAME=hostname, where hostname should be the FQDN (Fully Qualified Domain Name), but can be whatever hostname you want.
Please Note: For compatibility with older software that people might install (such as trn), the /etc/HOSTNAME file should contain the same value as here.
FORWARD_IPV4=answer, where answer is one of the following:
yes -- Perform IP forwarding.
no -- Do not perform IP forwarding.
(The current Red Hat Linux installation sets this to "no" by default [for RFC compliance], but if FORWARD_IPV4 is not set at all, forwarding is enabled for compatibility with the configuration files used on Red Hat Linux versions 4.2 and earlier.)
GATEWAY=gw-ip, where gw-ip is the IP address of the network's gateway.
GATEWAYDEV=gw-dev, where gw-dev is the gateway device (e.g. eth0).
NISDOMAIN=dom-name, where dom-name is the NIS domain name.
The /etc/sysconfig/pcmcia file is used to specify PCMCIA configuration information. The following values may be used:
PCMCIA=answer, where answer is one of the following:
yes -- PCMCIA support should be enabled.
no -- PCMCIA support should not be enabled.
PCIC=pcic-type, where pcic-type is one of the following:
i82365 -- The computer has an i82365-style PCMCIA socket chipset.
tcic -- The computer has a tcic-style PCMCIA socket chipset.
PCIC_OPTS=option, where option is the socket driver (i82365 or tcic) timing parameters.
CORE_OPTS=option, where option is the list of pcmcia_core options.
CARDMGR_OPTS=option, where option is the list of options for the PCMCIA cardmgr.
The /etc/sysconfig/amd file is used to specify operational parameters for amd. The following values may be used:
ADIR=path, where path is the amd directory. It should be "/.automount" and is normally never changed.
MOUNTPTS=mountpts, where mountpts is, for example, "/net /etc/amd.conf"
AMDOPTS=options, where options are any extra options for AMD.
The /etc/sysconfig/tape file is used to specify tape-related configuration information. The following values may be used:
DEV=devnam, where devnam is the tape device (for example, "/dev/nst0"). Use the non-rewinding device for these scripts.
For SCSI tapes this is "/dev/nst#", where "#" is the number of the tape drive you want to use. If you only have one, then use "/dev/nst0."
For IDE tapes you use "/dev/ht#", where "#" is the number of the tape drive you want to use. If you only have one, then use "/dev/ht0".
For floppy tape drives use "/dev/ftape".
ADMIN=account, where account is the user account to send mail to if the backup fails for any reason. Normally set to "root."
SLEEP=time, where time is the time to sleep between tape operations. Some drives need a bit more than others, but "5" seems to work for 8mm, 4mm, and DLT.
BLOCKSIZE=size, where size is the tape drive's optimal block size. A value of "32768" worked fine for 8mm, then 4mm, and now DLT. An optimal setting is probably however much data your drive writes at one time.
SHORTDATE=date, where date is a string that evaluates to a short date string, to be used in backup log filenames. The default setting is: "\$(date +%y:%m:%d:%H:%M)".
DAY=date, where date is a string that evaluates to a date string, to be used for the log file directory. The default setting is: "$(date +log-%y:%m:%d)".
DATE=date, where date is a string that evaluates to a regular date string, to be used in log files. The default setting is: "$(date)".
LOGROOT=path, where path is the root of the logging directory.
LIST=file, where file is the file name the incremental backup will use to store the incremental list. It will be followed by a sequence number.
DOTCOUNT=count, where count is the name of a file used for counting as you go, to know which incremental list to use.
COUNTER=count-file, where count-file is used for rewinding when done.
BACKUPTAB=file, where file is the name of the file in which we keep our list of backup(s) we want to make.
The following files are normally found in /etc/sysconfig/network-scripts:
/etc/sysconfig/network-scripts/ifup
/etc/sysconfig/network-scripts/ifdown
/etc/sysconfig/network-scripts/network-functions
/etc/sysconfig/network-scripts/ifcfg-<interface-name>
/etc/sysconfig/network-scripts/ifcfg-<interface-name>-<clone-name>
/etc/sysconfig/network-scripts/chat-<interface-name>
/etc/sysconfig/network-scripts/dip-<interface-name>
/etc/sysconfig/network-scripts/ifup-post
/etc/sysconfig/network-scripts/ifdhcpc-done
Let's take a look at each one.
Symlinks to /sbin/ifup and /sbin/ifdown, respectively. These are the only two scripts in this directory that should be called directly; these two scripts call all the other scripts as needed. These symlinks are here for legacy purposes only -- they will probably be removed in future versions, so only /sbin/ifup and /sbin/ifdown should currently be used.
These scripts take one argument normally: the name of the device (e.g. "eth0"). They are called with a second argument of "boot" during the boot sequence so that devices that are not meant to be brought up on boot (ONBOOT=no, [see below]) can be ignored at that time.
Not really a public file. Contains functions which the scripts use for bringing interfaces up and down. In particular, it contains most of the code for handling alternative interface configurations and interface change notification through netreport.
The first file defines an interface, while the second file contains only the parts of the definition that are different in a "clone" (or alternative) interface. For example, the network numbers might be different, but everything else might be the same, so only the network numbers would be in the clone file, while all the device information would be in the base ifcfg file.
The items that can be defined in an ifcfg file depend on the interface type.
The following values are common to all base files:
DEVICE=name, where name is the name of the physical device (except dynamically-allocated PPP devices where it is the "logical name").
IPADDR=addr, where addr is the IP address.
NETMASK=mask, where mask is the netmask value.
NETWORK=addr, where addr is the network address.
BROADCAST=addr, where addr is the broadcast address.
GATEWAY=addr, where addr is the gateway address.
ONBOOT=answer, where answer is one of the following:
yes -- This device should be activated at boot-time.
no -- This device should not be activated at boot-time.
USERCTL=answer, where answer is one of the following:
yes -- Non-root users are allowed to control this device.
no -- Non-root users are not allowed to control this device.
BOOTPROTO=proto, where proto is one of the following:
none -- No boot-time protocol should be used.
bootp -- The bootp protocol should be used.
dhcp -- The dhcp protocol should be used.
The following values are common to all PPP and SLIP files:
PERSIST=answer, where answer is one of the following:
yes -- This device should be kept active at all times, even if deactivated after a modem hangup.
no -- This device should not be kept active at all times.
MODEMPORT=port, where port is the modem port's device name (for example, "/dev/modem").
LINESPEED=baud, where baud is the modem's linespeed (for example, "115200").
DEFABORT=answer, where answer is one of the following:
yes -- Insert default abort strings when creating/editing the script for this interface.
no -- Do not insert default abort strings when creating/editing the script for this interface.
The following values are common to all PPP files:
DEFROUTE=answer, where answer is one of the following:
yes -- Set this interface as the default route.
no -- Do not set this interface as the default route.
ESCAPECHARS=answer, where answer is one of the following:
yes -- Use the pre-defined asyncmap.
no -- Do not use the pre-defined asyncmap.
HARDFLOWCTL=answer, where answer is one of the following:
yes -- Use hardware flow control.
no -- Do not use hardware flow control.
PPPOPTIONS=options, where options is an arbitrary option string. It is placed last on the command line so it can override other options (such as asyncmap) that were specified previously.
PAPNAME=name, where name is used as part of "name $PAPNAME" on the pppd command line.
Note that the "remotename" option is always specified as the logical PPP device name, like "ppp0" (which might perhaps be the physical device ppp1 if some other PPP device was brought up earlier...), which makes it easy to manage pap/chap files -- name/password pairs are associated with the logical PPP device name so that they can be managed together.
In principle, there shouldn't anything that would keep the logical PPP device names from being "worldnet" or "myISP" instead of "ppp0" -- "pppN."
REMIP=addr, where addr is the remote IP address (which is normally unspecified).
MTU=value, where value is the value to be used as MTU.
MRU=value, where value is the value to be used as MRU.
DISCONNECTTIMEOUT=value, where value represents the number of seconds to wait before re-establishing the connection after a successfully-connected session terminated.
RETRYTIMEOUT=value, where value represents the number of seconds to wait before re-attempting to establish a connection after a previous attempt has failed.
This file is a chat script for PPP or SLIP connections, and is intended to establish the connection. For SLIP devices, a DIP script is written from the chat script; for PPP devices, the chat script is used directly.
This write-only script is created from the chat script by netcfg. Do not modify this file. In the future, this file may disappear and instead will be created on-the-fly from the chat script.
This file is called when any network device (except a SLIP device) comes up. Calls /etc/sysconfig/network-scripts/ifup-routes to bring up static routes that depend on that device. Brings up aliases for that device. Sets the hostname if it is not already set and a hostname can be found for the IP for that device. Sends SIGIO to any programs that have requested notification of network events.
Could be extended to fix up nameservice configuration, call arbitrary scripts, and more, as needed.
This file is called by dhcpcd once dhcp configuration is complete; sets up /etc/resolv.conf from the version dhcpcd dropped in /etc/dhcpc/resolv.conf.
This section is a brief description of the internals of the boot process. It basically covers in detail how the machine boots using SysV init, as well as the differences between the init used in older Linux releases, and SysV init.
Init is the program that gets run by the kernel at boot time. It is in charge of starting all the normal processes that need to run at boot time. These include the getty processes that allow you to log in, NFS daemons, FTP daemons, and anything else you want to run when your machine boots.
SysV init is quickly becoming the standard in the Linux world to control the startup of software at boot time. This is because it is easier to use and more powerful and flexible than the traditional BSD init.
SysV init also differs from BSD init in that the config files are in a subdirectory of /etc instead of residing directly in /etc. This directory is called rc.d. In there you will find rc.sysinit and the following directories:
init.d rc0.d rc1.d rc2.d rc3.d rc4.d rc5.d rc6.d |
init.d contains a variety of scripts. Basically, you reqiire one script for each service you may need to start at boot time or when entering another runlevel. Services include things like networking, nfs, sendmail, httpd, etc. Services do not include things like setserial that must only be run once and then exited. Things like that should go in rc.local or rc.serial.
If you want rc.local, it should be in /etc/rc.d. Most systems include one even though it doesn't do much. You can also include an rc.serial file in /etc/rc.d if you need to do serial port specific things at boot time.
The chain of events is as follows:
The kernel looks in several places for init and runs the first one it finds
init runs /etc/rc.d/rc.sysinit
rc.sysinit does a bunch of necessary things and then runs rc.serial (if it exists)
init runs all the scripts for the default runlevel.
init runs rc.local
The default runlevel is decided in /etc/inittab. You should have a line close to the top like:
id:3:initdefault: |
From this, you'd look in the second column and see that the default runlevel is 3. If you want to change it, you can edit /etc/inittab by hand and change the 3. Be very careful when you are messing with the inittab file. If you do mess up, you can fix it by rebooting and doing:
LILO boot: linux single |
This should allow you to boot into single user mode so you can fix inittab.
Now, how does it run all the right scripts? If you enter ls -l on rc3.d, you might see something like:
lrwxrwxrwx 1 root root 17 3:11 S10network -> ../init.d/network lrwxrwxrwx 1 root root 16 3:11 S30syslog -> ../init.d/syslog lrwxrwxrwx 1 root root 14 3:32 S40cron -> ../init.d/cron lrwxrwxrwx 1 root root 14 3:11 S50inet -> ../init.d/inet lrwxrwxrwx 1 root root 13 3:11 S60nfs -> ../init.d/nfs lrwxrwxrwx 1 root root 15 3:11 S70nfsfs -> ../init.d/nfsfs lrwxrwxrwx 1 root root 18 3:11 S90lpd -> ../init.d/lpd.init lrwxrwxrwx 1 root root 11 3:11 S99local -> ../rc.local |
What you'll notice is that there are no "real" files in the directory. Everything there is a link to one of the scripts in the init.d directory. The links also have an "S" and a number at the beginning. The "S" means to start this particular script and a "K" would mean to stop it. The number is there just for ordering purposes. Init will start all the services based on the order in which they appear. You can duplicate numbers, but it will only confuse you somewhat. You only need to use a two digit number, along with an upper case "S" or "K" to start or stop the services you require to.
How does init start and stop services? Simple. Each of the scripts is written to accept an argument which can be "start" and "stop". You can execute those scripts by hand, in fact, with a command like:
/etc/rc.d/init.d/httpd.init stop |
Why all these runlevels? Some people want an easy way to set up machines to be multi-purpose. You could have a "server" runlevel that just runs httpd, sendmail, networking, etc. Then you could have a "user" runlevel that runs xdm, networking, etc.
Generally, Red Hat Linux operates in run level 3 -- full multiuser mode. The following runlevels are defined in Red Hat Linux:
0 -- Halt
1 -- Single user mode
2 -- Multiuser mode, without NFS
3 -- Full multiuser mode
4 -- Not used
5 -- Full multiuser mode (with an X-based login screen)
6 -- Reboot
If your machine gets into a state where it will not boot due to a bad /etc/inittab, or will not let you log in because you have a corrupted /etc/passwd or have simply forgotten your password, boot into single user mode by typing linux 1 at the LILO boot prompt. A very bare system will come up and you will be given a shell from which you can fix things.
The chkconfig utility provides a simple command-line tool for maintaining the /etc/rc.d directory hierarchy. It relieves system administrators from having to directly manipulate the numerous symlinks in /etc/rc.d.
In addition, there is the ntsysv utility, that provides a screen-oriented interface, versus chkconfig's command-line interface.
Please see the chkconfig and ntsysv man pages for more information.
The file /etc/rc.d/rc.local is executed at boot time, after all other initialization is complete, and whenever you change runlevels. You can add additional initialization commands here. For instance, you may want to start up additional daemons, or initialize a printer. In addition, if you require serial port setup, you can edit /etc/rc.d/rc.serial, and it will be executed automatically at boot time.
The default /etc/rc.d/rc.local simply creates a nice login banner with your kernel version and machine type.
To shut down Red Hat Linux, issue the shutdown command. You can read the shutdown man page for complete details, but the two most common usages are:
shutdown -h now shutdown -r now |
Each will cleanly shutdown the system. After shutting everything down, the first will halt the machine, and the second will reboot.
Although the reboot and halt commands are now "smart" enough to invoke shutdown if run while the system is in runlevels 1-5, it is a bad habit to get into, as not all Linux-like operating systems have this feature.