V. Grub A. Grand Unified Bootloader 1. configuration on the fly - unlike lilo, you can type in or search for the image you want to boot 2. Most distros include grub by default these days. a. Slackware no, Arch or Gentoo choice B. Grub configuration and files will typically be found in the /boot directory 1. /boot/grub a. menu.list - general configuration file - holds configured images b. image file - essential for booting i. stage 1 - put in mbr or boot sector of partition - loads stage 1.5 or 2 a. encodes location of stage 1.5 or 2 ii. stage 1.5 - file systems a. usually installed right after the mbr iii. stage 2 - core grub image iv. stage2_eltorito - used for creating bootable cdroms v. nbgrub - network boot vi. pxegrub - netboot image - preboot execution environment C. 2 ways to install grub 1. native - grub boot disk a. grub interface to setup and install grub b. considered the safer way 2. grub-install a. easier, comes with risk b. pass device as either linux device or grub device i. grub-install /dev/hda - mbr 2. grub-install /dev/hda1 - boot partition 3. grub-install (hd0) - mbr of firt hard disk. b. May have to specify where images are stored: i. grub-install --root-directory=/boot /dev/hda D. GRUB device naming 1. (hd#,#) a. hd for hard drive, fd for floppy b. 1st # is device number i. first device is 0 c. 2nd # is partition i. first partition is 0 2. eeepc = 0x80??? 1. bios labels floppys as 0 and increases a. fda = 0 b. fdb = 1 2. hardisk (regardless type) 0x80 a. sda = 0x80 b. hdb = 0x81 3. can use grub command line to help figure out a. root( + tab completion will fill in all devices applicable. F. menu.lst 1. be sure to specify root properly a. (hd0,0) = hard drive 1, partition 1 b. (hd0,3) = hard drive 1, partition 4 c. (hd2,1) = hard drive 3, partition 2 2. 2 sections: a. general settings b. OS definitions 3. General settings a. default = which definition to use as default boot i. remember, starts with 0 b. timeout = number of seconds before default is booted c. fallback = fallback definition to use if curent defition cannot be booted = more below d. color = normal highlight = (fg bg) see docs for list of colors i. only 8 colors of the 16 can be used for background a. black, blue, green, cyan, red, magenta, brown, light=gray 4. OS definitions a. title = name for os that will appear in menu list i. Slackware 2.6.22 kernel b. root = set the root partition to boot i. must conform to device naming structure ii. rood (hd0,0) = disk 1 partition 1 iii. remember 0 is first, 1 c. kernel = path to the kernel on the root parition i. can add parameters to pass to kernel d. initrd = path to initrd image on root partition e. chainloader = loads a file as chain-loader. i. used primarily for non-multiboot os - windows G. Grub on boot 1. Grub menu a. configured menu.lst c. enter = select definition to boot d. e = edit definition e. c = enter command line mode 2. Command mode a will boot into this if there is no configured menu.lst file b. full access to grub commands c. esc - return to menu 3. edit mode a. command line mode where you can edit lines of the definitions b. press e to edit line c. o = add line after current d. d = delete line e. enter to finish edit f. b to boot g. esc to return to menu, ignore changes H. Password protection 1. 2 possibliities a. protect from editing b. protect from booting 2. Protect from editing a. use password in menu.lst i. create an md5 hash using grub-md5-crypt (or md5crypt command from grub command line) ii. no md5 = plain text iii. optional path to additional menu.lst to load when password is entered a. path to additional menu.lst b. on boot press p to enter password. 3. Protect from booting a. include the protection above but add a. lock - after title (must be after title). G. Boot once only 1. used for testing a kernel 2. add to general configuration of menu.lst a. default saved i. this tells grub to read the default file to see what definition to boot. 3. add new definition after good definition 4. after good definition you want to use as default i. savedefault 5. after test definition add ii. saveddefault 0 6. save and run on command line: i. grub-set-default 1 ii. sets /boot/grub/default to 1 a. remember that 0 is first, 1 is second. 7. this will boot the new definition and set the default back to 0 8. if definition fails, system will stop booting H. Fallback definitions 1. will keep trying to boot fallbacks in succession until successful 2. add default saved to general configuration section 3. after add a. fallback 1 2 4. after each definition add a. savedefault fallback 5. system will try each fall back in succession until successfulboot then save success to the defaul file. I. Neither section will help to solve a problem should the kernel boot but fail after that, unless the failure results in a reboot. A. may want to use set default in such a case J. additional commands 1. Hidden (menu command) hide the grub menu unless esc is pressed during timeout phase 2. hide (general) - hide a partition from the booting os (only useful for dos and windows) 3. unhide (general) - clears hidden bit on partition (only useful for dos and windows) 4. boot (command line, menu entry) - attempt to boot 5. cat (command line) - list the contents of a file 6 chainloader (command menu entry) - load a file as a chain loader a. can use blocklist notation i. a block list is a file that does not appear in the file system ii. access by specifying the block offset b. example - chainloader +1 = boot file on first block of partition c. useful for oses with a defective bootloader and booting windows/dos 7. find (command) - search for a file in all mountable partitions 8. halt (command) - halt system 9. help (command) - display a list of commands a. help command - display help for that command 10. pause (menu) - print a message and wait for key press. 11. quit (command) - exit command line or edit mode back to menu mode 12. reboot (command) - reboot system 13. root (command, menu) - set the device to root and attempt to mount and get information 14. root (command, menu) - set root device but do not mount http://www.gnu.org/software/grub/manual/html_node/index.html