Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

So my computer has the following partitions:

/dev/sda -- (I know this isn't a real partition, but more so the boot loader)

/dev/sda1 -- (Windows 7 Boot Loader)

/dev/sda3 -- (Windows 7)

/dev/sda4 -- (Data partition, NTFS)

that means i have /dev/sda2 as free space.

I do not want to change the MBR of the computer. I would like /dev/sda2 to contain GRUB AND Ubuntu. So ideally when I turn my computer on, BIOS would ask if I'd like to boot Windows 7 or Ubuntu(or Grub or partition 2), and I could choose either one. But I would like Grub and Ubuntu to be on the same partition, so they will not interfere in any way with windows or window's boot loader/partition (sda3)

How can I do this?

Catch: when formatting partitions, Ubuntu does not give me the option to make them virtual partitions, so that makes things harder.

I tried: installing Ubuntu to /dev/sda2 (which I formatted as ext4) and then told the Ubuntu installer to install the bootloader to /dev/sda2. But when I select "Ubuntu" from BIOS's boot selection, it loads a black screen and says "invalid arch independent ELF magic

grub rescue> _" and allows me to input stuff. How can I fix this, or tell my computer where Grub is?

share|improve this question
3  
Is there a particular reason why you do not want to change the MBR of the computer? The easiest thing to do is to allow GRUB to be installed to MBR. This will allow GRUB to detect your Windows boot files and your Ubuntu boot files and you can select which os at boot from the GRUB menu. –  matt davis Sep 20 '12 at 1:41
    
IMO, you shouldn't even see a BIOS boot menu. The easiest way to fix this would be to reinstall grub, this time onto MBR, and update GRUB entries. –  Mahesh Sep 23 '12 at 19:00
add comment

4 Answers

BIOS is not smart enough to ask you about partitions, in fact, it knows nothing about partitions. From the BIOS point of view, your disk is just a sequence of 512-byte sectors.

When BIOS is ready to pass the control to the bootloader, it just reads the first 512 bytes from the disk and just blindly passes the control to whatever program is located at the predefined position in that data. It is the job of that program (MBR bootloader) to load the OS (this usually involves loading a more complex bootloader program from some other location on the disk).

Point is - it is your bootloader, stored in MBR, which is aware about partitions and stuff. You may have a Windows bootloader there or GRUB. If you find a way to configure the Windows bootloader to pass control to GRUB which is installed on /dev/sdaX then your schema would work although I never heard of anyone doing this. Windows is not very concerned about being able to load other OSes, you know.

It is possible to do what you want if you have two hard drives in your machine - just install Windows on one and Ubuntu on another, and switch between them in BIOS. Or, I don't know, maybe it is possible to put GRUB on a flash drive? That actually would be cool - if the drive is unplugged Windows would boot, if you plug the drive in then Ubuntu would boot (provided that "boot from USB" comes first in the list of boot devices) .

share|improve this answer
    
You can boot GRUB from the Windows bootloader. I know because I've done it. There are several editors out there to do it for Vista and later. On Windows XP, you just edit boot.ini. –  siride Apr 26 '13 at 0:54
add comment

I use a third party boot manager, which means I specifically want grub installed to a partition. It's easy to take care of this during installation since Ubuntu lets you put grub wherever you like. However, if you want to do it after the fact, it's as simple as:

sudo grub-install /dev/sda1 --force

where sda1 is the partition where you'd like to put it.

share|improve this answer
add comment

It's easy to do. Just download EasyBCD to edit the windows bootloader.

share|improve this answer
2  
Please explain how one would go about doing this safely. –  hexafraction Oct 5 '12 at 10:36
add comment

May I ask why you don't want to install GRUB in the MBR, thus replacing the Windows bootloader?


Installing GRUB in a partition is not recommended and generally considered to be a bad idea. One is usually better off letting Ubuntu install GRUB in the hard drive's MBR.

GRUB can then take care of loading either Ubuntu or Windows. This is simple, harmless, and the recommended approach.

This process is also completely reversible, should you choose to return to Windows and use its bootloader exclusively.


Should you decide to install GRUB in the MBR (as you should), Boot Repair is the way to go.

Install GRUB

To install the GRUB bootloader, follow these steps.

Open a terminal in Ubuntu, and run the following commands:

sudo add-apt-repository ppa:yannubuntu/boot-repair
sudo apt-get update
sudo apt-get install -y boot-repair
boot-repair

After a few seconds, Boot Repair's main window will open.

Click on Recommended repair.

You're done!

Reboot to test everything out.

Hold down the Shift key as the computer boots to display the GRUB menu, which allows you to select which OS you'd like to boot.


Glossary

Bootloader: a piece of code that runs before any operating system is running. A bootloader is used to boot other operating systems. Each operating system usually has its own bootloader.

GRUB (Grand Unified Bootloader): a bootloader package developed to support multiple operating systems and allow the user to select among them during boot-up. It is Ubuntu's default bootloader.

Command, command line: the traditional Unix environment , where you type commands to tell the computer what to do.

Terminal: an application that allows you to access the command line. Open it by hitting its keyboard shortcut, Ctrl Alt T

share|improve this answer
    
There are use cases where the mbr is not where you want to put grub, but you want to install it to a partition instead. Yes, something else will point to this partition, which will run grub. How can one accomplish this from the command line? –  Chris Oct 27 '12 at 20:02
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.