Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

Its showing:

error: no such partition.
grub rescue>

I want to fix this without using a live cd or usb stick, so just using grub rescue commands.

update:

Found this useful link http://techgage.com/news/repairing_a_broken_grub_2_boot-loader_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/boot showed error: unknown filesystem.

share|improve this question
    
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. –  ClothSword Dec 22 '12 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 '12 at 19:08
    
Nope. Can do from grub rescue =D –  ClothSword Dec 22 '12 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 '12 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 =) –  ClothSword Dec 23 '12 at 10:44
add comment

migrated from stackoverflow.com Dec 22 '12 at 18:59

This question came from our site for professional and enthusiast programmers.

1 Answer

As in the comments, it turns out this blog is perfect! http://techgage.com/news/repairing_a_broken_grub_2_boot-loader_on_ubuntu/ The problem I was having is 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... its 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! Its 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
share|improve this answer
    
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. –  ClothSword Dec 23 '12 at 10:54
    
In my case the linux.mod file was at /boot/grub/i386-pc/. use ls. –  Ujjwal Singh Mar 31 at 9:08
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.