Distroname and release: Debian Squeeze

Restore / Fix GRUB2 bootloader

Have you ever tried to mess up your GRUB2 conf file, or an dependant GRUB2 file?
In example /etc/default/grub, or /etc/grub.d/00_header ?

If so, it is quite easy to fix, using a live-cd. I have used knoppix in this example, but any live distro should work. First we will need to find out the partition names. I like to use cfdisk, but fdisk can be used as well.

Start cfdisk where /dev/sda is the harddisk, it could be /dev/hda, /dev/sdb or something completely different. Be sure to select the correct one.
#cfdisk /dev/sda
You will get a similar output, like shown below. With help of this, and the partition types, you should hopefully be able to recognize which parition belongs to wich mount point.
    Name         Flags       Part Type   FS Type            [Label]         Size (MB)
    sda1         Boot         Primary    Linux ext3                             98,71
    sda3                      Primary    Linux swap / Solaris                 2163,25
    sda4                      Primary    Linux ext3                           8463,82
If /boot is on a seperate parition, we will need to "bind" the boot partition into boot, or else this is not needed, and should not be done.!
If you have other seperate paritions, like /var, you should mount these seperate as well!

Mounting the / and /boot partitions.
/dev/sda1 is our /boot, and /dev/sda4 is our / partitions. This is important, since we will need to know wich partition is wich later.
#mount -t ext3 /dev/sda1 /media/sda1
#mount -t ext3 /dev/sda4 /media/sda4
Now we will need to mount some device points to the mountpoint we are going to chroot later. If you do not do this, you will get errors.
Note we are binding these to our / partition, which in this example is /dev/sda4.
mount --bind /dev /media/sda4/dev
mount --bind /proc /media/sda4/proc
mount --bind /sys /media/sda4/sys
Optional, depending on your configuration!
mount --bind /media/sda1/ /media/sda4/boot
Ok, so far so good, now it is time to change your configuration files. Use youre favorite editor, and make the changes in the file that is causing the troubles, and save the changes after editing.
#vim /media/sda4/etc/default/grub
Now this is done, we will need to chroot the environment, meaning we will change the working root directory.
#chroot /media/sda4
Now we are ready to complete the task, and update GRUB2, and restart the computer.
Task completed, and hopefully GRUB2 will start to boot successfully again. Good luck.
Copyright LinuxLasse.net 2009 - 2017 All Rights Reserved.

Valid HTML 4.01 Strict Valid CSS!