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
Marc said
Hi,
After typing sudo grub I get this:
sudo: grub: command not found
An I cannot proceed any further. Any suggestions?
Thanks for your help!
stringofthoughts said
Hi Marc!
The command is not found because the is grub is not installed in your system. Trying apt-get from live CD won’t fix the problem. Without any more information it’s difficult for me to suggest anything but you can take a look here but don’t try it blindly. http://www.gnu.org/software/grub/manual/html_node/Installing-GRUB-using-grub_002dinstall.html.
Download this script http://sourceforge.net/projects/bootinfoscript/ and execute as suggested in the script. It’ll generate a report, send me that report. It’ll be helpful for me to understand your system.
grubinstall is a little bit risky command if you are executing it blindly. Be careful.
Marc said
Hiya,
The report it generated is as follows:
============================= Boot Info Summary: ==============================
=> Grub0.97 is installed in the MBR of /dev/sda and looks on the same drive
in partition #1 for /boot/grub/stage2 and /boot/grub/menu.lst.
sda1: _________________________________________________________________________
File system:
Boot sector type: -
Boot sector info:
Mounting failed:
mount: unknown filesystem type ”
sda2: _________________________________________________________________________
File system: Extended Partition
Boot sector type: -
Boot sector info:
sda5: _________________________________________________________________________
File system: swap
Boot sector type: -
Boot sector info:
=========================== Drive/Partition Info: =============================
Drive: sda ___________________ _____________________________________________________
Disk /dev/sda: 203.9 GB, 203928109056 bytes
255 heads, 63 sectors/track, 24792 cylinders, total 398297088 sectors
Units = sectors of 1 * 512 = 512 bytes
Disk identifier: 0×6c2be8ed
Partition Boot Start End Size Id System
/dev/sda1 * 63 386,154,404 386,154,342 83 Linux
/dev/sda2 386,154,405 398,283,479 12,129,075 5 Extended
/dev/sda5 386,154,468 398,283,479 12,129,012 82 Linux swap / Solaris
blkid -c /dev/null: ____________________________________________________________
/dev/loop0: TYPE=”squashfs”
/dev/sda5: UUID=”23b42fa1-ea84-4f71-9d70-ef979de8f7ba” TYPE=”swap”
=============================== “mount” output: ===============================
aufs on / type aufs (rw)
none on /proc type proc (rw,noexec,nosuid,nodev)
none on /sys type sysfs (rw,noexec,nosuid,nodev)
udev on /dev type tmpfs (rw,mode=0755)
/dev/sr0 on /cdrom type iso9660 (rw)
/dev/loop0 on /rofs type squashfs (rw)
none on /sys/fs/fuse/connections type fusectl (rw)
none on /sys/kernel/debug type debugfs (rw)
none on /sys/kernel/security type securityfs (rw)
none on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
none on /dev/shm type tmpfs (rw,nosuid,nodev)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev)
none on /var/run type tmpfs (rw,nosuid,mode=0755)
none on /var/lock type tmpfs (rw,noexec,nosuid,nodev)
none on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noexec,nosuid,nodev)
gvfs-fuse-daemon on /home/ubuntu/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev,user=ubuntu)
Hope it makes sense
Thanks again,
Marc.
sidney myall said
Very helpful. Worked alright.
Thanks for screen shot as well
stringofthoughts said
Hello Marc,
I think grub-install will solve your problem. Since you don’t ‘ve multiple disk it shouldn’t be a problem.
$ sudo grub-install /dev/sda
after this follow the steps from the blog as you were doing earlier. (eg. sudo grub and find stage1 commands)
Let me know …… Good luck
Marc said
Hi,
Thanks for your reply
I still couldn’t fix my GRUB issues though. Basically after typing sudo grub-install /dev/sda, it returned:
grub-probe: error: cannot find a device for /boot/grub
No path or device is specified.
Try ”grub-probe –help” for more information.
Auto-detection of a filesystem module failed.
Please specify the module with the option ‘–modules’ explicitly.
I do not know if it means anything but I cannot mount the hdd either due to a similar filesystem error. Also, any ideas on how could all this GRUB 17 error happened? I never tried to install any other OS or partition the disk or similar… Would it be easier for me to just reinstall the whole system?
Thanks for your advice,
Marc.
stringofthoughts said
Hi,
If you can reinstall i think you should do it. Backup your data and reinstall the system. Your problem seems complex and requires closer look which is impossible through blog messages. Since you asked whether it’ll be easier to reinstall all I can tell you, assuming that you know how to reinstall, that it’ll save your time and will definitely solve your grub issue
I ‘ll try to emulate the situation on my test system to find out the problem. I ‘ll let you know
I’m sorry … Good luck !!!
Alastair McAlpine said
Marc.
Can I suggest that if you are running from a live CD, you may need to set-up your internet connection to allow the computer access to the files. As its a live CD you need to do this each and every time you run it, because it is not saving any preferences as it would when you are running from the Hard drive
Just a though!!
Ally