You are not logged in.

#1 2009-11-26 11:25:25

SoleSoul
Member
From: Israel
Registered: 2009-06-29
Posts: 319

GRUB2 rescue guide

I had a problem with GRUB2, and I couldn't find an answer anywhere. Eventually, me and my Gentoo using friend found the solution.
Since I thought it would be useful for many users, I decided to write a guide describing how to deal with such situations. I wanted to add it to the wiki but I don't know how to edit wiki pages.
I would appreciate opinions and corrections and if someone could convert it to wiki format it would be great.


GRUB Rescue (GRUB2)

Since the MBR is too small for all of GRUB2 modules, just the menu and a few basic capabilities truly reside there. Most of GRUB2 stays on the partition it was installed from. The "MBR part" keeps a variable - "prefix" - which points to the partition and folder containing the rest of the program.

Sometimes, when you change the partition layout of your HD, the number of the partition which contains GRUB2 changes. Let's assume we installed GRUB2 from (hd0,7) or /dev/sda7, which is a logical partition inside an extended partition. Then we deleted /dev/sda5 and /dev/sda6, our /dev/sda7 became /dev/sda5. Now when the "MBR part" is looking for the rest of the program, it can't find it in (hd0,7) since such partition doesn't exist anymore. In this case, instead of showing the usual GRUB2 menu, you are being dropped to some sort of command line which is called GRUB rescue.

The easies way to fix this situation is to use another boot disk of some sort and reinstall GRUB2 again from the right partition. Such a boot disk is not always available so here is how to do it from GRUB rescue.

The number of available commands in GRUB rescue is really minimal. The only useful ones are "set" and "insmod". "set" sets variables, and "insmod" inserts new modules to expand GRUB rescue's capabilities.

Before we can start, we have to know the right number of the partition which contains GRUB2 in order to inform the "MBR part".

Assuming GRUB2 is installed in it's default location "/boot/grub", type

set prefix=(hdx,y)/boot/grub

where x is the physical HD number and y is the partition number.

Note: If (hdx,y) is a boot partition, you have to omit the /boot part from the path, ie type "set prefix=(hdx,y)/grub".

Now we want to expand the console capabilities so we insert a useful module. Type

insmod (hdx,y)/boot/grub/linux.mod

where, again, (hdx,y) is the right partition where GRUB2 was installed from and "/boot/grub" is the path to the installation directory.

This will hopefully bring you back to the standad (?) GRUB2 console.

Now in order to boot your OS, we have to type the regular GRUB2 command.

Here is an example of how to boot Arch Linux:

set root=(hd0,5)
linux /boot/vmlinuz26 root=/dev/sda5
initrd /boot/kernel26.img
boot

where (hd0,5) is the partition of your Arch Linux installation (not necessarily the same partition as above and it is probably different in your case).

If you have  a boot partition, change the lines accordigly to something like that:

set root=(hd0,5)
linux /vmlinuz26 root=/dev/sda6
initrd /kernel26.img
boot

and again, change the numbers to fit your layout.

After successfully booting your Arch Linux installation, you must fix grub.cfg to the new partition numbers and then run

grub-install /dev/sda

or /dev/sdb or whatever fits your layout to reinstall GRUB2 and fix the problem completely.

Last edited by SoleSoul (2009-12-04 12:49:00)

Offline

#2 2009-11-29 15:25:16

SoleSoul
Member
From: Israel
Registered: 2009-06-29
Posts: 319

Re: GRUB2 rescue guide

There was no reply yet.  Please feel free to tell my why tongue
1) The guide is badly written.
2) There is no interest in this subject.
3) You expect me to put it in the wiki if I think it's useful.
4) The wiki is not the place for such guide.
5) other wink

Just tell me something...

Offline

#3 2009-12-02 01:52:10

tigrmesh
IRC Op
From: Florida, US
Registered: 2007-12-11
Posts: 794

Re: GRUB2 rescue guide

Thank you for this.  I've been hesitant to install GRUB2 because there seemed to be so little information about what to do if something goes wrong.  If I have time next weekend, I'll try out GRUB2.

If I might ask one favor:  would you please modify the topic so that it says GRUB2 instead of just GRUB?  That way I can easily find it if I need it.

Thanks!

Offline

#4 2009-12-02 04:44:13

tavianator
Member
From: Waterloo, ON, Canada
Registered: 2007-08-21
Posts: 858
Website

Re: GRUB2 rescue guide

I'd say it deserves to be in the wiki for sure.  It's perhaps a bit long-winded though, so maybe condense it down a bit and stick it in a reasonable place on the GRUB2 page.  Or add it to the talk page if you're not sure it's ready, and people can mess with it until it's ready for primetime.

Offline

#5 2009-12-02 21:42:53

SoleSoul
Member
From: Israel
Registered: 2009-06-29
Posts: 319

Re: GRUB2 rescue guide

Title changed to GRUB2.

Thanks for the comment.
So what is the next step? The GRUB2 discussion page is almost empty, no one will look there.
Who moderates the wiki? Can I contact him somehow?

Offline

#6 2009-12-03 20:00:41

s3kt0r
Member
Registered: 2009-01-20
Posts: 208

Re: GRUB2 rescue guide

Glad I read this post. Now I feel more at ease with the thought of giving GRUB2 a go. Thanks.


box1: Arch (linux-3.17-rc5)
box2: Gentoo (linux-3.17-rc5)
wm: subtle

Offline

#7 2009-12-03 20:25:09

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: GRUB2 rescue guide

SoleSoul - you're not getting the whole wiki idea. It's community-created, community-maintained. Don't ask someone else to submit your work, and don't ask to contact the admin. Either take the time to learn wiki editing - it doesn't take long - or start a discussion on the talk page. Don't paste the whole howto in there - paste a link to this thread.

Notwithstanding all that -  nice work, thanks.

Offline

#8 2009-12-04 13:34:07

SoleSoul
Member
From: Israel
Registered: 2009-06-29
Posts: 319

Re: GRUB2 rescue guide

Thanks for the comments.
I just made my first wiki page
http://wiki.archlinux.org/index.php/GRU … ue_Console
I have one bug there. My Codeline became {{{1}}}...
I didn't link to it yet because I want someone to review it first. Would anyone be kind enough to do some little cosmetic fixes?

Last edited by SoleSoul (2009-12-04 13:38:57)

Offline

#9 2009-12-04 17:32:15

scio
Member
From: Buffalo, NY
Registered: 2008-08-05
Posts: 366

Re: GRUB2 rescue guide

You can avoid all of these problems if you have free space at the start of your disk, or create a bios_grub partition of > 31kb.

http://grub.enbug.org/BIOS_Boot_Partition

Offline

#10 2009-12-04 17:37:56

pointone
Wiki Admin
From: Waterloo, ON
Registered: 2008-02-21
Posts: 379

Re: GRUB2 rescue guide

Great work, SoleSoul.

The problem with the Codeline template is described in Help:Template; essentially, the "=" sign breaks output. You can either surround the input with <nowiki> tags or treat the parameter number as a named parameter (e.g. {{Codeline|1=1 + 1 = 2}}).

I think this is something that should be merged with the GRUB2 article; possibly under the heading "Using the interactive prompt" or something along those lines. I may play around with it later this afternoon.


M*cr*s*ft: Who needs quality when you have marketing?

Offline

#11 2009-12-05 17:13:14

SoleSoul
Member
From: Israel
Registered: 2009-06-29
Posts: 319

Re: GRUB2 rescue guide

@scio
Thanks. I didn't know about that.

@pointone
Thank you. So the key is <nowiki> </nowiki>, good to know.

I see that the article was merged nicely into GRUB2 wiki page. That's great!
There are two problems with the content though.

1) "The available commands in GRUB rescue can be listed by entering "help"."
This proved to be 100% wrong in my case. hmm I couldn't use "help".

2) Whoever did the cut and merge, omitted the "set prefix" command.
I checked it about 10 times and if the prefix is wrong you can't use "insmod" at all even if the root variable is right!
Since "set prefix" is the core of the problem it must be included.

Otherwise, nice merge.

Offline

#12 2009-12-05 19:07:32

pointone
Wiki Admin
From: Waterloo, ON
Registered: 2008-02-21
Posts: 379

Re: GRUB2 rescue guide

Sorry; I made changes from memory -- it has been several months since I've played with GRUB2. I'll correct this.


M*cr*s*ft: Who needs quality when you have marketing?

Offline

#13 2009-12-06 13:39:06

SoleSoul
Member
From: Israel
Registered: 2009-06-29
Posts: 319

Re: GRUB2 rescue guide

You changed it even more and it looks good!
Nice work.
I have to get used to this wiki thing smile

Offline

#14 2010-01-12 14:40:28

AlE
Member
From: Near Rome - Italy
Registered: 2010-01-12
Posts: 1

Re: GRUB2 rescue guide

SoleSoul wrote:

There was no reply yet.  Please feel free to tell my why tongue
1) The guide is badly written.
2) There is no interest in this subject.
3) You expect me to put it in the wiki if I think it's useful.
4) The wiki is not the place for such guide.
5) other wink

Just tell me something...

I used these steps this morning  to recover HD (dualboot ubuntu+win) of a colleague of mine.

Very useful post.


AlE

Offline

#15 2010-01-17 02:13:10

IgnorantGuru
Member
Registered: 2009-11-09
Posts: 640
Website

Re: GRUB2 rescue guide

Nice guide I hope that becomes a wiki in some form.

I experienced grub2 a bit when I ran Ubuntu Karmic for a few months.  When I changed to Arch I was actually relieved to see grub1 was the default.  grub2 has some nice abilities.  It's neat how it finds the OSes and updates itself.  But the flip side of that is that when you do want to modify something, you have to jump through a lot hoops.  I think I prefer just editing menu.lst the way I want and being done with it.  grub2 has so many files to maintain to accomplish the same thing.  So I'm in no hurry to change.

Just my two bytes.

Offline

#16 2010-03-21 16:40:35

Ravenman
Member
Registered: 2009-07-03
Posts: 236

Re: GRUB2 rescue guide

Thank you very much. Your guide saved my Arch Linux system. cool

Offline

Board footer

Powered by FluxBB