Boot Process |
Server Training - Server Administration | ||||||||||||||||
The Boot ProcessThe boot process or bootstrapping is the process whereby your computer starts up. This is a time of potential problems as there is so little of the system working in this initial stage. Hardware issues must be resolved and configuration files must be correct in order to get the boot process to work. This is one of the reasons that much effort has gone into making the boot process automatic. You can do a manual boot from single user mode. Server Management ManualDownloadable PDF - $49.95
Server Management Manual is almost 500 pages of training with 25 Labs. This step by step manual will help you set up and manage a server. The manual is written for CentOS 5 (Red Hat Source Code). The topics in the manual include: boot process, root user, process management, managing the file system, managing users, managing quotas, managing system logs, managing hard drives, backups, automating actions,updates, networking, remote access with Webmin, VNC or SSH, kernel development, XWindow and server security. The manual is 11x8.5 ". This is lay flat spiral manual which is shipped. Includes 64 Flash movies with voice to demonstrate.
Here is a step by step event of a server booting. Power On BIOS Starts POST Hardware Probe Select boot Device Load and execute MBR Load/execute second stage of GRUB Load/execute kernel Hardware probe Mount Initial RAM disks Initialize Devices Mount root System Load/execute /sbin/init Select runlevel run the rc command run rc?.d/K* stop run rc?.d/S* start run kudzu run daemons text based logins start XWindow The BIOSThe BIOS is software that is placed on a ROM chip on the motherboard. The purpose of the BIOS is to interface between the hardware and the software that is on the system. The first thing the BIOS does is run a POST test, Power On Self-Test, to determine where the MBR is and what peripherals are connected to the machine. The CMOS,Complementary Metal Oxide Semiconductor, holds the hardware configuration stored on a chip that is saved even when the computer is turned off. The boot device is the Hard drive partition, CD-ROM, or USB device that holds the boot information. The BIOS will then execute the boot information which is usually found on the first physical sector of the boot device which is the MBR or Master Boot Record found on the first 512 bytes.
GRUBIntel based motherboards must be started with a 16-bit operating system because of a limitation to 640 kilobytes of RAM at startup. GRUB is used to interface with the 16-bit requirement and load the 32-bit Linux kernel. The AMD CMOS is 64-bit so it can load the 64-bit kernel for Linux. In order for GRUB to work it must use a two step process. The first step loads and executes the Master Boot record, which will then execute the second step which is a file located in /etc/grub. This second step reads the file in /boot/grub/grub.conf. Here is an example of menu.list found in /boot/grub. This example shows a CPU which has hyper-threading enabled for the CPU, showing two CPUs when there is actually one CPU. # grub.conf generated by anaconda # # Note that you do not have to rerun grub after making changes to this file # NOTICE: You have a /boot partition. This means that # all kernel and initrd paths are relative to /boot/, eg. # root (hd0,0) # kernel /vmlinuz-version ro root=/dev/md0 # initrd /initrd-version.img #boot=/dev/hda default=0 timeout=5 splashimage=(hd0,0)/grub/splash.xpm.gz hiddenmenu title Red Hat Enterprise Linux ES (2.6.9-34.ELsmp) root (hd0,0) kernel /vmlinuz-2.6.9-34.ELsmp ro root=/dev/md0 rhgb quiet initrd /initrd-2.6.9-34.ELsmp.img title Red Hat Enterprise Linux ES-up (2.6.9-34.EL) root (hd0,0) kernel /vmlinuz-2.6.9-34.EL ro root=/dev/md0 rhgb quiet initrd /initrd-2.6.9-34.EL.img
Note that the grub device name is hd0,0 which is the same as /dev/hda1. If you were going to install grub on /dev/hda1 the command would look like this: grub-install `(hd0,0)`
Warning: When you install a new kernel or update a kernel you should never remove the existing kernel until you know for sure the new kernel works. So you should use this command to install a kernel:
rpm -ivh kernel* The configuration shows that the default kernel to load is 0 which is the first one. If you wanted the default to be the second kernel you would change this to 1. The purpose of kernel is to provide control for the initial process after the root file system has been installed. This requires that device drivers be loaded for all of the devices. When GRUB activates the kernel it provides access to the initial RAM disk which is called /boot/initrd.x.y.z.img This initial RAM disk contains the drivers needed to mount a filesystem. Once the kernel has discovered and initialized hardware it mounts the root file system and initiates the /sbin/init. When the kernel completes the basic initialization it creates several spontaneous processes. They are called spontaneous because they were not created out of the normal system fork. Common Kernel Processes kjournald - ext3 journal updates to disk kswapd - swaps processes kreclaimd - reclaims memory pages not used for a while ksoftirqd - controls multiple layers of soft interrupts khubd - configure USB devices
Once the kernel has created the spontaneous processes it turns it all over to init.
/etc/inittab sets the default runlevel and then calls the script at /etc/rc.d/rc.sysinit which starts many of the necessary system tasks such as kernel parameters from /etc/sysctl.conf, system clock, keymaps, swap, hostname, executes root file system check and then mounts it r/w, activate RAID, start quotas, mounts file systems in /etc/fstab and then cleans up the PIDs and state locks that were set.
Init ProcessThe init process is the last process to occur during the boot process. init has the process id of “1”. init launches several copies of mingetty Ctrl+ALT+ F1-F6 so that they can be used to login on terminals. init also launches the Graphical Login in runlevel 5. The /etc/sysconfig/desktop file contains the preferred display manager which init launches in runlevel 5 as it selects the DISPLAYMANAGER variable. This section of the /etc/inittab shows how to setup the shutdown if power is lost.
# When our UPS tells us power has failed, assume we have a few minutes # of power left. Schedule a shutdown for 2 minutes from now. # This does, of course, assume you have powered installed and your # UPS connected and working correctly. pf::powerfail:/sbin/shutdown -f -h +2 "Power Failure; System Shutting Down"
# If power was restored before the shutdown kicked in, cancel it. pr:12345:powerokwait:/sbin/shutdown -c "Power Restored; Shutdown Cancelled"
Note that the init program is the first to run and has the PID of 1.
init─┬─acpid ─artsd ─atd ─bonobo-activati ─crond ─cups-config-dae ─cupsd ─2*[dbus-daemon-1] ─dbus-launch ─eggcups ─events/0─┬─aio/0
If the system has been started in single user mode by passing the word “single” to the kernel, init is made aware of this fact and waits for the user to load the system manually. If the file system has been loaded read only you will have to remount it as read/write to make changes. mount -o rw, remount /
A user can enter single user mode by using the command: telinit 1 or at GRUB spash screen a user can click “a” to append the selected kernel. Then simply add single to the end of the line:
grub append> ro root=LABEL=/ rhgb quiet single Now type b to boot into single user mode. Once the initialization scripts have completed, init must still spawn the getty processes so users can login. The getty process, or mingetty, controls the login on virtual terminals. The graphical logins xdm and gdm are also spawned by init. Startup ScriptsThe startup scripts perform a number of important tasks. These scripts set the computer name, time zone, check disks with fsck, mount disks, remove old files from /tmp, set up network interfaces and start daemons. One place to look for errors on startup is the dmesg file in /var/log.
DaemonsThe services run in specific runlevels. Each runlevel directory contains the services that run in that runlevel.
ls -la /etc/rc* lrwxrwxrwx 1 root root 7 Oct 12 2006 /etc/rc -> rc.d/rc lrwxrwxrwx 1 root root 10 Oct 12 2006 /etc/rc0.d -> rc.d/rc0.d lrwxrwxrwx 1 root root 10 Oct 12 2006 /etc/rc1.d -> rc.d/rc1.d lrwxrwxrwx 1 root root 10 Oct 12 2006 /etc/rc2.d -> rc.d/rc2.d lrwxrwxrwx 1 root root 10 Oct 12 2006 /etc/rc3.d -> rc.d/rc3.d lrwxrwxrwx 1 root root 10 Oct 12 2006 /etc/rc4.d -> rc.d/rc4.d lrwxrwxrwx 1 root root 10 Oct 12 2006 /etc/rc5.d -> rc.d/rc5.d lrwxrwxrwx 1 root root 10 Oct 12 2006 /etc/rc6.d -> rc.d/rc6.d lrwxrwxrwx 1 root root 13 Oct 12 2006 /etc/rc.local -> rc.d/rc.local lrwxrwxrwx 1 root root 15 Oct 12 2006 /etc/rc.sysinit -> rc.d/rc.sysinit
/etc/rc.d: total 136 drwxr-xr-x 10 root root 4096 Oct 12 2006 . drwxr-xr-x 82 root root 12288 May 21 07:53 .. drwxr-xr-x 2 root root 4096 Nov 1 2006 init.d -rwxr-xr-x 1 root root 2352 Mar 16 2004 rc drwxr-xr-x 2 root root 4096 Nov 1 2006 rc0.d drwxr-xr-x 2 root root 4096 Nov 1 2006 rc1.d drwxr-xr-x 2 root root 4096 Dec 21 12:49 rc2.d drwxr-xr-x 2 root root 4096 May 2 10:36 rc3.d drwxr-xr-x 2 root root 4096 Dec 21 12:49 rc4.d drwxr-xr-x 2 root root 4096 May 2 10:36 rc5.d drwxr-xr-x 2 root root 4096 Nov 1 2006 rc6.d -rwxr-xr-x 1 root root 220 Jun 23 2003 rc.local -rwxr-xr-x 1 root root 27799 Dec 15 2005 rc.sysinit init The whole init process sets up various levels of options for the server. The server runlevels are listed below.
/etc/inittab # ca::ctrlaltdel:/sbin/shutdown -t3 -r now Runlevels Linux has several levels or modes of operation called runlevels. These runlevels which are defined in /etc/inittab determine which user interfaces will be available as well as if the system will run allowing only one user or many users. Runlevels: 0 Turn the System Off Linux actually supports up to 10 runlevels but 7-9 are undefined at this time. The file /etc/inittab contains the configuration for runlevels and has the default runlevel for each system. When you view this file find this text to determine what the current runlevel is set at: # The default runlevel is defined here id:5:initdefault: The example shows that the default runlevel is 5, the Graphical User Interface with Multiuser mode and Networking. You would never want to set runlevels 0,4 or 6 in your inittab as this would make the system unusable. Runlevels could be changed in inittab or runlevels 3 and 5. The runlevel can also be determined by running this command at a terminal: /sbin/runlevel The return will be N with a number which will indicate the runlevel. The runlevel can be changed by using the init command with the desired runlevel as root: init 0 this will stop the system rc.d DirectoryThe rc.d directory is located at /etc/rc.d. In this directory are a series of directories that contain links to programs that run in different runlevels. The example shows the contents of /etc/rc.d/rc3.d The first thing you will notice about each of the items is that they are links to the init.d directory. The second thing you will notice is that each has a K or an S that it starts with. S means start and K means to stop. The system will run each of these scripts when it starts in the numeric number that exits. lrwxrwxrwx 1 root root 13 Dec 17 08:35 K20nfs → ../init.d/nfs This example shows that the nfs service will be turned off and that the order in which this script is run is number 20 (K20nfs) which means that it will be run before other scripts with higher numbers. [root@wk etc]# ls -la rc.d/rc3.d
Copyright CyberMontana Inc. and BeginLinux.com All rights reserved. Cannot be reproduced without written permission. Box 1262 Trout Creek, MT 59874
|