Linux 2-1 1-2 CPU and Memory 1-3 1-4 RAID Software RAID Lab Installing RedHat Linux and Implementing Software RAID Linux F4 ( Files 4 ) lilo.conf grub.conf inittab fstab service chkconfig 2-1 Linux 2-1 Linux 4 1. /etc/lilo.conf 2. /boot/grub/grub.conf 3. /etc/inittab 4. /etc/fstab Linux F4. 2-1 Linux BIOS MBR Partition Kernel Image Read-Only mount / filesystem
Process init init /etc/inittab id:initdefault: runlevel runlevel /etc/rc.sysinit /etc/fstab mount filesystems runlevel /etc/r.d/rc$runlevel.d/ script runlevel 5 /etc/x11/prefdm /etc/sysconfig/desktop
2-1 Linux 2-2 GRUB vs. LILO Redhat Linux Boot Loader GRUB ( Grand Inified Boot-loader ) LILO ( Linux Loader ) GRUB LILO Partition Linux Kernel Image Read-Only mount / filesystem process init LILO GRUB 1st Stage MBR 446bytes boot Sector 2nd Stage boot partition Kernel Image Read-Only mount / filesystem, init
2-2 Boot Loader 2-2-1 GRUB LILO 3-1 GRUB LILO 2-1 GRUB LILO GRUB Default Boot Loader /boot/grub/grub.conf grub-install /dev/hda reinstall GRUB LILO Boot Loader /etc/lilo.conf lilo reinstall LILO lilo t test lilo.conf configuration lilo v install LILO or update configuration lilo u
restore the MBR backup grub.conf lilo.conf lilo Single User Mode Space a 1 Enter Ctrl+X linux 1 GRUB LILO cp /etc/lilo.conf.anaconda lilo timeout 0.1 sec LILO GRUB grub-intall /dev/had timeout 1 sec default label default label hd(0,0) partition root root Single Model GRUB LILO Singel User Mode GRUB Single Mode. GRUB
2-3 GRUB 2. a kernel LABEL=/ 1 b Boot
2-4 GRUB kernel arguments 3. password 2-5 Singel User Mode LILO Single Mode 1. Ctrl-X text Mode 2-6 LILO 2. linux 1 Single User Mode 2-7 LILO Text Mode
MBR MBR 446 bytes boot loader GRUB LILO MBR 446 bytes dd if=/dev/zero of=/dev/had bs=446 count=1 MBR BIOS 3-8 3-9 2-8 BIOS 2-9 MBR 3-9
-- MBR Rescue Mode Rescue Mode. CD boot: linux rescue 2-10 Rescue Mode
2-11 2-12 KeyBoard Type
2-13 2-14
2. Rescue Mode chroot /mnt/sysimage grub-install /dev/hda exit exit 2-15 2-16
2-2-2 /boot/grub/grub.conf # 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/hda2 # initrd /initrd-version.img #boot=/dev/hda default=0 timeout=10 splashimage=(hd0,0)/grub/splash.xpm.gz password --md5 $1$gE6Ok/$6vYAf6vYhmf6D2VJqXSIf0 # grub ---------------------------- Label =0 ---------------------------- title Red Hat Linux (2.4.18-14) root (hd0,0) (hd0,0) / kernel /vmlinuz-2.4.18-14 ro root=label=/ initrd /initrd-2.4.18-14.img ---------------------------- Label =1 ---------------------------- title Windows 2000 rootnoverify (hd0,1) # Windows 2000 partition chainloader +1 default=0 (hd0,0) BIOS H.D /boot/grub/device.map (hd0,0) hda1 # this device map was generated by anaconda (fd0) /dev/fd0
(hd0) /dev/hda root (hd0,0) (hd0,0) partition ( grub partition ) / kernel /vmlinuz-2.4.18-14 kernel image / Linux Filesystem /boot ro root=label=/ Read-Only mount Label / partiton Linux / Filesystm root root (hd0,0) root initrd /initrd-2.4.18-14.img Initial RAM disk Initial RAM disk Linux Kernel Image SCSI Software RAID Driver Initial RAM disk image file GRUB Password grub.conf password --md5 $1$gE6Ok/$6vYAf6vYhmf6D2VJqXSIf0 grub $1$gE6Ok/$6vYAf6vYhmf6D2VJqXSIf0 1234 grub-md5-crypt copy password --md5 Single User Mode 1234 [root@rhce root]#grub-md5-crypt Password: 1234 Enter $1$gE6Ok/$6vYAf6vYhmf6D2VJqXSIf0 [root@rhce root]# / filesytem Boot Loader read-only mount / filesystem / init grub.conf kernel /vmlinuz-2.4.18-14 ro root=label=/ kernel /vmlinuz-2.4.18-14 ro root=label=\ init 2-17
2-17 / filesystem 2-2-3 /etc/lilo.conf grub.conf lilo.conf prompt timeout=50 default=linux boot=/dev/hda map=/boot/map # 0.1 # Laeble =Linux # first stage loader MBR # map file install=/boot/boot.b # second loader message=/boot/message linear password redhat restricted # password # password restricted LILO parameter password ( Single User Mode) ########## Laeble =Linux ########## image=/boot/vmlinuz-2.4.18-14 # kernel image label=linux
initrd=/boot/initrd-2.4.18-14.img c read-only append="root=label=/" # Read-Only mount / filesystem ########## Laeble =Windows 2000 ########## other=/dev/hda2 label=windows 2000 /boot/boot.b LILO /boot/boot.b /boot/map kernel kernel /boot/map kernel /boot/boot.b //boot/map rename kernel /boot/map /boot/map kernel label linux Windows 2000 sector 3-3 /etc/inittab process init /etc/inittab script inittab runlevle runlevel runlevel [root@rhce root]# runlevel N 5 inittab
/etc/inittab RHCE # # inittab This file describes how the INIT process should set up # the system in a certain run-level. # # Author: Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org> # Modified for RHS Linux by Marc Ewing and Donnie Barnes # # Default runlevel. The runlevels used by RHS are: # 0 - halt (Do NOT set initdefault to this) # 1 - Single user mode # 2 - Multiuser, without NFS (The same as 3, if you do not have networking) # 3 - Full multiuser mode # 4 - unused # 5 - X11 # 6 - reboot (Do NOT set initdefault to this) # id:5:initdefault: runlevel ( ) # System initialization. si::sysinit:/etc/rc.d/rc.sysinit runlevel rc.sysinit l0:0:wait:/etc/rc.d/rc 0 l2:2:wait:/etc/rc.d/rc 2 l3:3:wait:/etc/rc.d/rc 3 l4:4:wait:/etc/rc.d/rc 4 l5:5:wait:/etc/rc.d/rc 5 l6:6:wait:/etc/rc.d/rc 6 runlevel /etc/rc.d/rc.d/* # Things to run in every runlevel. ud::once:/sbin/update # Trap CTRL-ALT-DELETE ca::ctrlaltdel:/sbin/shutdown -t3 -r now Virtual Console CTRL-ALT-DELETE
# 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 powerd 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" # Run gettys in standard runlevels 1:2345:respawn:/sbin/mingetty tty1 2:2345:respawn:/sbin/mingetty tty2 3:2345:respawn:/sbin/mingetty tty3 4:2345:respawn:/sbin/mingetty tty4 5:2345:respawn:/sbin/mingetty tty5 6:2345:respawn:/sbin/mingetty tty6 6 Virtual Console # Run xdm in runlevel 5 # xdm is now a separate service x:5:respawn:/etc/x11/prefdm -nodaemon runlevel 5 prefdm /etc/rc.sysinit runlevel script Sets kernel parameters in /etc/sysctl.conf Sets the system clock Loads keymaps Enables swap partitions Sets hostname Root filesystem check and mount Add RAID devise Enable disk quotas Check and mount other filesystems Cleans up stale locks and PID diles /etc/fstab mount filesystems /etc/inittab
l0:0:wait:/etc/rc.d/rc 0 l2:2:wait:/etc/rc.d/rc 2 l3:3:wait:/etc/rc.d/rc 3 l4:4:wait:/etc/rc.d/rc 4 l5:5:wait:/etc/rc.d/rc 5 l6:6:wait:/etc/rc.d/rc 6 runlevel 3 /etc/rc.d/rc3.d/ /etc/rc.d/rc /etc/rc.d/rc # Is there an rc directory for this new runlevel? [-d/etc/rc$runlevel.d] exit 0 # First, run the KILL scripts. for i in /etc/rc$runlevel.d/k* ; do K Scripts check_runlevel "$i" continue # Check if the subsystem is already up. subsys=${i#/etc/rc$runlevel.d/k??} [ -f /var/lock/subsys/$subsys -o -f /var/lock/subsys/$subsys.init ] \ continue done # Bring the subsystem down. if egrep -q"(killproc action )" $i ; then $i stop else action $"Stopping $subsys: " $i stop fi # Now run the START scripts. for i in /etc/rc$runlevel.d/s* ; do S Scripts check_runlevel "$i" continue # Check if the subsystem is already up. subsys=${i#/etc/rc$runlevel.d/s??} [ -f /var/lock/subsys/$subsys -o -f /var/lock/subsys/$subsys.init ] \
&& continue # If we're in confirmation mode, get user confirmation if [-n"$confirm"]; then confirm $subsys case $? in 0) :;; 2) CONFIRM=;; *) continue;; esac fi done # Bring the subsystem up. if [ "$subsys" = "halt" -o "$subsys" = "reboot" ]; then unset LANG unset LC_ALL exec $i start fi if egrep -q "(daemon action )" $i 2>/dev/null \ [ "$subsys" = "single" -o "$subsys" = "local" ]; the $i start else action $"Starting $subsys: " $i start fi runlevel /etc/rc.d/rc?.d/ scripts K S Scripts S scripts K scripts # ls l /etc/rc.d/rc*.d/k* more # ls l /etc/rc.d/rc*.d/s* more
2-18 ls l /etc/rc.d/rc*.d/k* more 2-19 ls l /etc/rc.d/rc*.d/s* more /etc/rc.d/rc*.d/ scripts link /etc/rc.d/init.d K* ( Kill ) link service S* ( Start ) link service
/etc/rc.d/init.d/ Scripts System V Startup Scripts runlevel /etc/rc.local Ans : ls l /etc/rc.d/rc*.d/*local runlevel 2~5 Start Link /etc/rc.local runlevel 2~5 /etc/rc.local 2-4 Linux Services Linux services init services ( mingetty Virtual Cosole ) System V Startup Scripts ( /etc/init.d/* scripts atd crond httpd xinetd services ( telnet wu-ftpd ipop3 ) System V xinetd chkconfig services 2-2 service chkconfig service System V chkconfig System V chkconfig xinetd service runlevel on/off xinetd System V servie services # service httpd start httpd server # service httpd stop httpd server # service httpd restart httpd server # service httpd status www server # chkconfig httpd on # chkconfig telnet runlevel 3,4,5 on httpd server # chkconfig httpd off runlevel 3,4,5 httpd server # chkconfig httpd - - list runlevel httpd server # chkconfig - - list runlevel System V services # chkconfig httpd - -del runlevel
httpd # chkconfig httpd - -add runlevel httpd