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: 0×247ae615Device 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-686title      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
GRUB error 15 ( Debian/Ubuntu ) | Debian-News.net - Your one stop for news about Debian said
[...] Error 17 is described here [...]
GRUB error 15 ( Debian/Ubuntu ) | Ubuntu-News - Your one stop for news about Ubuntu said
[...] Error 17 is described here [...]
Poovaiah M P said
Hey,
thank you very much for the post. This was very helpful for me. Keep up the good work
anamtamrin said
thank u very very much…
Levi said
I tried this and although very well written, had issues. Looking for insight.
For starters, i got this error because of an update in Ubuntu 9.04. Not sure why.
fdisk -l returns:
sda1* W95 Fat32
sda2 extended
sda5 Linux swap / solaris
no order issues when fdisk dev/sda ran.
fdisk -l | grep -i linux returns:
sda5 Linux swap / solaris
ran grub
grub>root (sd0,4) returns:
Error 23: Error while parsing number
for poopies and chuckles i tried…
grub>root (sd0,1)
same result.
Help?
stringofthoughts said
Hi,
I’m not aware of your whole problem but one thing i noticed in your comment is that you don’t ‘ve a Linux partition. You ‘ve a swap partition but not the partition where you had installed Linux.
$ fdisk -l | grep -i linux should ‘ve returned
/dev/sda1 1276 1397 979902 82 Linux swap / Solaris
/dev/sda2 1398 2550 9261441 83 Linux
A Linux partition and a swap partition. You ‘ve only swap partition. same thing with fdisk -l , your main Linux partition is missing.
You could try to retrieve partition table or if you ‘ve important data in there somewhere you should make a disk image so that you can retrieve data later. I feel like you could try to get the partition back or make a new partition and do a fresh installation.
Good Luck
ÓÄÇá ÇÓÆáÉ Úä ÊæÒíÚÉ ãäÊ ÞÈá ÇáÊäÕíÈ - ãÌÊãÚ áíäæßÓ ÇáÚÑÈí said
[...] [...]
Steve said
Sorry, Ubuntu newbie here. I have a Windows/Ubuntu dual boot set up and recently repartioned a drive through Windows. Now I am getting Grub Error 17. Looks like my partition table is indeed out of order. Here is what I am getting:
ubuntu@ubuntu:~$ sudo fdisk -l
Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xc3ffc3ff
Device Boot Start End Blocks Id System
/dev/sda1 * 1 3825 30724281 7 HPFS/NTFS
/dev/sda2 3826 10324 52203217+ f W95 Ext’d (LBA)
/dev/sda3 10325 17654 58878225 83 Linux
/dev/sda4 17655 19457 14482597+ 12 Compaq diagnostics
/dev/sda5 7712 10006 18429952 7 HPFS/NTFS
/dev/sda6 10007 10324 2554303+ 82 Linux swap / Solaris
However, I am getting stalled on the next command:
ubuntu@ubuntu:~$ sudo fdisk /dev/hda
Unable to open /dev/hda
Any help is appreciated. Thanks!
stringofthoughts said
Hi Steve,
I’ve wrote those blogs from a debian system. Debian shows hard disk as /dev/hdx where as ubuntu shows ‘em as /dev/sdx . I guess you copied commands from my blog. You should try
$ sudo fdisk /dev/sda
replace hdx with sdx and i think it’ll work out just fine.
Good luck
Steve said
By the way, I am using a Ubuntu live CD. Do I need to mount the hard drive first? Just an idea from reading forums.
stringofthoughts said
No. you don’t need to mount the drive first to execute fdisk command.
mohamed said
ubuntu@ubuntu:~$ $ sudo fdisk -l
bash: $: command not found
ubuntu@ubuntu:~$
Cliff said
@Mohamed: the command is sudo fdisk -I, leave out the “$”
hosein said
Hi
I have problem with
grub> root(sd0,5)
Error 27: Unrecognized command
Do you help me?
stringofthoughts said
Hi,
Your command is incorrect. Try this
grub> root (hd0,5)
There is always a space between root and the string (hd0,5) and hard disk is represented as hd0 and not as sd0. These were the two problems with your command.
I hope it works.
Good Luck