Linux: Startup Analysis II -- GRUB analysis
ls /bootconfig-2.6.18-194.el5lost+foundSystem.map-2.6.18.el5grubmessagevmlinuz-2.6.18-194.el5initrd-2.6.18-194.el5.imgsymvers-2.6.18-194.el5-gz
?3) What stores in "/boot/grub/grub.conf"?
#grub.conf generated by anaconda#...#boot=/dev/sdadefault=0timeout=5splashimage=(hd0,0)/grub/splash.xpm.gzhiddenmenutitle CentOS (2.6.18-194.el5) root(hd0,0) kernel /vmlinuz-2.6.18-194.el5 ro root=LABEL=/ rhgb quiet initrd /initrd-2.6.18-194.el5.img
1) default: the default start up os, in real server env, we will not install multiple os.
2) timeout: the default waiting time(second)
3) splashimage: GRUB GUI image. (hd0,0) --> hd(Hard Disk). hd0 the first hard disk. hd(0, 0) the first segment on the first hard disk.
? ? Here, (hd0,0) represents the hardware position of folder "/boot".
? ? So we can find splash.xpm.gz in /boot/grub directory.
4) hiddenmenu: If we comment this, then we can get the information of GRUB procession.
5) kernel: point out the position of kernel. ro means readonly.
6) initrd: load image file
?
2. Single user mode
1) Why should we use single user mode?
? ? We may forget the password for root.
? ? There may be file system chaos after a sudden power off.
? ? Single user mode enable us login system as root and don't have to input password.
? ? Single user mode disabled X-Window
2) How can we shift to single user mode?
e: edit current start menuc: enter GRUB command lineb: start current selected start menu itemd: delete current lineEsc: return to GRUB start up GUI and cancel all the modification for current menu item.
1. Step into GRUB GUI when start up.
2. Press e into edit line mode
3. Move highlight to kernel row, and press e again into edit mode.
4. Add 1 or s to the end of this line like this: kernel /vmlinuz-2.6.18-194.el ro root=LABEL=/ rhgb quiet 1
5. Press b to boot the system with single user mode as root.
?
3. Setup password for GRUB
1) Why should we set password for GRUB?
? ? To prevent other people change the password or damage system when entering single user mode by using GRUB.
2) How should we set password for GRUB?
? ? Just have to add line before title.
#grub.conf generated by anaconda#...#boot=/dev/sdadefault=0timeout=5splashimage=(hd0,0)/grub/splash.xpm.gzhiddenmenupassword --md5 **********************title CentOS (2.6.18-194.el5) root(hd0,0) kernel /vmlinuz-2.6.18-194.el5 ro root=LABEL=/ rhgb quiet initrd /initrd-2.6.18-194.el5.img
?
4. Recover GRUB
1) After startup and get into GRUB GUI, there is no menu displayed, only grub> prompt:
? ? That may results from a damaged row in grub.conf file.
? ? ?As convention, we should backup /boot directory for emergency use.
press c to enter grub command line.
grub> cat /boot/grub/grub.conf (look up the params)
grub> root (hd0,0) --> set root path as the /boot directory
grub> kernel (hd0,0)/vmlinuz-2.4.18-14 ro root=LABEL=/ ?--> set kernel file as ...
grub> initrd (hd0,0)/initrd-2.4.18-14.img ?--> set initrd?
grub> boot
2) What if we cannot even get into GRUB GUI?
We have to use linux installation cd to recover the system.