Grub Legacy Tips

Note: Grub 2 supercedes Grub which has now been renamed Grub Legacy.

Introduction

Grub - GRand Unified Bootloader


Boot floppy

How to create a boot floppy under Linux

Caution These operations destroy any data on the floppy

Boot sector

This creates a boot sector on the floppy disk.

This gives you a Grub command line with which to boot the system.

   # cd /usr/lib/grub/i386-pc # on debian /lib/grub/i386-pc
   # dd if=stage1 of=/dev/fd0 bs=512 count=1
   1+0 records in
   1+0 records out
   # dd if=stage2 of=/dev/fd0 bs=512 seek=1
   225+1 records in
   225+1 records out

This method creates a boot floppy which includes the menu etc.

   # : Format the floppy
   # fdformat /dev/fd0
   # mkfs.ext2 /dev/fd0
   # mount /dev/fd0 /mnt/floppy
   # mkdir -p /mnt/floppy/boot/grub
   # cp /boot/grub/stage1 /mnt/floppy/boot/grub
   # cp /boot/grub/stage2 /mnt/floppy/boot/grub
   # cp /boot/grub/menu.lst /mnt/floppy/boot/grub

The run grub interactively

   # grub
   grub> root (fd0)
   grub> setup (fd0)
   grub> quit

Bootable CD-ROM

As of writing, you need a fairly up-to-date version of Grub, and it may well need to be patched to support the features mentioned here. I fetched a version for Debian from www.backports.org - I believe similar features are available in the Red Hat distribution.

This is a summary of what is described in detail in the 'Installation' section of the excellent Grub manual. (The manual is in the Debian grub-doc package).

  • mkdir -p iso/boot/grub
  • cp /usr/lib/grub/i386-pc/stage2_eltorito iso/boot/grub

Optionally include 'menu.lst' in iso/boot/grub. If you do, make sure you remove any 'savedefault' options, otherwise you'll get an error like 'Error 6: mismatched or corrupt stage1/stage2' when you try to boot.

Make an iso9660 image (see CdBurning)

(Whilst still in ../iso/ i.e. the parent of the iso directory)

  • genisoimage -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table -o grub.iso iso

Then burn the CD using that image. See CdBurning.

-- Frank Dean - 27 Mar 2010


Boot option for next boot only

As of writing, you need a fairly up-to-date version of Grub, and it may well need to be patched to support the features mentioned here. I fetched a version for Debian from www.backports.org - I believe similar features are available in the Red Hat distribution.

This emulates the lilo '-R' option - an absolute must for anyone upgrading kernels on remote machines!

If you've got this version simply issue

  • grub-reboot n # where n is the Grub option to boot with, zero indexed.

See man grub-reboot.

-- Frank Dean - 1 Feb 2005

LVM and RAID

Grub has supported LVM and RAID since version 1.95 - see http://grub.enbug.org/LVMandRAID

See this email re Grub and Software RAID

-- Frank Dean - 04 May 2007

Robustnes

See http://www.gnu.org/software/grub/manual/html_node/Making-your-system-robust.html#Making-your-system-robust

-- Frank Dean - 04 May 2007

Segmentation Fault

Check that the contents of /boot/grub/device.map are correct. I.e. point to a valid device.


-- Frank Dean - 27 Jan 2005

Related Topics: GrubTips, LinuxLilo, LogicalVolumeManagement