Page 5 of 8 FirstFirst ... 34567 ... LastLast
Results 41 to 50 of 76

Thread: HowTo: Revert from grub2 to Legacy Grub.

  1. #41
    Join Date
    Apr 2008
    Beans
    11,707

    Re: HowTo: Revert from grub2 to Legacy Grub.

    This post is a work in progress and you should only try this if you're adventurous! My goal is to enable anyone to restore any Linux or Windows MBR with any Ubuntu Live CD.

    Although it's been around for a while now Grub 2 introduced the problem of users not being sure what version of grub they have installed and therefore just exactly how to restore Grub after the installation of Windows, or some other event, wipes out Grub. IMHO the best solution is to mount and chroot the Ubuntu (or Mint/other derivative) to first determine what version of Grub is installed and then to "recover" Grub while in the chroot so you're dealing with the grub packages installed in that OS. This eliminates the need of using a specific version of Ubuntu/Mint/derivative Live CD.

    Of course the first thing to do is learn what partition Ubuntu is installed on, and also whether or not you have a separate "/boot" partition. This would also be an excellent time to describe drive and partition designations in Ubuntu:

    Drives are designated as /dev/sda, /dev/sdb, /dev/sdc, etc. the last letter indicates the drive number, eg:
    /dev/sda = drive #1
    /dev/sdb = drive #2
    /dev/sdc = drive #3

    Partititions are designated with a number following the drive designations, eg:
    /dev/sda1 = drive #1/partition #1
    /dev/sda2 = drive #1/partition #2
    /dev/sdb1 = drive #2/partition #1

    In many cases you may be able to determine the Ubuntu partition simply by running "sudo fdisk -l" (BTW that's a lower case L), but if the partitioning scheme is at all complicated, or if you simply have any doubts, I recommend running the Boot Info Script.

    http://bootinfoscript.sourceforge.net/

    The first two sections of the RESULTS.txt show what OS's bootloader is installed to the mbr of which drive and a list of all partitions including what OS is installed to what partition.

    I should also add some general info about my "mount and chroot" procedure. It's not a true script but rather just a series of commands connected by "space&&space", so if one part of it fails the rest will fail! I strongly recommend that you copy-n-paste all commands. This is also intended only for determining the version of and restoring grub. For installing/removing packages, etc. more commands are needed!

    This procedure is actually well explained here:

    https://wiki.ubuntu.com/Grub2#Recove...20via%20LiveCD

    Particularly pay attention to what's said there about mounting and unmounting a separate "/boot" partition if used! My "script" does NOT include the commands for mounting and unmounting "/boot"!

    So once you've determined what partition to mount simply boot any Ubuntu Live CD and, in Terminal, run:

    Code:
    sudo mount /dev/sdXY /mnt && sudo mount --bind /dev /mnt/dev && sudo mount --bind /proc /mnt/proc && sudo mount --bind /sys /mnt/sys && sudo chroot /mnt
    Of course the X and Y need to be replaced by your proper drive and partition designations (the easiest way to do so is to "copy-n-paste" the command and then use the left and right arrow keys to edit).

    To be certain you've mounted the proper partition/OS run:

    Code:
    lsb_release -a
    If that appears to be right then check the installed version of Grub:

    Code:
    grub-install -v && aptitude show grub|head -2 && aptitude show grub-pc|head -2 && aptitude show grub-common|head -2 && aptitude show os-prober|head -2
    Example:

    grub-install (GNU GRUB 1.98-1ubuntu6)
    Package: grub
    State: not installed
    Package: grub-pc
    State: installed
    Package: grub-common
    State: installed
    Package: os-prober
    State: installed
    You can see there that the grub version is "1.98-1ubuntu6" which is grub 2, basically "0.9*" = legacy grub, and "1.9*" = grub 2. As far as packages are concerned:

    grub = legacy grub
    grub-pc = grub 2
    grub-common is shared by both legacy grub and grub 2
    os-prober is particularly necessary for the proper function of grub 2

    So, if that shows you have Grub 2, as in the example, installing it to the MBR of the proper drive is as simple as:

    Code:
    grub-install /dev/sdX
    Should that produce any errors then:

    Code:
    grub-install --recheck /dev/sdX
    Of course in both of those examples the X must be replaced with the proper DRIVE designation! I can't stress strongly enough that it's very seldom wise to install grub (particularly Grub 2) to a partition rather than the MBR of a drive!

    I've also found that if any partitioning changes resulted in the loss of grub 2 boot it's a good idea to run:

    Code:
    update-grub
    Had that shown you had legacy grub you'd need to open a Grub shell so run the command::

    Code:
    grub
    Note: I've noticed while working in a grub shell that the enter key in the numerical block of the keyboard doesn't always work properly, so use the enter key just above the right shift key!

    Then:

    Code:
    find /boot/grub/stage1
    That will provide an output like (hdX,Y) which you'll need to use in the next step:

    Code:
    root (hdX,Y)
    You see I've used (hdX,Y) from the "find" command, of course you'll use the proper drive/partition designations as indicated by that command. Then:

    Code:
    setup (hdX)
    There I've used only the proper drive designation indicated by the "find" command.

    If correct you should see an output like:

    Checking if "/boot/grub/stage1" exists... yes
    Checking if "/boot/grub/stage2" exists... yes
    Checking if "/boot/grub/e2fs_stage1_5" exists... yes
    Running "embed /boot/grub/e2fs_stage1_5 (hd0)"...* 15 sectors are embedded.
    succeeded
    Running "install /boot/grub/stage1 d (hd0) (hd0)1+15 p (hd0,1)/boot/grub/stage
    2 /boot/grub/menu.lst"... succeeded
    Done.
    Hopefully you see three "yes" and two "succeeded" responses. If not something is wrong.

    When done we need to exit the grub shell so be sure to run:

    Code:
    quit
    Now, whether you recovered legacy grub or Grub 2, you must exit the chroot and umount when done:

    Code:
    exit
    Code:
    sudo umount /mnt/dev && sudo umount /mnt/sys && sudo umount /mnt/proc && sudo umount /mnt
    Now, how to recover a Windows MBR with only an Ubuntu Live CD:

    Code:
    sudo apt-get install lilo
    Code:
    sudo lilo -M /dev/sdX mbr
    There again, the X must be replaced with the proper drive desigantion!

    Note: If I use Lilo to restore a Windows MBR using my "installed" Ubuntu I always like to remove the package "lilo" when done just to prevent some later "conflict" with grub updates, this of course is as easy as "sudo apt-get remove lilo".
    Last edited by kansasnoob; June 12th, 2010 at 10:14 PM.

  2. #42
    Join Date
    Jul 2008
    Beans
    7

    Re: HowTo: Revert from grub2 to Legacy Grub.

    I would like to add my two cents. I used your instructions, but having a separate /boot partition, I had to make some tweaks.

    Code:
    sudo grub-install --root-directory=/boot /dev/sda
    Even after that, I was greeted with a GRUB console upon boot. Turns out that it was looking for /boot/grub/menu.lst in the /boot partition, instead of just grub/menu.lst. So I fixed it with

    Code:
    cd /boot
    sudo ln -s . boot
    Now, I'm back to good 'ole Grub1. Thanks for your instructions!!!

  3. #43
    Join Date
    Apr 2008
    Beans
    11,707

    Re: HowTo: Revert from grub2 to Legacy Grub.

    Quote Originally Posted by Corn Flake View Post
    I would like to add my two cents. I used your instructions, but having a separate /boot partition, I had to make some tweaks.

    Code:
    sudo grub-install --root-directory=/boot /dev/sda
    Even after that, I was greeted with a GRUB console upon boot. Turns out that it was looking for /boot/grub/menu.lst in the /boot partition, instead of just grub/menu.lst. So I fixed it with

    Code:
    cd /boot
    sudo ln -s . boot
    Now, I'm back to good 'ole Grub1. Thanks for your instructions!!!
    Aaaaaaaaaaaah, you're very right! I personally detest the use of a separate /boot partition unless absolutely necessary but I really should add a bit about that.

    Thank you

  4. #44
    Join Date
    Apr 2008
    Beans
    11,707

    Re: HowTo: Revert from grub2 to Legacy Grub.

    Just needed a place to throw a screenshot:

    Click image for larger version. 

Name:	Screenshot.jpg 
Views:	143 
Size:	60.6 KB 
ID:	158946

  5. #45
    Join Date
    Apr 2008
    Beans
    11,707

    Re: HowTo: Revert from grub2 to Legacy Grub.

    Quote Originally Posted by Corn Flake View Post
    I would like to add my two cents. I used your instructions, but having a separate /boot partition, I had to make some tweaks.

    Code:
    sudo grub-install --root-directory=/boot /dev/sda
    Even after that, I was greeted with a GRUB console upon boot. Turns out that it was looking for /boot/grub/menu.lst in the /boot partition, instead of just grub/menu.lst. So I fixed it with

    Code:
    cd /boot
    sudo ln -s . boot
    Now, I'm back to good 'ole Grub1. Thanks for your instructions!!!
    Thinking about this a bit more I need to try something, but I believe if I drop the "sudo grub-install /dev/sda" entirely and rely only on installing grub to the mbr using a grub shell this situation should be avoided.

    In the next day or two I'll do a couple of tests, actually performing a test install with a separate /boot to find out

    Thanks for making me aware of this.

  6. #46
    Join Date
    Apr 2008
    Beans
    11,707

    Re: HowTo: Revert from grub2 to Legacy Grub.

    Quote Originally Posted by kansasnoob View Post
    Thinking about this a bit more I need to try something, but I believe if I drop the "sudo grub-install /dev/sda" entirely and rely only on installing grub to the mbr using a grub shell this situation should be avoided.

    In the next day or two I'll do a couple of tests, actually performing a test install with a separate /boot to find out

    Thanks for making me aware of this.
    Nope! Tried that and I'm wrong so I must do an install with a /boot to do more testing

    I still maintain that using a separate /boot is often a problem in itself!

  7. #47
    Join Date
    Apr 2008
    Beans
    11,707

    Re: HowTo: Revert from grub2 to Legacy Grub.

    Quote Originally Posted by kansasnoob View Post
    Nope! Tried that and I'm wrong so I must do an install with a /boot to do more testing

    I still maintain that using a separate /boot is often a problem in itself!
    OK I think I'm gaining. It appears instead of running "find /boot/grub/stage1" if a separate /boot partition is used then the command should be:

    Code:
    find /grub/stage1
    Then the output of the terminal after running "setup" is slightly different:

    grub> setup (hd1)
    Checking if "/boot/grub/stage1" exists... no
    Checking if "/grub/stage1" exists... yes
    Checking if "/grub/stage2" exists... yes
    Checking if "/grub/e2fs_stage1_5" exists... yes
    Running "embed /grub/e2fs_stage1_5 (hd1)"... 17 sectors are embedded.
    succeeded
    Running "install /grub/stage1 (hd1) (hd1)1+17 p (hd1,0)/grub/stage2 /grub/menu
    .lst"... succeeded
    Done.
    But I still need to do a bit more retesting to be certain.

  8. #48
    Join Date
    Aug 2010
    Beans
    1

    Re: HowTo: Revert from grub2 to Legacy Grub.

    Nice HowTo,
    I'm trying to install grub2 to dual boot ubuntu 10.04 64-bit and windows 7, in Alienware M17x laptop. I did the revert process down to legacy but I could not get the windows partition to load in grub. Then I went back to grub-pc but then I completely lost the ability to load windows even with a SGD (which worked at the beginning to load either OS). Any hints and help will be greatly appreciated.

  9. #49
    Join Date
    Aug 2010
    Location
    Anacortes, WA
    Beans
    9
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: HowTo: Revert from grub2 to Legacy Grub.

    hey i know this is totally different to this but can anyone tell me how to create a thread???? im lost with this and i have may question to do about ubuntu

  10. #50
    Join Date
    Apr 2008
    Beans
    11,707

    Re: HowTo: Revert from grub2 to Legacy Grub.

    Quote Originally Posted by darkbler View Post
    Nice HowTo,
    I'm trying to install grub2 to dual boot ubuntu 10.04 64-bit and windows 7, in Alienware M17x laptop. I did the revert process down to legacy but I could not get the windows partition to load in grub. Then I went back to grub-pc but then I completely lost the ability to load windows even with a SGD (which worked at the beginning to load either OS). Any hints and help will be greatly appreciated.
    I would need to see the output of the Boot Info Script before proceeding:

    http://bootinfoscript.sourceforge.net/

    I'm curious why you needed to revert to begin with, what problems did you encounter with grub2?

    It would actually be best to start a new thread here:

    http://ubuntuforums.org/forumdisplay.php?f=333

    You'll get more traffic there

Page 5 of 8 FirstFirst ... 34567 ... 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
  •