1

I was dual booting Windows and Ubuntu. When I reinstalled Windows, it would no longer get to the GRUB menu.

It's showing:

error: no such partition.
grub rescue>

I want to fix this without using a live CD or USB stick, so I am just using GRUB rescue commands.

I found the useful page Repairing a broken GRUB 2 bootloader on Ubuntu, with the instructions (and explanations) of what to do:

grub> ls

(hd0) (hd0,5) (hd0,1) (fd0)

grub> set prefix=(hd0,1)/boot/grub
grub> set root=(hd0,1)

grub> set
?=0
color_highlight=
color_normal=
pager=
prefix=(gd0,1)/boot/grub
root=hd0,1

grub> ls /boot

grub/ System.map-2.6.32-21-generic abi-2.6.32-21-generic config-2.6.32-21-generic memtest86*.bin vmcoreinfo-2.6.32-21-generic vmlinuz-2.6.32-21-generic System.map-2.6.32-22-generic initrd.img-2.6.32-21-generic config-2.6.32-22-generic abi-2.6.32-22-generic vmcoreinfo-2.6.32-22-generic initrd.img-2.6.32-22-generic vmlinuz-2.6.32-22-generic

grub> insmod /boot/grub/linux.mod
grub> linux /vmlinuz root=/dev/sda1 defaults
grub> initrd /initrd.img
grub> boot_

But things went like this:

error: no such partition.

grub rescue> help

Unknown command 'help'

grub rescue> ls /boot

error: no such partition.

grub rescue> ls
(hd0) (hd0,msdos3) (hd0,msdos2) (hd0,msdos1)
grub rescue> set prefix=(hd0,msdos1)/boot/grub
grub rescue> set root=(hd0,msdos1)

grub rescue> set

prefix=(hd0,msdos1)/boot/grub
root=hd0,msdos1

grub rescue> ls /boot
error: unknown filesystem.

grub rescue> boot

Unknown command 'boot'

So you can see that ls and boot showed the error unknown filesystem.

5
  • There are many resources on google on how to do this with live cds/sticks... but there are unanswered questions on how to do it without. I have fixed this problem before, I found the set of commands on some site. But I can't find it and have misplaced my notes. It was something like [list partitions, set root or boot partition or something, job done] if i find it I will of course post it here.
    – xxjjnn
    Dec 22, 2012 at 18:24
  • 2
    You need to reinstall grub, to do this you may be able to boot into linux from the grub rescue prompt or use a live cd/usb. I really don't understand why you wouldn't simply use a live cd/usb? Instead of wasting time I'd be more interested in getting my system working again.
    – nikhil
    Dec 22, 2012 at 19:08
  • Nope. Can do from grub rescue =D
    – xxjjnn
    Dec 22, 2012 at 20:15
  • May this link help you a bit. av8n.com/computer/htm/grub-reinstall.htm in my case i had mbr copy saved this way realy simple restore previous grub state
    – Yurij73
    Dec 22, 2012 at 21:23
  • This question is specifically about how to do it without live cd/usb. There are many resources on how to do it with =)
    – xxjjnn
    Dec 23, 2012 at 10:44

1 Answer 1

2

As in the comments, it turns out this blog post is perfect: Repairing a broken GRUB 2 bootloader on Ubuntu

The problem I was having was that I was looking at the order that ls was giving... which is:

(hd0) (hd0,msdos3) (hd0,msdos2) (hd0,msdos1)

which I mistakenly believed mapped to the order of:

[empty space from deleted recovery partition, windows 7, swap, Ubuntu]

That pesky GRUB rescue ls command should have said:

(hd0) (hd0,msdos1) (hd0,msdos2) (hd0,msdos3)

... The moral of the story is try each partition until it works =p

error: no such partition.

grub rescue> ls /boot
error: no such partition.

grub rescue> ls
(hd0) (hd0,msdos3) (hd0,msdos2) (hd0,msdos1)

# This is a comment. The following is choosing
# the non-Linux partition by mistake... error
# unknown filesystem should alert you to the
# mischoice. Keep choosing until you get
# the right one!

grub rescue> set prefix=(hd0,msdos1)/boot/grub
grub rescue> set root=(hd0,msdos1)

grub rescue> set
prefix=(hd0,msdos1)/boot/grub
root=hd0,msdos1

grub rescue> ls /boot
error: unknown filesystem.

# Here I choose the correct partition - an
# Ubuntu one. Note that the ls /boot
# doesn't give an error!

grub rescue> set prefix=(hd0,msdos3)/boot/grub

grub rescue> set root=(hd0,msdos3)

grub rescue> set
prefix=(hd0,msdos3)/boot/grub
root=hd0,msdos3

grub rescue> ls /boot
blah blah blah loads of stuff; I'm not
going to type it all out... it's similar
to the junk about generic and abi
from the blog thing.

grub rescue> insmod /boot/grub/linux.mod
grub rescue> linux /vmlinuz root=/dev/sda3 defaults
grub rescue> initrd /initrd.img
grub rescue> boot

# Booted! It's TERMINAL time! Open your Linux
# terminal and plonk this in. Credit to
# <http://techgage.com/news/repairing_a_broken_grub_2_boot-loader_on_ubuntu/>

sudo update-grub
sudo grub-install /dev/sda
3
  • In case of link rot, read the question this answers to see the grub rescue commands and outputs techgage had. The article also explains that (HD0,1) is the first primary partition's first logical parition, and that (HD2,4) would be the third primary partition's 4th logical partition. (Sometimes, computers count from zero rather than one). Also, (HD0,1) gives sda1; (HD2,4) gives sdc4; (HD25,99) would give sdz99. The place where it says sda rather than sda1, it doesn't care which logical partition - so sdz99 would just be sdz. Not that you can have 99 primary partitions, I think the limit is 4.
    – xxjjnn
    Dec 23, 2012 at 10:54
  • In my case the linux.mod file was at /boot/grub/i386-pc/. use ls. Mar 31, 2014 at 9:08
  • Note that once you find the correct set prefix, you can load the normal module and mode, which probably makes the next part easier, cf. askubuntu.com/questions/654386/… Sep 1, 2016 at 9:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .