Just a thought

Archive for May 24th, 2009

GRUB error 17 ( Debian/Ubuntu )

Posted by stringofthoughts on May 24, 2009

Grub error 17 and Grub error 15, the most common grub error messages. Grub error 17 is kind of scary because you don’t even see your grub menu in this case and grub error 15 is very frustrating because it shows the grub menu but comes back to same error over and over again. I was also terrified of these error because once you get these error you can’t use your system, you can’t access the net and that’s is just not cool.is it ?

The reason for grub error 17 is a messed up partition table disk order. How partition table disk order gets messed up I have no idea but it does sometimes and then you get error 17. So what does it mean by a messed up partition table disk order. It means say your drive A was /dev/hda2 earlier now it is /dev/hda3 or something else bottom line for you to know is that you need to fix this to get rid of error 17. A good way to find this out is using a live CD

$ sudo fdisk -l

You ‘ll get something like (this is only an example)

Disk /dev/hda: 200.0 GB, 200049647616 bytes
255 heads, 63 sectors/track, 24321 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x247ae615

Device Boot      Start         End      Blocks   Id  System
/dev/hda1   *           1        1275    10241406    c  W95 FAT32 (LBA)
/dev/hda2            1276       24320   185108962+   f  W95 Ext’d (LBA)
/dev/hda5            1276        1397      979902   82  Linux swap / Solaris
/dev/hda6            1398        2550     9261441   83  Linux
/dev/hda7            2551        6374    30716248+   b  W95 FAT32

Partition table entries are not in disk order

I ‘ve a perfectly good system. I ‘ve added this line in bold at the end to show how it’ll look like if your partition table disk order is messed up. To fix the disk order.

$ sudo fdisk /dev/hda

Please note it’s hda not hda1 or hda3. No numbers we are working on entire disk. It’ll take you to fdisk prompt. Be careful here.

choose option x (extra functionality (experts only)) and enter.
then select f (fix partition order) and enter.
then select option w (write table to disk and exit), and enter.

X F W in short. Don’t do anything else unless you know what you are doing.

Now run

$ sudo fdisk -l | grep -i linux

The partition table disk order is changed and you need to note down 2 important things. Where is your swap and linux root devices. The command above will give you

/dev/hda5            1276        1397      979902   82  Linux swap / Solaris
/dev/hda6            1398        2550     9261441   83  Linux

Note this down Swap :: /dev/hda5 and Linux root :: /dev/hda6

Now you need to install grub. It’s very simple. The grub will be installed on /dev/hda6 which is written as (hd0,5) in grub. Make sure you understand this if it’s /dev/hda1 then you ‘ll use (hd0,0). It’s always one digit less in (hdX,Y).

$ sudo grub

grub > root (hd0,5)

grub > setup (hd0)

grub > quit

This is my personal observation that sometimes even if after re-installing grub /boot/grub/menu.lst is not updated. So open your menu.lst file and check /dev/hda6 and (hd0,5) is the root device in the file and not any other device. If it’s set to any other device you ‘ll end up with error 15. Here in our example root is /dev/hda6 so there is a entry in menu.lst like

title        Debian GNU/Linux, kernel 2.6.26-2-686
root        (hd0,5)
kernel        /boot/vmlinuz-2.6.26-2-686 root=/dev/hda6 ro
initrd        /boot/initrd.img-2.6.26-2-686

title        Debian GNU/Linux, kernel 2.6.26-2-686 (single-user mode)
root       (hd0,5)
kernel        /boot/vmlinuz-2.6.26-2-686 root=/dev/hda6 ro single
initrd        /boot/initrd.img-2.6.26-2-686

For Ubuntu users it’ll be (hd0,5) and /dev/sda6. Make sure the root device is correct in this file.

Next file to check is /etc/fstab. Open the file and check the device for swap and root is correct. here is an example

# /etc/fstab: static file system information.
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    defaults        0       0
/dev/hda6 /               ext3    errors=remount-ro 0       1
/dev/hda5 none            swap    sw              0       0
/dev/hdc        /media/cdrom0   udf,iso9660 user,noauto     0       0

Once you are done you can reboot. You ‘ve just solved your grub problem 🙂

Advertisements

Posted in Linux, tips 'n tricks | 42 Comments »