1 / 28

CIT 470: Advanced Network and System Administration

This CIT 470 course covers advanced booting techniques including BIOS initialization, MBR and bootloader operations, GRUB installation and configuration, kernel loading, and run levels.

hazellloyd
Télécharger la présentation

CIT 470: Advanced Network and System Administration

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Booting CIT 470: Advanced Network and System Administration CIT 470: Advanced Network and System Administration

  2. CIT 470: Advanced Network and System Administration Topics • Booting • Bootstrap loaders • Run levels • Startup scripts • Shutdown and reboot

  3. CIT 470: Advanced Network and System Administration Booting • ROM boot code (BIOS in PCs)‏ • Master Boot Record (MBR)‏ • Bootloader • Kernel • Hardware detection and configuration • Creation of system processes • Multiuser operation

  4. CIT 470: Advanced Network and System Administration BIOS • Load CMOS settings. • Initialize registers and power management. • POST (Power On Self Test.)‏ • Display system settings (if key pressed.)‏ • Activate other BIOSes Disk interfaces Graphics cards Network interfaces • Find bootable device. • Load MBR. • Run MBR program.

  5. CIT 470: Advanced Network and System Administration MBR 4 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.

  6. CIT 470: Advanced Network and System Administration Bootloader: GRUB Stage 1 (stored in MBR or boot sector)‏ • Initialize the system briefly. • Detect the geometry and the accessing mode of the loading drive. • Load the first sector of Stage 2. • Jump to the starting address of the Stage 2. Stage 1.5 (stored in sectors of MBR track)‏ One version for each filesystem. Loads stage 2 from filesystem. Stage 2 (stored in filesystem)‏ Displays menu of OS choices. Often displays boot splashscreen. Loads selected OS kernel.

  7. CIT 470: Advanced Network and System Administration GRUB Installation At OS Install Time Most distributions install GRUB. Linux Install grub-install /dev/hda Native install Boot with CD and run grub. #>> root (hd0,0)‏ #>> setup (hd0)‏ #>> quit

  8. CIT 470: Advanced Network and System Administration GRUB Boot • Automatically 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.

  9. CIT 470: Advanced Network and System Administration Booting with GRUB Direct Boot Specify OS kernel image to load. Chainloading Specify another bootloader to load. Chainload NTLDR to boot MS Windows.

  10. CIT 470: Advanced Network and System Administration Config: /boot/grub/menu.lst # timeout (sec) before booting default timeout 10 title Ubuntu, kernel 2.6.10-5-386 root (hd1,0)‏ kernel /boot/vmlinuz-2.6.10-5-386 root=/dev/hde1 ro quiet splash initrd /boot/initrd.img-2.6.10-5-386 boot title Windows 2000 root (hd0,0)‏ makeactive chainloader +1

  11. CIT 470: Advanced Network and System Administration GRUB Naming Convention GRUB uses BIOS hard disk numbers OS may not number disks identically to BIOS. Examples (hd0,0) First partition of first hard disk (hd1,2) Third partition of second hard disk.

  12. CIT 470: Advanced Network and System Administration Kernel • GRUB loads kernel file into memory /boot/vmlinuz-VERSION • Kernel uncompresses self and begins running. • Sets up interrupts and virtual memory. • Loads initial RAMdisk into memory /boot/initrd.img-VERSION • Kernel ncompress initrd and mounts as /sysroot. • Kernel loads drivers and modules from /sysroot. SCSI and RAID drivers, ext3 filesystem module, etc. • Switches from real mode to protected mode. • Creates kernel threads (ksoftirq, khelper, kblockd)‏ • Starts init process.

  13. CIT 470: Advanced Network and System Administration Kernel Arguments Numeric arguments • Specify runlevel. • single also specifies single user mode Root device options • root= specifies which root device to use • ro, rw specify access type Console options • console=ttyS1,9600 will use serial console Hardware options • Enable, disable specific hardware devices/features.

  14. CIT 470: Advanced Network and System Administration Run Levels 0 – Shutdown 1 – Single user 2 – Multi-user, no networking 3 – Multi-user, with networking 4 – Unused 5 – Multi-user, networking, and GUI 6 – Reboot

  15. CIT 470: Advanced Network and System Administration /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 change l0:0:wait:/etc/init.d/rc 0 l1:1:wait:/etc/init.d/rc 1 l2:2:wait:/etc/init.d/rc 2 l3:3:wait:/etc/init.d/rc 3 l4:4:wait:/etc/init.d/rc 4 l5:5:wait:/etc/init.d/rc 5 l6: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

  16. CIT 470: Advanced Network and System Administration rc • Executed 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.

  17. CIT 470: Advanced Network and System Administration Scripts in runlevel 2 $ ls /etc/rc2.d S05vbesave S13gdm S20openntpd S89cron S08iptables S18hplip S20postfix S91apache2 S10acpid S18portmap S20powernowd S98usplash S10powernowd.early S19cupsys S20rsync S99acpi-support S10sysklogd S20apmd S20ssh S99rc.local S10syslog-ng S20argus-server S20xinetd S99rmnologin S11klogd S20hotkey-setup S21nfs-common S99stop-readahead S12dbus S20makedev S89anacron

  18. CIT 470: Advanced Network and System Administration 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

  19. CIT 470: Advanced Network and System Administration Turning Services On/Off Add a new service Install startup script in /etc/init.d Create S symlinks in appropriate runlevels Create K symlinks in appropriate runlevels Prevent a service from starting on boot Remove S links from /etc/rc?.d/* Remove K links from /etc/rc?.d/*

  20. CIT 470: Advanced Network and System Administration Red Hat Service Commands Starting or stopping a service service NAME [start,restart,stop] is equivalent to /etc/init.d/NAME [start,restart,stop] Enabling or disabling a service at boot time chkconfig --level # NAME is equivalent to ln –s /etc/init.d/NAME /etc/init.d/rc.d/rc#.d/S??name

  21. CIT 470: Advanced Network and System Administration Single User Mode Kernel boots (with arg 1 or “single”)‏ System asks for root password Root shell starts No system processes No networking Only root filesystem mounted (read-only). Remount for RW: mount –o remount,rw / Why? Fix w/o user interference: disks, backups, security.

  22. CIT 470: Advanced Network and System Administration What if single user mode doesn’t work? Bypass init by booting into shell Pass 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

  23. CIT 470: Advanced Network and System Administration Shutdown shutdown (or init 0)‏ Offers time-delay option. Runs server stop scripts. Kill remaining processes. Flushes writes to disk. halt Kills processes. Flushes writes to disk (sync).

  24. CIT 470: Advanced Network and System Administration Reboot init 6 shutdown restarts system Ctrl-Alt-Del Defined in /etc/inittab ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now reboot halt restarts system

  25. CIT 470: Advanced Network and System Administration 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?

  26. CIT 470: Advanced Network and System Administration 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.

  27. CIT 470: Advanced Network and System Administration 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

  28. CIT 470: Advanced Network and System Administration References • Aeleen Frisch, Essential System Administration, 3rd edition, O’Reilly, 2002. • M. Tim Jones, “Inside the Linux boot process,” http://www.ibm.com/developerworks/library/l-linuxboot/index.html, 2006. • M. Tim Jones, “Parallelize applications for faster Linux booting,” http://www.ibm.com/developerworks/linux/library/l-boot-faster/index.html, 2007. • Evi Nemeth et al, UNIX System Administration Handbook, 3rd edition, Prentice Hall, 2001. • Scott James Remnant, “Upstart in Universe,” http://www.netsplit.com/2006/08/26/upstart-in-universe/, 2006. • Starman, “Boot records revealed: MBR details,” http://mirror.href.com/thestarman/asm/mbr/index.html • “Extended boot record,” http://en.wikipedia.org/wiki/Extended_Boot_Record. • GRUB manual, http://www.gnu.org/software/grub/manual/grub.html • “How it works: Master Boot Record (MBR),” http://www.ata-atapi.com/hiwmbr.htm • “Replacement Init”, https://wiki.ubuntu.com/ReplacementInit

More Related