Discussion in 'all things UNIX' started by Ocky, May 4, 2010.
Make yourself a bootable Grub 2 rescue CD
Absolute must imho.
Can't you just boot from your distro's livecd and perform any repairs from there?
Sure, but that's cumbersome. This way you get the grub menu with all the kernels as you normally would, make your selection and you boot into the distro with the damaged grub. From there you can just reinstall grub from terminal.
Once you have burned the .iso to CD boot with it. At the grub prompt type configfile /grub.cfg
Ocky, GRUB2 is still not standardized, so using a live CD may not necessarily work for all flavors of GRUB2. To be on the safe side, you may want to boot the live CD of your particular distro edition and perform maintenance using that.
That said, Herman is a very knowledgeable dude and his pages are very useful, informative and interesting. It's worth listening to his advice. But i believe that this is for Ubuntu only, and even then, per-edition.
For example, GRUB2 has changed from 1.97-beta4 to 1.98-ubuntu5 between karmic and lucid and device mapping file is gone from the grub directory. These small, subtle differences could be dangerous if you do not know fully what you're doing.
Mrk,worked really well for me with dual boot Karmic. I had a prob. once with Karmic and simply booted the grub rescue CD, then installed grub 2 from within the live system. All was perfect again. I posted in Ubuntu forums because the command for Karmic is not valid for Lucid. Tested this morning and Herman's new command for Lucid is fine.
I don't have Windows, but realise that your cautionary re: device mapping is called for but surely there is no prob. for (X)Buntu's ?
Device mapping is required for booting from other disks, if you have more than one, so that grub can properly identify and associate hd0/1/2/3 to sda/b/c/d. Not strictly related to any particular os, more to make sure the bios order is indeed the grub order.
All I can say is try it out on one of your machines where Grub 2 is installed.
If Grub version = 1.97 use: grub-mkrescue --overlay=/boot/grub Grub2CD.iso
If Grub version = 1.98 use: grub-mkrescue --output=rescue.iso /boot/grub
With the rescue CD made using the second command I can successfully boot into either
Lucid or Karmic despite different vesions of Grub 2 and Karmic is on another internal HDD.
I'll check and if it works, add to grub2 tutorial.
Herman has updated his site ... http://members.iinet.net/~herman546/p20/GRUB2 Bash Commands.html#GRUB2_CD-ROM
thanks Ocky for link great stuff .........indeed herman is very knowledgeable person )
Ocky please can you give a demo of restoring grub i mean grub 1 (menu.lst) i know little bit but grub 2 is still new thing for me
let me get what i understand
step 1 grub-mkrescue --output=rescue.iso /boot/grub
in ubuntu 10.04 it will make a grub config script and making it bootable cd iso
step 2 burn iso in image formate then boot from it and press c to get command mode
step 3 from command mode configfile /grub.cfg
now why herman (configfile (hd0,1)/boot/grub/grub.cfg)
now will it configure grub as the previous one or i need to reinstall the grub then use this to configure it
please it would be kind if you give a demo step by step considering newbie in mind its will help others as well
For grub legacy (old grub) I would use a live cd. For grub 2 it's very easy:-
(If Grub version = 1.97 use: grub-mkrescue --overlay=/boot/grub Grub2CD.iso
If Grub version = 1.98 use: grub-mkrescue --output=rescue.iso /boot/grub)
If you have 10.04 which uses grub 1.98 use the command for 1.98 as above.
Burn the iso named rescue.iso to CD-RW.
Boot from it.
At the grub prompt simply type configfile /grub.cfg
This will get you your Grub 2 Menu with all the kernels splash image modifications etc.
Select the kernel and hit enter to boot into your 10.04 OS
Then from within 10.04 you can repair your damaged Grub 2 : sudo grub-install /dev/sdX
You could also do this at the grub prompt instead of the above configfile way ..
grub> linux (hd0,1)/vmlinuz root=/dev/sdX
grub> initrd (hd0,1)/initrd.img
... Replacing the (hd0,0) and sdX with the appicable disk/partition descriptions for your setup.
thanks Ocky thanks very much
this is exactly what i was looking for
Forgot to mention. After the grub-install command, remember to run either:-
sudo grub-mkconfig -o /boot/grub/grub.cfg (or)
I was wondering...will this iso that's created work on both 32 and 64 bit systems or is it specific to either?
This iso could be a hassle free solution should grub2 corruption ever occur. Thanks for this, Ocky.
Trespasser, yes must work as long as we are talking Grub 2.
Edit: Just remember when there has been a kernel update, make a new recue cd so that you can boot into the OS with the latest kernel.
Now mentioned in the Ubuntu forum's Grub Guide. http://ubuntuforums.org/showthread.php?t=1195275
You need to install package grub-rescue-pc and xorriso.
Then:- grub-mkrescue --output=rescue.iso /boot/grub
Tried it no problems. At prompt type configfile /grub.cfg
This am I found and used these very handy instructions to repair my Mint 10's Grub 2. The difference for me is my non-standard location of Grub 2 ( I was fooling around carelessly ), as I like it on the root partition (sdg6 for me), rather than the standard beginning of sdg. Instead of: #grub-install /dev/sdg I used #grub-install /dev/sdg6 --force (--force because of the warning it's not recommended to install it to a partition. I use dual-boot with Win7, and setup the Linux Grub 2 entry in EasyBCD so I can choose which O/S I want to boot from.
Separate names with a comma.