Page 1 of 2 12 LastLast
Results 1 to 10 of 19

Thread: GRUB restoration

  1. #1
    Join Date
    Jun 2007
    Location
    Rochester, NY
    Beans
    595
    Distro
    Ubuntu

    GRUB restoration

    I just had a 3-4 hour fight with my computer because I'm into playing with other distros, but to me, liveCD's and VM/parallels stuff is useless. So I went to try FreeBSD, who's boot loader did not play nice (froze up) with my computer (DV9000). So I used a program called unetbootin through windows which changed the boot.ini file to boot FreeBSD without their gay boot loader. So it installed, and put their boot loader back on, and then I was stuck.

    Here's where things got bad: I tried to put GRUB on, though there was no distributions installed to get it from - I was trying to install it from live CD's, I couldn't even compile it from source because gparted doesn't have a C compiler and I didn't have any distros handy.

    Finally I went to Ubuntu's live CD to skip the install and install GRUB - well it didn't skip the install, so I got Ubuntu on it (not sure if I'm going to keep it or not, 10Gb is kinda small for what I'd give Ubuntu, though it'd provide some Linux stability..) - I use Ubuntu daily on my desktop, afraid to upgrade I'm playing in gutsy.

    That's all irrelevant, the point is I need a fast way to restore GRUB in case I put any other bad operating systems on that rape my boot record, which begs an interesting question.

    I knew I wanted to use GRUB when I formatted the computer, so I put Windows XP Pro (Vista's bootmgr was killing me with GRUB) on the second hard drive (it runs dual 80's), but ONLY the primary was bootable. My premise for this was that I could install GRUB on the primary boot record and point to the windows part on the second hard drive..Though while I didn't have GRUB installed, XP still booted fine. If my computer can't boot off the 2nd hard drive (you can't switch the options around in the BIOS), how the heck was it booting the second disk? Only answer I could come up with was if it couldn't load the boot record in the first drive, it went to the second, since the first drive was blank it defaulted to the second.

    With that in mind, I thought it would be rather important to take note of the fact that I NEED GRUB installed because of the amount of partitions + I want windows to stay alive and the like - So I need a fast, quick, (don't really care if it's easy) way to install GRUB back on that first boot record.

    I ran into some instructions online that said I can simply copy the drive (without specifying a partition) and it'll copy the boot rec - like:

    dd if=/dev/sda of=/media/USB/grub.bin

    Would that work? I need like a guaranteed way of backing up or restoring GRUB in case this crap happens again.

    Sorry for making the post so long.

    Thanks for your time.
    I don't believe in bad operating systems, simply that certain operating systems are better at doing certain things.

  2. #2
    Join Date
    Jun 2006
    Location
    Texas
    Beans
    3,931
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: GRUB restoration

    Sounds like a dedicated GRUB partition was made just for you. Doesn't need very much room mine is 16MB and only has 2 MB used. (mostly splash screens). Great to when you play with multiple OS that come and go.

    Here's a good how to if you have any questions I be around off and on.
    IDBS make a dedicated GRUB partition

    Look around the page all kind of good stuff on GRUB.
    UNIX was not designed to stop you from doing stupid things, because that would also stop you from doing clever things. -- Doug Gwyn
    SystemRescueCd | Dual Boot | psychocats | FAQ

  3. #3
    Join Date
    Jul 2007
    Location
    Melbourne, Australia
    Beans
    3,475
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: GRUB restoration

    To reinstall grub, boot live cd; go to terminal
    sudo grub
    find /boot/grub/stage1
    Output will be (hdx,x)
    root (hdx,x)
    inserting the corresponding numbers in place of x + a mention of the file system
    setup (hdx)
    use first number only, most often (hd0)
    quit
    As for the booting question, I believe you have given yourself the answer. As primary is blank/raw, the next potentially bootable device would be searched for, in your case the 'secondary' hard drive.
    Hope this helps.
    By the way grub and windows get on much better if windows is on the primary drive, on the first partition. You will save yourself many potential headaches by setting up that way with windows installed before any linux distro's.
    Windows is the best virus detector on the market!
    Ubuntu attracts Human Beings - Windows attracts viruses and worms

  4. #4
    Join Date
    Apr 2008
    Beans
    3,317
    Distro
    Kubuntu 9.10 Karmic Koala

    Re: GRUB restoration

    Code:
    dd if=/dev/sda of=/media/USB/grub.bin
    This will try to copy you whole drive hard drive to that file. I don't see any reason why you want to do that.
    Last edited by meierfra.; June 8th, 2008 at 08:17 PM.

  5. #5
    Join Date
    Apr 2008
    Beans
    3,317
    Distro
    Kubuntu 9.10 Karmic Koala

    Re: GRUB restoration

    Sounds like a dedicated GRUB partition was made just for you
    I agree.

    Backing up Grub does not make much sense. Reinstalling Grub is pretty easy, and your backup probably would not work, since your configuration has changed. Grub comes in two parts: One part is on the MBR or a boot sector. The other part needs to be on some partition. So if you want Grub to be independent from your various OS's, you need to dedicated Grub partition.

  6. #6
    Join Date
    Jun 2007
    Location
    Rochester, NY
    Beans
    595
    Distro
    Ubuntu

    Re: GRUB restoration

    Quote Originally Posted by meierfra. View Post
    Code:
    dd if=/dev/sda of=/media/USB/grub.bin
    This will try to copy you whole drive hard drive to that file. I don't see any reason why you want to do that.
    That's what I thought, but some site with GRUB info said differently, which is why I posted here.

    Quote Originally Posted by meierfra.
    I agree.

    Backing up Grub does not make much sense. Reinstalling Grub is pretty easy, and your backup probably would not work, since your configuration has changed. Grub comes in two parts: One part is on the MBR or a boot sector. The other part needs to be on some partition. So if you want Grub to be independent from your various OS's, you need to dedicated Grub partition.
    Well I was hoping to make an image out of it that I could just slap on the boot record if things got nasty.

    Quote Originally Posted by bumanie
    As for the booting question, I believe you have given yourself the answer. As primary is blank/raw, the next potentially bootable device would be searched for, in your case the 'secondary' hard drive.
    Hope this helps.
    By the way grub and windows get on much better if windows is on the primary drive, on the first partition. You will save yourself many potential headaches by setting up that way with windows installed before any linux distro's.
    I saw that how-to re-install GRUB method before, but I thought since you're searching /boot it was copying it out of an existing installation with GRUB. Though I'm now assuming that's the /boot of the CD?

    Why is putting windows on the primary drive a better idea in terms of saving me headaches? Then I would have to use the windows boot loader to boot something on my second hard drive, unless the distro put the /boot partition on the boot record of the primary in which case it makes no difference.

    Quote Originally Posted by louieb
    Sounds like a dedicated GRUB partition was made just for you. Doesn't need very much room mine is 16MB and only has 2 MB used. (mostly splash screens). Great to when you play with multiple OS that come and go.

    Here's a good how to if you have any questions I be around off and on.
    IDBS make a dedicated GRUB partition

    Look around the page all kind of good stuff on GRUB.
    How would a dedicated GRUB partition help me? Any OS that I install will still slap their boot loader on the boot record.
    I don't believe in bad operating systems, simply that certain operating systems are better at doing certain things.

  7. #7
    Join Date
    Apr 2008
    Beans
    3,317
    Distro
    Kubuntu 9.10 Karmic Koala

    Re: GRUB restoration

    How would a dedicated GRUB partition help me? Any OS that I install will still slap their boot loader on the boot record.

    Just need to install the boot loader of the new OS to the "boot sector" of the partition of your new OS, instead to the MBR (every OS I ever installed gave me that option)

    Then add the following to your menu.lst on your grub partition.

    title Another OS which isn't nearly as good as Ubuntu
    chainloader (hd2,3)+1


    Of course you need to replace (hd2,3) by the appropriate numbers for the partition of your new OS
    Last edited by meierfra.; June 9th, 2008 at 12:44 AM.

  8. #8
    Join Date
    Apr 2008
    Beans
    3,317
    Distro
    Kubuntu 9.10 Karmic Koala

    Re: GRUB restoration

    dd if=/dev/sda of=/media/USB/grub.bin

    This will try to copy you whole drive hard drive to that file. I don't see any reason why you want to do that.

    That's what I thought, but some site with GRUB info said differently, which is why I posted here.

    There is a variation of the command which can be used to add an OS to the XP bootloader:

    1) Install the boot loader of your new OS to the boot sector of its partition.

    2) "dd if=/dev/sda5 of=New_OS.bin bs=512 count=1"

    (where /dev/sda5 is the partition of your New_OS

    3) Copy New_OS.bin to the C: drive of your Windows partion.
    (or you could have mounted your Windows partition in Step 2 and use "dd" to directly place "New_OS.bin" on the C" drive)

    4) Add the line "C:\New_OS.bin" to boot.ini

    (If the new OS and Windows are on different hard drives, the procedure is slightly more complicated)

    But if you use this method and the Windows Partition becomes corrupt, you will not be able to boot into any of your OS's.

    So using a dedicated Grub partition is easier and more reliable.
    Last edited by meierfra.; June 9th, 2008 at 12:45 AM.

  9. #9
    Join Date
    Jun 2007
    Location
    Rochester, NY
    Beans
    595
    Distro
    Ubuntu

    Re: GRUB restoration

    Alright, So I just create a partition of 16mb or so and every time I put on an OS I have it install the /boot partition to that? Then when using grub just use the chainloader command? So this way GRUB is always being used?
    I don't believe in bad operating systems, simply that certain operating systems are better at doing certain things.

  10. #10
    Join Date
    Apr 2008
    Beans
    3,317
    Distro
    Kubuntu 9.10 Karmic Koala

    Re: GRUB restoration

    every time I put on an OS I have it install the /boot partition to that?
    No. Don't make a separated boot partition and don't used the grub partition as a boot partition. The location of the boot loader is not the same as the location of /boot.

    Say you are installing your new OS on /dev/sda5. At some stage during the installation process you will have the option to choose a location for your boot loader. The default location of the boot loader is the MBR ("/dev/sda" or (hd0)" . Change it to /dev/sda5. (This will put the boot loader on the first sector of /dev/sda5)

    For example when you install Ubuntu, you have to choose "advanced" at step 7 of the installation to change to location of the boot loader.
    Last edited by meierfra.; June 9th, 2008 at 12:58 AM.

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •