Jump to content

Grub


zeek

Recommended Posts

Useful tools to help in recovery of the GRUB bootloaderNB: Continued on post #18, and post #27, and post #290) Bruno's Tips1) Supergrub Disk (SGD): It's menu is a bit cryptic at firstFor example: GRUB => MBR & !LINUX! (1) AUTO

means install/re-install GRUB into the MBRthen boot into Linux and do this automaticallythe (1) means you have only one partition on the hard-drive

As of this date, their wiki site is down (has been for awhile). but via this link one can at least see the basic look and steps involved.When 1st booting up the SGD you will be greeted with a screen.From here, one has a few options.1) Quick Method --> Automatically fix the MBR. Basically:

1a) If only have 1 GNU/Linux distro, and want to re-install GRUB, then Select the option: GRUB => MBR & !LINUX! (1) AUTO 1b) If have more than 1 distro and want to re-install GRUB, then Select: GRUB => MBR & !LINUX! (>=2) MANUAL Then pick the partition that holds the distro that initially loaded Grub into the MBR

2) Classical Method --> SGD still does the work for you

Select "Choose a Lang & HELP" option then, select "English Super Grub Disk" (obviously, choose your language) then, select "GNU/Linux" then, select "Fix Boot of GNU/Linux" then, in the window select the partition that holds [ /boot ] then, in a few short seconds it states: "SGD HAS SUCCEEDED"

3) Manual Method - Select the Advanced option and walk through the options. At each step SGD does tell you what it is about to do and one uses the arrows keys to select the proper options. Question: Does anyone know if Super Grub will restore a Grub-2 booboo? (asked on another thread)

Tried to find out, but their wiki is still down. But,
seems to suggest yes.Current version available is: 1.21 via

2) Discover Boot Script at sourceforgeInitially referenced from Ubuntu forums (sorry, forgot link)

"DL script anywhere (eg, your Desktop), then run it as root# bash ~/Desktop/boot_info_script047.shcreates a results.txt file" and provides useful info for troubleshooting

3) Backup/Restore your MBRAs root (assuming the MBR you are using is located on the 1st hard drive (which is true for most of us)

# dd if=/dev/hda of=bootsector.img bs=512 count=1

To restore back to the MBR

# dd if=bootsector.img of=/dev/hda

4) menu.lstAs suggested on another thread, back up your menu.lst as well (printer or usb)NB: menu.lst is only part of Grub legacy (ie, it's no longer part of the newer version of Grub, called Grub2)CheersEdit #1: Expanded the options available on SGD & formattingEdit #2: Even if you choose not to use SGD, stepping through its menus does provide helpful info

Edited by zeek
Link to comment
Share on other sites

I'd like to interject a question.Currently I have 2K, XP and PCLinux with Grub handling the selection of OS.I'd like to "upgrade" XP to Win 7, once I figure out how much RAM this built computer (not built by me and haven't heard from the builder in a couple of years) can handle. Since Win 7 works differently, can this work for me if I do the upgrade? If not, any ideas on how to tackle this or is it a waste of time?

Link to comment
Share on other sites

V.T. Eric Layton

Windows will probably take over your MBR as soon as you upgrade, so be prepared... you're going to have to boot with another source (Live CD) and reinstall your PCLOS GRUB. Once you do that, then you should be able to chainload Windows just like you've been doing. You probably won't even need to change you menu.lst to do it.

Link to comment
Share on other sites

you should be able to chainload Windows just like you've been doing.
I've heard the term - chainload windows but since I don't know how to do it, I don't think I'm doing it.I simply put in my SuperGrub boot floppy and went through the menus until I found one that said "repair windows mbr". That's what I picked.
Link to comment
Share on other sites

timeout 10color black/cyan yellow/cyangfxmenu (hd1,5)/boot/gfxmenudefault 3title linuxkernel (hd1,5)/boot/vmlinuz BOOT_IMAGE=linux root=UUID=fb6fb899-f5f1-4032-b701-0ef14d0b7b4f acpi=on splash=silent vga=788initrd (hd1,5)/boot/initrd.imgtitle linux-nonfbkernel (hd1,5)/boot/vmlinuz BOOT_IMAGE=linux-nonfb root=UUID=fb6fb899-f5f1-4032-b701-0ef14d0b7b4f acpi=oninitrd (hd1,5)/boot/initrd.imgtitle failsafekernel (hd1,5)/boot/vmlinuz BOOT_IMAGE=failsafe root=UUID=fb6fb899-f5f1-4032-b701-0ef14d0b7b4f failsafe acpi=oninitrd (hd1,5)/boot/initrd.imgtitle windowsroot (hd0,0)makeactivechainloader +1Well what do you know it shows chainloader +1 at the bottom. I guess I need to start reading up on this. :w00t: Looking over the title listings, linux-nonfb is not showing at bootup. I guess I'll have to search to see what that means too.My mbr went south after I tried to install Ubuntu on my slave drive. I partitioned, using Ubuntu and then it said I needed to reboot. When I rebooted, Ubuntu started partitioning my master drive and royally screwed up windows. I used my True Image image and restored windows but when I tried to boot up, I got a screen filled with numbers. So I fired up my Super Grub boot floppy and fixed windows. Eventually I installed PCLinux 2009 and I guess that took over. Somewhere I have notes on what choices I made.

Link to comment
Share on other sites

V.T. Eric Layton

Once you upgrade that XP installation to the the Windows 7 you were talking about, it may take control of your MBR again. Just fire up the PCLOS disk and I believe there is an option on that disk to repair your MBR/GRUB. Do that. Since you have a stock menu.lst (no customizations), you shouldn't even have to edit it for it to boot the newly upgraded Windows installation. As you see, you already have a chainloading entry for your existing XP. Since the upgrade will not change anything partition-wise for Windows, the existing chainload Windows entry will work fine. Easy-peasy! :(

Link to comment
Share on other sites

Thanks Eric. I think I can handle that.First I need to hunt and see how much RAM this home built computer can handle. I'm not about to do any upgrade while running just 1GB of RAM. Stupid me, I had it open this morning because I had to replace the CMOS battery and I swapped out a case fan hoping to make it quieter. I was so busy cleaning, I didn't even bother looking to see how many slots for RAM on the motherboard. <sigh> Oh well, I wanted to open it up again because the case now seems to pick up a vibration. I may run it with the side off to see if I can get it quieter. It has been noisy from day 1 and I never was really thrilled with the amount of noise.I just opened it and there are three slots for RAM. 512 sticks in two of the slots. I might just buy 3 - 1GB sticks and put them in; provided the board (ASUS) can handle that.

Edited by zlim
Link to comment
Share on other sites

isn't there a disk imager out there in linux land?
PCLinux has one which I've used. I think it is called, Make LiveCDNot only did I use it to make a live cd copy of my 2006 PVCLinux install on my desktop but I also used it to install on my HP notebook! My notebook was so messed up that I figured trying to run it wasn't going to do any further damage. I was shocked when it installed and worked!
Link to comment
Share on other sites

V.T. Eric Layton

EDIT: Oops! I just realized it was temmu asking about this, not Liz. I'm sure there are quite a few hard drive cloning apps, Liz. I"ve never had the need for one, so I don't know of any to recommend to you at the moment. Also, you could always use the "dd" command in terminal --> http://www.brunolinux.com/02-The_Terminal/...dd_command.html

Link to comment
Share on other sites

Liz:

  1. When updating Vista/Win7 via update packs one needs to consider the following: that it might be best to have Windows re-install its own bootloader into the MBR before doing the service pack updates. And after Windows competes its updates re-intall your favorite Linux distro's GRUB back into the MBR. (don't remember where I read this)
  2. Did everything work out OK????
  3. Sorry that I didn't respond until now.

Temmu

  1. Any other recovery ideas? I'm currently looking into Test-Disk
  2. Disk Imager? Are you thinking of backing up the MBR this way?

Cheers

Link to comment
Share on other sites

zeek, I haven't done this yet. I need to add more RAM before I consider "upgrading" for XP to Win 7.I've spent the last two days putting in and taking out a case fan. I'm trying to get the computer quieter. If I can't, I'm not going to waste money on RAM. My two current "work horses" my eeepc and an eMachines are so quiet that I really notice the noise on this 2K/XP/linux computer.My husband tells me I need to buy another computer. You have to love him because we have 8 computers in the house. :hysterical: 7 belong to us and one I will work on belongs to a friend. The last thing I need or want is yet another computer!

Link to comment
Share on other sites

Liz: Quiet is nice, mine likes to make its presence known to all who dare to come near. Wow! an octo-computer householdCheersPS: By the way, your husband is right - it's in the genes! (just kidding).

Edited by zeek
Link to comment
Share on other sites

Continuation of first post:Subject: menu.lst and chainloadingQuestion: What is going on when installing Gnu/Linux distros from GRUB's menu.lst file point of view?The discussion that follows shows the importance of the menu.lst file (and thus knowing which partition holds the GRUB files you need to re-install). When you are re-installing GRUB, you are also telling GRUB which menu.lst file to pay attention too - the one from distro_1 or the one from distro_2 or from distro_3, and so on.Overall Scenario:Windows already installedInstall the first distro, called distro_1Install another distro, called distro_2Assume:1 hard disk (hd0), with a few partitions on it(hd0,0) Windows partition(hd0,1) Distro_1 partition(hd0,2) Distro_2 partitionBackground on menu.lst file:

  • The menu.lst file contains commands that boots the distro properly.
  • Each distro has its own menu.lst file with certain commands added that will boot that particular distro properly.
  • Each distro's menu.lst file is stored in the partition where the distro's own root directory is stored. It's stored in a subdir of root called boot. So:. distro_1 menu.lst is located in the /boot subdirectory of (hd0,1). distro_2 menu.lst is located in the /boot subdirectory of (hd0,2)

All distros install the same GRUB files, but different menu.lst files. GRUB is installed in 2 different places: into the MBR and in /boot subdir. The memu.lst file is installed into one place: the /boot subdir of that particular distro.1) Install the 1st GNU/Linux distro:

  • You want to install distro_1 into the (hd0,1) partition
  • Distro_1 will install the necessary GNU/GRUB file into the MBR
  • Then, distro_1 will install its own menu.lst into its own partition - that is, into the /boot subdirectory of the (hd0,1) partition.
  • Now, when you reboot the computer, you should see options to boot both distro_1 and windows.
  • The basic steps the computer goes through to boot distro_1 are: BIOS --> MBR --> the MBR says now go to the /boot subdir of (hd0,1) and find the menu.lst and run those commands

2) Install the 2nd distro:

  • You want to install distro_2 into the (hd0,2) partition
  • Distro_2 will want to install GRUB into the MBR
  • But, you already have GRUB in the MBR (when you installed distro_1). So, you tell it not to install into the MBR, but install the necessary GRUB files into the root partition instead.
  • This last step installs the remaining Grub files into the /boot subidr of the (hd0,2) partition. This will also install distro_2's menu.lst file into the /boot subdir of the (hd0,2) partition.

IF you now reboot the computer after just installing distro_2, you will still see the options to only boot distro_1 and windows. To boot distro_2, you have to manually add distro_2 as an option to the menu.lst that belongs to distro-1. When that is done, you can now boot distro_2.To boot distro_2, the process now is: BIOS --> MBR --> use menu.lst from distro_1 located in /boot of (hd0,1) partition. And IF the user wants to boot distro_2 (after adding this option manually), then go to the /boot of (hd0,2) and use the menu.lst located in (hd0,2) for instructions on how to properly boot distro_2. This is an example of chainloading (ie, passing control to the config file that knows how to boot the distro you want to boot).In summary:In this scenario, when re-installing Grub - you need to know to choose to use the menu.lst from distro_1. When using SGD, choose the partition that contains distro_1's /boot subdir - (hd0,1). The (hd0,1 partition will contain the menu.lst file with all the distros listed that you want to boot. NB:

  1. The above is not complete (many details left out as there are a plethora of variations/options available)
  2. Obviously, when installing distro_2, one could select distro_2 to write to the MBR. Then have distro_2 automatically write the proper commands into its own menu.lst file to boot all the other distros. Unfortunately, this doesn't always work because some distro_2s will not recognize the other distros and thus not write the proper commands to boot the other distros.
  3. I selected the scenario to have distro_2 to install its bootloader into the root partitions instead of the MBR for a very good reason: it simplifies things and preempts problems (eg, kernel upgrades).
  4. A newer version of GRUB is currently being tested. The newer version is called GRUB2, while the older one is called "Grub Legacy." Grub2 does not have a menu.lst among other differences, but the basic idea still holds - that each distro will need to install its Grub config file (eg, menu.lst) into its own partition in order to boot properly.

CheersEdit : formatting

Edited by zeek
Link to comment
Share on other sites

Disk imager:ClonezillaI've always used partimage or dd, and that's what Clonezilla uses but with a more friendly interface.
I use partimage, been using it for quite sometime.It works with Windows (NTFS) and all flavors of linux.I presently maintain 6 images on a couple of Fat 32 USB flash drives and can restore them from there.Those 6 images are Win 7, XP Pro, Ubuntu Hardy 64 bit, Ubuntu Intrepid 64 bit and both KDE and Gnome versions of PCLinuxOS 2009.I just recently replaced them with fresh images after extensive system updates.The older images were waiting in the wings in case I screwed up the updates.Partimage only creates images of the used space of a partition.It has built in compression options to help keep the images fairly small.It also will split the image up into smaller pieces to accomodate storage on Fat 32 media.You can store the images on any type of media but a restore must be from Fat 32 or ext3 formatted media.I my case it takes about 24 minutes to create and store directly to a 16 GB Corsair thumbdrive my 9 GB Win 7 install.That's 9 GB of a 22 GB NTFS partition.I creates two images of less than 4 GB and with moderate compression that amounts to about 4.5 GB about half the size of the original used space.Restore from the thumb drive is very fast (about 4 minutes for the above example).The version I use is on the SystemRescueCD and the links below are for tutorials on how to use it from SystemRescueCD.The first link is for a how to I wrote and posted a couple of years ago at the Ubuntu forums.The second one is a more polished how to by another forum member based on my tutorial.He PM'd for permission before posting.http://ubuntuforums.org/showthread.php?t=226402http://ubuntuforums.org/showthread.php?t=287522Enough of partimage.More OT, I first began experimenting with Linux (Ubuntu Breezy) and dual/multibooting at about the same time.A fantastic source of info was a tutorial posted by an Aussie, hermanzone, that contained a wealth of knowledge aboutdual booting, GRUB and FSTAB. Recently his provider dropped support for his web site and after seeking advice at the Ubuntu forums he decided to keep the site alive with another ISP.If you had his old site bookmarked it won't work.Below is his new site.http://members.iinet.net/~herman546/index.htmlBelow is a link to the Ubuntu thread he sought advice from.http://ubuntuforums.org/showthread.php?t=1176678 Edited by Frank Golden
Link to comment
Share on other sites

Disk imager:ClonezillaI've always used partimage or dd, and that's what Clonezilla uses but with a more friendly interface.
Thank you, sunrat for the clonezilla link.I've been playing with it for the last couple of hours and I must say I'm impressed.It is slicker than partimage but more complicated and almost entirely GUI.It might be quicker than partimage after I get used to it.I can see me replacing partimage with is some day.I was able to use clonezilla to fix an issue I've had with partimage and Win 7.My Win 7 partimage would restore fine on my main HDD, no issues butI also have a spare HDD with the identical partition structure to my main drive.In the past when I created fresh images of my Windows and linux installs I would restore them to the spare drive so that I'd havea complete copy of my main drive in case my main drive failed.For some inexplicable reason restoring Win 7 partimages to my spare drive would fail to boot correctly.It would boot to the point of the welcome screen then and then hang.It would eventually finish to a blank desktop and a message that the copy of Win 7 was not genuine.XP and my linux images would install with no issues but Win 7 wouldn't.All this with partimage.Clonezilla avoids this problem entirely, sucessfully restoring Win 7 to my spare drive.I suspect the issue has something to do with my spare drive having a different serial numberfrom the drive Win 7 was initially installed on. Some kind of WGA issue.Again thanks, another great tool in my toolkit. Edited by Frank Golden
Link to comment
Share on other sites

Continuation: This is a generalized overview of booting process. See GNU GRUBProvides a clue as to where the problem is occurring.A simple view of the boot process from GRUB's point of view. ----> BIOS----> MBR portion of the hard disk located and accessed. ----> GRUB stage1 gets loaded into memory from the MBR of the hard disk----> GRUB stage2 gets loaded into memory from your distro's /boot/grub/ dir----> Kernel gets loaded into memory from your distro's /boot/ dir and takes over the boot processTo fix a booting problem it is helpful to know where the boot problem is occurring in the boot loading sequence....If there is no stage1 in the MBR ---> can't boot...If stage1 can't find stage2 --> can't boot...if stage2 can't read your distro's menu.lst file ---> can't boot properly...If stage2 can't load your distro's kernel --> can't boot your distroNow, a more expanded view of the processIs the boot problem occurring at location (0)? or location (1)? etc.----> BIOS----> (0) ----> MBR ----> (1)----> stage2 GRUB file loaded into memory----> stage2 now presents a graphical interface asking you what distro to boot by reading your distro's /boot/grub/menu.lst file and presenting you with options of which distro to boot. If no option is selected, it boots the default distro listed in the menu.lst file----> (2)----> Kernel and initrd gets loaded into memory (initrd has the kernel modules)----> GRUB tells the kernel where your distro's root [ / ] partition is located----> GRUB now exits (it has done it's job)----> (3)----> Now the kernel takes over or another bootloader takes over by being chainloaded===========================Error at Location(0) An error at this step - think what can go wrong with the MBR1) GRUB stage1 wasn't put into MBR of the hard disk.2) The hard disk containing the MBR can't be located or recognized by GRUB3) The stage1 file from a another distro's root partition is being loaded into memory instead.4) Or . . .Error at Location(1)An error here means that stage1 is having problems loading stage2 into memory. Stage2 is located in your distro's /boot/grub directory.So, the question is: where is stage2, and why can't it be found?Could it be that: 1) the partition where stage2 is located can't be mounted? Why? 2) the filesystem where stage2 is located is corrupted? --> Need to run fsck3) it went to the wrong place to find the stage2 file (another partition perhaps? Or even a different hard disk?)4) Or . . .Error at Location(2)An error here can mean:1) stage2 can't find your distro's menu.lst file in your distro's /boot/grub directory2) stage2 found a menu.lst file, but it is the wrong one (it found the one from a different distro, but not from your distro) 3) stage2 found your distro's menu.lst file, but there is an error in one of the lines of the /boot/grub/menu.lst file. Eg, the kernel line is pointing somewhere else than expected. 4) the filesytem where stage2 is located is corrupted6) Or . . .Error at Location(3) GRUB passed control to the kernel, so GRUB is done. Just a final note: It is amazing how well GRUB actually does it job considering all what it has to deal with: BIOS idiosyncrasies - has to then figure out the hardware your computer hasDifferent filesytems types (ext2/3/4, FAT32, etc)Multibooting with different distros, OS's, multiple hard-drives with many partitions, multitude menu.lst files, etcCheersEdit: Generalized, formatting.

Edited by zeek
Link to comment
Share on other sites

ContinuationSome parts of the menu.lst talk to GRUB, while other parts of the menu.lst file talk to the kernel.The part talking to GRUB, must use language that GRUB understands.The part talking to the kernel must use language that the kernel understands.For example This part of the menu.lst is talking to GRUBkernel (hd0,1)/boot/vmlinuz--->This part tells GRUB to load your distro's kernel from your distro's (hd0,1)/boot/ directoryThis part of the menu.lst is talking to the kernelroot=/dev/hda2--->This part tells the kernel that your distro's root partition [ / ] is on hda2So the menu.lst file must use the correct terminology when talking to GRUB or the kernelCheersEdit: Generalized, formatting

Edited by zeek
Link to comment
Share on other sites

  • 11 months later...
rescatux, highly recommended!
I was looking at that last time I was at SuperGrubDisc site. It looks like it is SGD-NG. It's great that it works so well. Thanks for the report. :)
Link to comment
Share on other sites

Hello,I think there is also a "stage 1.5" when Grub is installed in the HDD MBR, located in the unused blocks just following the MBR.It is copied from one of the /boot/grub/xxxx_stage1_5 files, according to the file system.Doesn't seem required when Grub is installed in a root partition. I don't know why ...So now, when I save my MBR, I use "count=18" (size of /boot/grub/e2fs_stage1_5 file + 1 block) in the dd command.This is true for Grub Legacy, I have not really tried Grub 2 now.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...