Presentation is loading. Please wait.

Presentation is loading. Please wait.

Booting and Shuting Down WeeSan Lee. Roadmap Bootstrapping Boot Loaders Startup/Init Scripts Reboot & Shutdown Q&A.

Similar presentations


Presentation on theme: "Booting and Shuting Down WeeSan Lee. Roadmap Bootstrapping Boot Loaders Startup/Init Scripts Reboot & Shutdown Q&A."— Presentation transcript:

1 Booting and Shuting Down WeeSan Lee

2 Roadmap Bootstrapping Boot Loaders Startup/Init Scripts Reboot & Shutdown Q&A

3 Bootstrapping (simplified version) BIOSBoot LoaderKernel Initialization init Runs scripts from /etc/rc[0-6].d/ Spawns getty processes login Spawns Xdm/gdm processes login

4 BIOS Basic Input/Output System Contains information about the machine’s configuration. Eg. IDE controller, NIC PC knows which device to boot from via BIOS PC tries to run code from the MBR, ie. 1 st 512 bytes, of the disk MBR tells the PC to load the boot loader from certain disk partition The boot loader loads the kernel

5 Boot Loaders - LILO Traditional and stable /etc/lilo.conf  boot=/dev/hda  root=/dev/hda1  timeout=5  image=/boot/vmlinuz  label=Linux  read-only  other=/dev/hdb1  label=Windows  table=/dev/hdb To install it  $ lilo lilo must be run after every reconfiguration

6 Boot Loaders – LILO (cont) At LILO prompt  LILO: linux init=/sbin/init  LILO: linux init=/bin/bash  LILO: linux root=/dev/hda5  LILO: linux single

7 Boot Loaders – GRUB GRand Unified Boot loader Default on Red Hat and SuSe Read configuration file at boot time Understand filesystems and kernel executable formats  ie. Only need to know the device, disk partition and kernel filename  GRUB device (hd0,0) → /dev/hda1 or /dev/sda1 To install GRUB (for the very first time)  $ grub-install ‘(hd0,0)’  Edit /boot/grub/grub.conf

8 Boot Loaders – GRUB (cont) /boot/grub/grub.conf  default=0  timeout=5  splashimage=(hd0,0)/boot/grub/splash.xpm.gz  title CentOS ( el5)  root (hd0,0)  kernel /boot/vmlinuz el5 ro root=LABEL=/  initrd /boot/initrd el5.img  title Windows  rootnoverify (hd1,0)  chainloader +1

9 Boot Loaders – GRUB (cont) At the splash screen  Hit ‘a’ and type “ single” to boot to single-user mode  Hit ‘c’ to enter command-line mode To boot other OSes that aren’t in grub.conf Display system information Press TAB to see possible commands

10 Kernel Initialization A program itself  /vmlinuz or /boot/vmlinuz Two-stage loading process  initrd (init RAM disk) A transient root filesystem in RAM before a real root filesystem is available Eg. It is used to install file system modules into the kernel  The real root filesystem Device detection and configuration  You tell the kernel what to expect  The kernel probes the H/W itself Kernel threads creation  Eg. init (a user process), kjournald, kswapd

11 Single-user mode A manual mode after kernel initialization and before running startup scripts “single” is passed to init, sulogin is run instead Most system processes are not running Users can’t log in, except root / is mounted read-only  $ mount -o rw,remount / Check/repair the disk if there are disk problems  $ fsck -y /dev/sda1 Run ‘exit’ to exit single-user mode

12 Startup/Init Scripts After Kernel initialization, a process called init is created with PID 1 init runs startup scripts (normal shell scripts) to perform specific tasks, eg.  Setting the hostname, time zone, etc  Checking and mouting the disks  Configuring network interfaces  Starting up daemons and network services

13 Startup/Init Scripts (cont) Startup scripts (rc files) are run based on run levels  0the level in which the system is completely shut down  1single-user mode  2multiuser mode w/out NFS  3full multiuser mode  4unused  5X11  6reboot level Starts with run level 0 to the default run level (usually 3) /etc/inittab tells init what to do at each level To find out which run level the system is current in  $ runlevel

14 Startup/Init Scripts (cont) init runs the scripts from /etc/rc.d/rc[0-6].d/  /etc/rc.d/rc0/K25sshd → /etc/init.d/sshd  /etc/rc.d/rc3/S55sshd → /etc/init.d/sshd Each server/daemon provides a master script  Stored in /etc/init.d  Understands the arguments: start, stop, restart /etc/init.d/sshd start run level 0 → 3  /etc/rc.d/rc3/S* start run level 3 → 0  /etc/rc.d/rc0/K* stop Pretty ugly!

15 Startup/Init Scripts (cont) Use chkconfig instead. Eg.  $ chkconfig --add sshd  $ chkconfig --del sshd Before that, need to add/modify /etc/init.d/sshd  # chkconfig: sshd should be started/stopped at run level 2, 3, 4 and 5 with the start priority of 55 and the stop priority of 25

16 Reboot & Shutdown To reboot  $ shutdown -r now  $ reboot  $ telinit 6 To halt  $ shutdown -h now  $ halt  $ telinit 0  $ poweroff

17 Reboot & Shutdown (cont) To shutdown gracefully  $ shutdown -h +15 “Shutdown in 15 mins”

18 References LAH  Ch 2: Booting and Shutting Down Grub manual 


Download ppt "Booting and Shuting Down WeeSan Lee. Roadmap Bootstrapping Boot Loaders Startup/Init Scripts Reboot & Shutdown Q&A."

Similar presentations


Ads by Google