Howto Boot Grub from windows

From Super Grub Disk Wiki
Jump to: navigation, search

How do I chainload GRUB from Windows boot.ini

Contents

Other titles for this same problem.

  • GRUB is a great but I prefer not to install it on my mbr.
  • How do I chainload GRUB from Windows Vista
  • I have Linux in my second hard disk and I follow other howto instructions but I cannot get it to be chainloaded from Windows.
  • Is there a safe way to access Linux on the external drive and have xp on the internal drive while being able to disconnect the external drive from pc at any time? ([b]You should run Fix Boot of Windows[/b] for your internal hard disk before these steps.)

Advice

adrian15 advice for this kind of task is #Classical solution


Neogrub lazy solution

TODO: Talk about Neogrub that it is included with EasyBCD I think.


Classical solution

Please continue reading at: Common Final Solution

Advanced solution

SITUATION WHEN GRUB FILES AND BOOT SECTOR ARE NOT THE SAME PARTITION

Problematic solution

TODO EXPLAIN THE USE OF LIVESWAP WHEN DETECTED HARD DISK ORDER IS NOT OK.

GRUB solution (on its own)

This method is only valid when you want to boot a Linux partition that it is found in the same hard disk as the windows one (i.e. the first hard disk).

This installs Stage1 of Grub to the first sector of partition containing the Grub folder. To get started we need to identify the partition containing the Grub folder. (Usually the same as the Linux partition) Say it is (hd0,3) (Usually, but not always, identified in Linux as: /dev/sda4).

Boot with your grub disk or with your already installed grub.

Press 'c'

At the grub> prompt type:

  • root (hd0,3)
  • setup (hd0,3)
  • quit #(With Linux working)
  • reboot #(From grub disk)

Please continue reading at: Common Final Solution

GRUB solution (Linux shell)

This installs Stage1 of Grub to the first sector of partition containing the Grub folder. We will use the "device" function of the grub-shell to ensure that Grub uses the correct map between the bios drives and linux devices, and also to ensure that Grub uses the hard drive numbers.

To get started we need to identify the partition containing the Grub folder. (Usually the same as the Linux partition) Say it is (hd2,3) and /dev/sdb4. (The (hd2,3) must be how grub sees the partition during boot-up)

Open a terminal in Linux and type

  • su #(use sudo -i in Ubuntu)
  • grub

and at the "grub>"prompt

  • device (hd2) /dev/sdb
  • device (hd0) /dev/sdb
  • root (hd2,3)
  • setup (hd0,3)
  • quit

Please continue reading at: Common Final Solution

GRUB2 solution (on its own)

As long as I know GRUB2 cannot install itself on its own.

GRUB2 solution (Linux shell)

This installs first part of Grub2 to the first sector of partition containing the Grub folder.

Let's suppose that you know that your Linux partition is /dev/sda3

What you need to to is run:


Open a terminal in Linux and type

  • su #(use sudo -i in Ubuntu)
  • grub-install --force /dev/sda3

Please continue reading at: Common Final Solution

Common Final Solution

As a final solution we need somehow Windows to chainload our Linux partition. If we use easybcd we can avoid having to copy a file from a live cd to our Windows partition and setting up the boot. If we are geeks and classical we will have to edit boot.ini or the new Vista file manually in order to make things work.

Windows Vista (with easybcd help)

  1. Download and run EasyBCD 1.7.2(or any version i think)
  2. If program ask for boot drive just select your windows partion
  3. Choose Add/remove Entries
  4. At "Add an Entry" select "Linux"
  5. Change Type to "Linux"
  6. Enter Name box with any name u want
  7. At Drive Select Your Ubuntu Partion
  8. Click "Add Entry"
  9. Click "Save"
  10. Restart, you have done ^ ^

Classical Final Solution

Once grub has been installed to a partition we need to get its boot sector to a file in order to boot it from Windows.

Let's boot with a live cd and open a terminal.

Identify the partition containing the grub folder. (Usually the same one as the Linux partition)

In this example the identified grub partition is sda3.

Plugin your pendrive and open it. Identify your plugged pendrive associated folder.

In this example: Pendrive mount point is: /media/disk

From a terminal (Aplications -> System -> Terminal) please run:

  • sudo -i | su

(When prompted enter your current user password or your root password in non-sudo systems such as Debian. If you do not know how to type | symbol please only type sudo -i)

  • dd if=/dev/sda3 of=/media/disk/linux.bin count=1 bs=512
  • sync
  • Right Click on your pendrive icon in your desktop and click on umount or extract.

Now let's boot into Windows.

Plug in your pendrive and copy the linux.bin file into c:\ folder.

Windows XP/Windows 2000/NT/Windows

Now let's edit boot.ini and add this line at its bottom:

c:\linux.bin="Linux"

Windows Vista (manually)

TODO



Now when rebooting if you boot windows you will get a Windows menu with two options: Windows and the new Linux option which will chainload GRUB.

Finally there is an optional step that it is removing grub so that it chainloads Windows menu in the first place automatically at boot.

Rescatux

This feature is not yet available at the Rescapp program. It is available at the Super Grub Disk included with Rescatux. If you want to have this feature at the Rescapp program please complain at the super grub disk mailing list.

Tecnical explanation

One thing you should know

  • These methods only restore GRUB successfully if a stage1,stage2 (and optionally a stage1_5 file) is found. If you have deleted these files the GRUB solution (Linux shell) might help although it might be better to reinstall GRUB from a chroot environment got from a live cd.

If your Linux filesystem has errors GRUB might not be able to find its files even if they are there. So sometimes is advised to try to run the:

fsck -yc /dev/DEV

command as root where DEV is your linux partition device.

fsck -yc /dev/sda3 

will fix the third partition from an scsi or sata first disk (Although it might not actually be the first one).

  • OpenSolaris GRUB cannot be restored to a partition which this method. You need to boot Linux and then use the install-grub command. See man install-grub for more info.

TIP

If you cannot get to restore grub this way you can always try to boot Linux and then use the Grub Solution (on its own) method or the Grub Solution (Linux shell) method.

Similar problems

External resources

TODO