cit 500: it fundamentals
DESCRIPTION
CIT 500: IT Fundamentals. Startup. Topics. Booting Bootstrap loaders Run levels Startup scripts Shutdown and reboot. Booting. ROM boot code (BIOS in PCs) Master Boot Record (MBR) Bootloader Kernel Hardware detection and configuration Creation of system processes - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: CIT 500: IT Fundamentals](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813ff1550346895dab058f/html5/thumbnails/1.jpg)
CIT 500: IT Fundamentals
Startup
![Page 2: CIT 500: IT Fundamentals](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813ff1550346895dab058f/html5/thumbnails/2.jpg)
Slide #2
Topics
1. Booting2. Bootstrap loaders3. Run levels4. Startup scripts5. Shutdown and reboot
![Page 3: CIT 500: IT Fundamentals](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813ff1550346895dab058f/html5/thumbnails/3.jpg)
Slide #3
Booting
1. ROM boot code (BIOS in PCs)2. Master Boot Record (MBR)3. Bootloader4. Kernel5. Hardware detection and configuration6. Creation of system processes7. Multiuser operation
![Page 4: CIT 500: IT Fundamentals](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813ff1550346895dab058f/html5/thumbnails/4.jpg)
Slide #4
BIOS1. Load CMOS settings.2. Initialize registers and power management.3. POST (Power On Self Test.)4. Display system settings (if key pressed.)5. Activate other BIOSes
Disk interfacesGraphics cardsNetwork interfaces
6. Find bootable device.7. Load MBR.8. Run MBR program.
![Page 5: CIT 500: IT Fundamentals](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813ff1550346895dab058f/html5/thumbnails/5.jpg)
MBR4 primary partitions.
One can be used as an extended partition, which is a link to an Extended boot record on the 1st sector of that partition.Each logical partition is described by its own EBR, which links to the next EBR.
![Page 6: CIT 500: IT Fundamentals](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813ff1550346895dab058f/html5/thumbnails/6.jpg)
Slide #6
GRUB InstallationAt OS Install Time
Most distributions install GRUB.
Linux Installgrub-install /dev/hda
Native installRun grub command from live CD or hard disk.#>> root (hd0,0)
#>> setup (hd0)
#>> quit
![Page 7: CIT 500: IT Fundamentals](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813ff1550346895dab058f/html5/thumbnails/7.jpg)
Slide #7
GRUB Boot
• Auto boots default OS after timeout.• Key sequences bring up– Menu of boot options (described in menu.lst)– Edit kernel options (runlevel, other features)– GRUB command shell
• A boot prompt password may be required before edit/shell access granted.– Can bypass OS security by specifying kernel
options or accessing files from GRUB shell.
![Page 8: CIT 500: IT Fundamentals](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813ff1550346895dab058f/html5/thumbnails/8.jpg)
GRUB Menu
![Page 9: CIT 500: IT Fundamentals](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813ff1550346895dab058f/html5/thumbnails/9.jpg)
GRUB Edit Menu
![Page 10: CIT 500: IT Fundamentals](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813ff1550346895dab058f/html5/thumbnails/10.jpg)
Slide #10
/boot/grub/menu.lst# timeout (sec) before booting defaulttimeout 10
title CentOS (2.6.18-128.el5)root (hd1,0)kernel /boot/vmlinuz-2.6.18-128.el5
root=/dev/hdb1 ro rhgb quietinitrd /boot/initrd-2.6.18-128.el5.imgboot
title Windows 2008root (hd0,0)makeactivechainloader +1
![Page 11: CIT 500: IT Fundamentals](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813ff1550346895dab058f/html5/thumbnails/11.jpg)
Slide #11
Booting with GRUB
Direct BootSpecify OS kernel image to load.
ChainloadingSpecify another bootloader to load.Chainload NTLDR to boot MS Windows.
![Page 12: CIT 500: IT Fundamentals](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813ff1550346895dab058f/html5/thumbnails/12.jpg)
GRUB Naming Convention
GRUB uses BIOS hard disk numbersOS may not number disks identically to BIOS.
Examples(hd0,0) First partition of first hard disk(hd1,2) Third partition of second hard disk.
![Page 13: CIT 500: IT Fundamentals](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813ff1550346895dab058f/html5/thumbnails/13.jpg)
Kernel1. GRUB loads kernel file into memory
/boot/vmlinuz-VERSION2. Kernel uncompresses self and begins running.3. Sets up interrupts and virtual memory.4. Loads initial RAMdisk into memory
/boot/initrd.img-VERSION5. Kernel uncompresses initrd and mounts as /sysroot.6. Kernel loads drivers and modules from /sysroot.
SCSI and RAID drivers, ext3 filesystem module, etc.7. Switches from real mode to protected mode.8. Creates kernel threads (ksoftirq, khelper, kblockd)9. Starts init process.
![Page 14: CIT 500: IT Fundamentals](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813ff1550346895dab058f/html5/thumbnails/14.jpg)
Kernel Arguments in GRUB
![Page 15: CIT 500: IT Fundamentals](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813ff1550346895dab058f/html5/thumbnails/15.jpg)
Slide #15
Kernel ArgumentsNumeric arguments
Specify runlevel.single also specifies single user mode
Root device optionsroot= specifies which root device to usero, rw specify access type
Console optionsconsole=ttyS1,9600 will use serial console
Hardware optionsEnable, disable specific hardware devices/features.
![Page 16: CIT 500: IT Fundamentals](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813ff1550346895dab058f/html5/thumbnails/16.jpg)
Slide #16
Run Levels
0 – Shutdown1 – Single user2 – Multi-user, no networking3 – Multi-user, with networking4 – Unused5 – Multi-user, networking, and GUI6 – Reboot
![Page 17: CIT 500: IT Fundamentals](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813ff1550346895dab058f/html5/thumbnails/17.jpg)
/etc/inittab# The default runlevel.id:2:initdefault:
# Boot-time system configuration/initialization script.si::sysinit:/etc/init.d/rcS
# What to do in single-user mode.~~:S:wait:/sbin/sulogin
# /etc/init.d executes the S and K scripts upon changel0:0:wait:/etc/init.d/rc 0l1:1:wait:/etc/init.d/rc 1l2:2:wait:/etc/init.d/rc 2l3:3:wait:/etc/init.d/rc 3l4:4:wait:/etc/init.d/rc 4l5:5:wait:/etc/init.d/rc 5l6:6:wait:/etc/init.d/rc 6
# What to do when CTRL-ALT-DEL is pressed.ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now
![Page 18: CIT 500: IT Fundamentals](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813ff1550346895dab058f/html5/thumbnails/18.jpg)
rc• Run by init with runlevel as argument.• Starts and stops services for each runlevel.• /etc/rc#.d scripts– Symlinks to actual scripts in /etc/init.d– Stops services beginning with K*– Starts services beginning with S*– Executes in ASCII order.
![Page 19: CIT 500: IT Fundamentals](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813ff1550346895dab058f/html5/thumbnails/19.jpg)
Scripts in runlevel 2$ ls /etc/rc2.dS05vbesave S13gdm S20openntpd S89cronS08iptables S18hplip S20postfix S91apache2S10acpid S18portmap S20powernowd S98usplashS10powernowd.early S19cupsys S20rsync S99acpi-supportS10sysklogd S20apmd S20ssh S99rc.localS10syslog-ng S20argus-server S20xinetd S99rmnologinS11klogd S20hotkey-setup S21nfs-common S99stop-readaheadS12dbus S20makedev S89anacron
![Page 20: CIT 500: IT Fundamentals](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813ff1550346895dab058f/html5/thumbnails/20.jpg)
Slide #20
Example init.d script#! /bin/sh case "$1" in
'start') if [ -f /usr/local/sbin/sshd ]; then
echo "starting SSHD daemon" /usr/local/sbin/sshd &
fi;;
'stop')PID=`/usr/bin/ps -e -u 0 | /usr/bin/fgrep sshd |
/usr/bin/awk '{print $1}'` if [ ! -z "$PID" ] ; then
/usr/bin/kill ${PID} >/dev/null 2>&1 fi ;;
*) echo "usage: /etc/init.d/sshd {start|stop}“;;
esac
![Page 21: CIT 500: IT Fundamentals](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813ff1550346895dab058f/html5/thumbnails/21.jpg)
Slide #21
Enabling or Disabling Services
Add a new serviceInstall startup script in /etc/init.dCreate S symlinks in appropriate runlevelsCreate K symlinks in appropriate runlevels
Prevent a service from starting on bootRemove S links from /etc/rc?.d/*Remove K links from /etc/rc?.d/*
![Page 22: CIT 500: IT Fundamentals](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813ff1550346895dab058f/html5/thumbnails/22.jpg)
Slide #22
Red Hat service Command
Starting or stopping a serviceservice NAME [start,restart,stop]
is equivalent to/etc/init.d/NAME [start,restart,stop]
Service command options:start
restart
stop
status
Use command without any options to get help message with all available options.
![Page 23: CIT 500: IT Fundamentals](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813ff1550346895dab058f/html5/thumbnails/23.jpg)
Slide #23
Red Hat chkconfig Command
List configured serviceschkconfig
Enabling or disabling a service at boot timechkconfig --level # NAME
is equivalent toln –s /etc/init.d/NAME /etc/init.d/rc.d/rc#.d/S??name
Adding or removing a service entirelychkconfig --level
![Page 24: CIT 500: IT Fundamentals](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813ff1550346895dab058f/html5/thumbnails/24.jpg)
Red Hat Service Configuration
Red Hat Linuxes use files in /etc/sysconfigVARIABLE=value formatDocumentation in RHEL manuals
Examplesdesktop: select GNOME, KDE, XFCE desktopiptables: firewall configurationnetwork: hostname, gateway routernetwork-scripts/ifcfg-eth0: eth0 config
![Page 25: CIT 500: IT Fundamentals](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813ff1550346895dab058f/html5/thumbnails/25.jpg)
Slide #25
Single User Mode
Kernel boots (with arg 1 or “single”)System asks for root passwordRoot shell starts
No system processesNo networking
Only root filesystem mounted (read-only).Remount for RW: mount –o remount,rw /
Why?Fix w/o user interference: disks, backups, security.
![Page 26: CIT 500: IT Fundamentals](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813ff1550346895dab058f/html5/thumbnails/26.jpg)
Slide #26
What if single user mode doesn’t work?
Bypass init by booting into shellPass init=/bin/bash argument to kernel.Probably want to specify rw option as well.No need for root password.No housekeeping performed.
Boot from CD RedHat CD with linux rescue Knoppix CD
![Page 27: CIT 500: IT Fundamentals](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813ff1550346895dab058f/html5/thumbnails/27.jpg)
Slide #27
Shutdown
shutdown (or init 0)Offers time-delay option.Runs server stop scripts.Kill remaining processes.Flushes writes to disk.
haltKills processes.Flushes writes to disk (sync).
![Page 28: CIT 500: IT Fundamentals](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813ff1550346895dab058f/html5/thumbnails/28.jpg)
Slide #28
Reboot
init 6shutdown
restarts system
Ctrl-Alt-DelDefined in /etc/inittabca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now
reboothalt
restarts system
![Page 29: CIT 500: IT Fundamentals](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813ff1550346895dab058f/html5/thumbnails/29.jpg)
Slide #29
What's wrong with init?Performance
– Starts services sequentially.– Shell scripts spawn lots of processes.
Manual configuration– Order to start services determined manually.– i.e. network before auth before nfs.
Reliability– Init doesn’t monitor or restart services after boot.
Hotplug hardware– Drives mounted at boot.– What about USB or network drives?
![Page 30: CIT 500: IT Fundamentals](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813ff1550346895dab058f/html5/thumbnails/30.jpg)
Slide #30
Init Alternatives
iniNG– Service config specifies dependencies.– need = system/initial net/all; – Starts services in parallel once dependencies met.
launchd– Mac replacement for init, rc, cron, atd, inetd– Monitors services, starts on demand.
Service Management Facility– Sun replacement for init with service monitoring.
![Page 31: CIT 500: IT Fundamentals](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813ff1550346895dab058f/html5/thumbnails/31.jpg)
Upstart
• Event-based init replacement.• Supports wider range of events than launchd.– Hardware device has been added.– Filesystem has been mounted.– Time-based (can replace cron as well as init.)– File has been modified.– Another job has begun or finished running.
• Backwards compatible with /etc/init.d scripts.• Respawns services that are down.• Used in Ubuntu >= 6.10, Fedora >= 9
![Page 32: CIT 500: IT Fundamentals](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813ff1550346895dab058f/html5/thumbnails/32.jpg)
References
1. Red Hat, RHEL Installation Guide, http://www.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/5.4/html/Installation_Guide/index.html, 2009.
2. Syed Mansoor Sarwar, Robert Koretsky, Syed Ageel Sarwar, UNIX: The Textbook, 2nd edition, Addison-Wesley, 2004.
3. Nicholas Wells, The Complete Guide to Linux System Administration, Thomson Course Technology, 2005.