GRUB
Tips and Tricks
From Ref. [1]:
On my USB flash memory key, I created a root folder named boot to hold all the data necessary for USB booting (see figure 2). Under the boot folder, I created a directory named grub for GRUB-related files, images which are initial ramdisk (initrd), floppy, or disk images, and finally kernels to hold all the kernels
…you’ll need to copy some of GRUB’s stage files, including stage1, stage2, and fat_stage1_5, and put them into the boot/grub directory on the USB flash memory key
…install GRUB to the Master Boot Record (MBR) of the USB flash memory key. Luckily, it’s the same process as installing to a hard drive.
One cool trick is to use GRUB and memdisk to boot floppy disk images.
Install process example:
Find boot images: grub> find (hd2,0)/boot/im<TAB>
grub> root (hd2,0)
grub> setup (hd2)
First, download the DSL ISO9660 image, and either burn it to a CD, or mount it via loopback:
mkdir dsl-test
mount -t iso9660 -o loop dsl-image.iso dsl-testNext, copy the KNOPPIX file, kernel, and initial ramdisk:
cp dsl-test/KNOPPIX/KNOPPIX /media/usb/boot/images/dsl
cp dsl-test/boot/isolinux/linux24 /media/usb/boot/kernels/dsl-linux24
cp dsl-test/boot/isolinux/minirt24.gz /media/usb/boot/images/dsl-minirt24.gz
sync
umount dsl-test && rmdir dsl-testThis assumes that your USB flash memory key is mounted at /media/usb. Next, edit the /media/usb/boot/grub/menu.lst file and make sure it looks like the entry in Sidebar 1. You might have noticed that the root line at the top of the menu.lst file says (hd0,0) even though we used (hd2,0) earlier. When you boot from the USB flash memory key, the key itself becomes hd0, even before the primary master hard drive.
DSL entry in menu.lst From Sidebar 1:
title DSL 1.2 (2.4.26) 1024x768 (save to RAM)
kernel /boot/kernels/dsl-linux24ramdisk_size=100000
init=/etc/init
lang=us
apm=power-off
vga=791
toram nomce noapic quiet
knoppix_dir=images
knoppix_name=dslinitrd=/boot/images/dsl-minirt24.gz
Manual
From Ref. [2]
Naming convention
First number: disk (starting with zero)
Second number: partion (starting with zero - extended partition numbering starts at 4)
Examples:
(hd1,0): 2nd disk, first partition
(hd0,4): 1st disk, first extended partition
Boot Linux
- Use find w/ <TAB> completion to locate vmlinuz
- Load the kernel: grub> kernel /vmlinuz root=/dev/hda1
- grub> boot
menu.lst
Syntax: configuration
- Comment lines with hash (#)
- default <num>: Set which entry <num> to load on default, starting with 0
- timeout <sec>: Number of seconds to wait before booting default
- title <desc>: Delimits entries. Include a short description to be displayed in the menu
- root <device>: Set the root device grub will use. Device holds path to kernel file on next line
- Specify root device directly to find kernel: kernel (hd1,0)/vmlinuz root=/dev/hdb1
- kernel <file> <flags>: device/path to file for grub to load. <flags> are passed verbatim as the kernel command-line.
- initrd <file>: device/path to INITial RamDisk for boot image
- No need to end with a boot command, grub will call automatically
Chainloader
Use to hand off boot process to another bootloader. Of course it could be another GRUB
Typical chainload
grub> rootnoverify (hdX,Y)
grub> chainloader +1
grub> makeactive
grub> boot
The +1 on chainloader hands off booting to the first block of the current device
Boot USB from hardrive GRUB menu
Assuming USB stick device maps to (hd2) when grub loads off the hard drive:
grub> root (hd2,0)
grub> chainloader (hd2)+1
grub> boot
The (hd2)+1 on chainloader hands off booting to the first block of the specified device, in this case (hd2). This
seems to be necssary if grub loaded off of a different device.
Change default boot device
Construct menu.lst items so that the operating system selected will be the default boot operating system on next startup.
See savedefault and default. Also consider fallback.
# By specifying saved here the default entry is the entry previously saved with the command savedefault
default saved
title O/S 1
root (hdX,Y)
kernel /boot/KERN root=/dev/sdZZ
initrd /boot/INITRD
savedefault
title O/S 2
root (hdA,B)
kernel /boot/KERN
savedefault
Boot an ISO
title KNOPPIX
root (hd0,0)
kernel /linux26 ramdisk_size=100000 fromhd=/dev/hda4
initrd /minirt26.gz
savedefault
boot