How to create a Grub disc to boot a Debian GNU/Linux system
From NewbieDOC
- Chris Lale
- chrislale AT users DOT berlios DOT de (publisher)
Go to NewbieDOC index
Revision History
Revision 1.0 | 26th February 2007 | Revised by Chris Lale | ||||||||||
Initial release. | ||||||||||||
| ||||||||||||
Revision 1.1 | 22nd November 2007 | Revised by Chris Lale | ||||||||||
Modified to include Revision History, Abstract and Appendix for Licence, so that a stable version can be included in the "newbiedoc" package. | ||||||||||||
It helps to be prepared. This NewbieDOC article helps you to plan for disaster by making a boot floppy or CD to boot your Debian system in case another operating system overwrites your MBR.
1 The advantage of having a Grub boot discIf you have more than one operating system on a dual- or multi-boot Debian system, you run a small risk of damaging the Grub bootloader. This might happen if another operating system overwrites the boot sector. It might also happen if you have several versions of Debian on different partitions and you remove one of them. The answer is to create a Grub boot disc (floppy or CD) that will boot into Debian on a partition that you know will never be moved or removed. 2 Create a boot floppyThe way to create a Grub boot floppy for Debian, based on the article at http://www.linuxjournal.com/comment/reply/4622, is as follows. Boot into your Debian system. If you have more than one, boot into the system that you know will remain permanently on your hard drive. Insert a floppy disc in your floppy drive and format it. Add a file system. This could be anything that Debian will recognise (eg ext2), but these commands will add an MSDOS filesystem. fdformat /dev/fd0 mkfs -t msdos /dev/fd0 Mount the floppy and copy the /boot/grub directory and its contents from the running system to the floppy. Unmount the floppy. $ mount -t msdos /dev/fd0 /media/floppy $ mkdir -p /media/floppy/boot/grub $ cp /boot/grub/* /media/floppy/boot/grub $ umount /media/floppy Install the GRUB boot loader in the MBR of the floppy itself. Run grub and enter these commands at the grub prompt. $ grub grub> root (fd0) grub> setup (fd0) grub> quit That's it! To test the floppy, restart the system with the floppy in the drive. You can select which operating system to boot from the usual blue menu. 3 Create a boot CDYou can find basic instructions for creating a bootable Grub disc in the manual at http://www.gnu.org/software/grub/manual/html_node/Making-a-GRUB-bootable-CD_002dROM.html.html#Making-a-GRUB-bootable-CD_002dROM. By adding a slightly modified menu.lst you can create a CD which will boot your system from the usual blue menu. In your "home" directory create a directory (eg "iso") in which to place the files for the CD. $ cd ~ $ mkdir iso Make a directory for Grub and copy the file "stage2_eltorito" to it from /usr/lib/grub/i386-pc/. $ mkdir -p iso/boot/grub $ cp /usr/lib/grub/i386-pc/stage2_eltorito iso /boot/grub Also copy the menu.lst file to it from /boot/grub. cp /boot/grub/menu.lst iso/boot/grub Now edit iso/boot/grub/menu.lst and remove any lines identical to "savedefault". Leaving these commands will cause an error because the CD is a read-only disc. A typical menu entry will look like this once "savedefault" has been removed: title Debian GNU/Linux, kernel 2.6.18-3-686 root (hd0,5) kernel /boot/vmlinuz-2.6.18-3-686 root=/dev/hda6 ro initrd /boot/initrd.img-2.6.18-3-686 Finally, make a ISO9660 image file called "grub.iso". $ mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot \ -boot-load-size 4 -boot-info-table -o grub.iso iso Burn the image file onto CD or a DVD. If you are using K3B or GnomeBaker, choose "Burn CDROM Image" from the "Tools" menu. If you are using the command line, you can use cdrecord. There is an explanation of how to do this at http://www.debian-administration.org/articles/273. Note: mkisofs has already set up the disc to boot from the boot/grub/stage2_eltorito file, so there is no need to setup GRUB on the disc. The -boot-load-size 4 bit is required for compatibility with the BIOS on many older machines. That's it! To test the CD, restart the system with the CD in the drive. You can select which operating system to boot from the usual blue menu. 4 How to use the Grub boot disc to repair the MBR--Chris Lale 15:32, 2 March 2007 (CET) Your system may stop booting from the hard drive if you install Windows or install another instance of Debian and then remove it. Just boot from your Grub floppy or CD, login, switch user to user root and re-install the Grub bootloader. If your first master hard disc is IDE, enter # grub-install /dev/hda If your first master hard disc is SCSI or SATA, use # grub-install /dev/sda 5 Appendix A: LicenceCopyright (c) 2007 Chris Lale. chrislale AT users DOT berlios DOT de
Go to NewbieDOC index |