Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I've just installed my OSes on a new HDD: Windows 7 and Debian 7. As usual I first installed Windows, then Debian.

At the first attempt, GRUB seems to not have been installed properly, because my computer would just boot into Windows. I found this on debian.org, so I followed its advice:

When there is more than one disk available during installation (for example one hard disk and one USB stick, as it is commonly the case when booting the installer from a USB stick), grub-install may run into problems: it was reported several times, that the GRUB bootloader was installed onto the USB stick instead of the hard disk containing the newly-installed system.

To avoid running into this, make sure to answer "No" when the following question is asked during the installation process: "Install the GRUB boot loader to the master boot record?"; it should be possible to specify the right device at the next step: "Device for boot loader installation".

After I did this, GRUB would show up on boot, but when I selected Windows, the screen would go black and immediately pop back to the GRUB menu. I installed GRUB into the first partition, as that was the one with the boot flag.

My partitions are as follows:

  1. 100MB System Reserved
  2. 195GB Windows
  3. 2GB Swap
  4. 40GB Linux

I managed to fix the MBR with the Windows CD afterwards, but of course, now Debian is unavailable.

Should I have installed GRUB somewhere else, or is it a different problem ?

share|improve this question

2 Answers 2

up vote 1 down vote accepted

Assuming you're partitioning with MBR and not GPT.

First, you can backup and eventually restore your mbr (assuming hda is the target disk):

 dd if=/dev/hda of=/path/mbr-backup bs=512 count=1 # backup
 dd if=/path/mbr-backup of=/dev/hda bs=512 count=1 # restore

Obviously would be hda1 if you installed grub in the partition and not the disk.

Note if it is in the disk (hda) don't change your partition table between backup and restore.

Second, if your Debian is currently installed, just boot a Live CD and mount the Debian root somewhere:

mkdir /tmp/x
mount /dev/hda1 /tmp/x # Debian root partition
# mount some needed filesystem
mount proc /tmp/x/proc -t proc
mount sysfs /tmp/x/sys -t sysfs
mount --bind /dev /tmp/x/dev

Chroot into the partition and reinstall grub

chroot /tmp/x
grub-install /dev/hda # or hda1 for the partition

Don't know yet if you need an update-grub also (should verify)

The grub's os-prober should find your Windows, then if it doesn't boot there's some other problem in the chain loader.

update

If your disk is partitioned as GPT see this FAQ

Windows and GPT FAQ

in particular this one:

Can Windows 7, Windows Vista, and Windows Server 2008 read, write, and boot from GPT disks?

Yes, all versions can use GPT partitioned disks for data. Booting is only supported for 64-bit editions on UEFI-based systems.

If you have BIOS use MBR partitioning, if you have UEFI then use GPT.

share|improve this answer
    
Thanks for your answer, I finally found the time to try it out. I think the mistake I made was to install GRUB into the first partition (sdb1) instead of in the disk. When I tried to fix it, mount proc /tmp/x/proc -t procfs failed with the message: mount: unknown filesystem type 'procfs'. When I retried without specifying the type it said mount: special device proc does not exist. I am using Knoppix 7, but I don't think that should matter. –  Ale Strooisma May 24 at 11:51
    
@AleStrooisma my fault, I've edited the answer, it is -t proc (or you could use --bind as for /dev) –  Alex May 25 at 14:48
1  
I should've figured that out myself. Anyway, I am writing this from Debian, so it worked. Feels good to be back in Linux! One issue I ran into, which might be worth mentioning in your answer, was that the live cd needed to be 64 bit in order to be able to chroot to my 64 bit debian installation. –  Ale Strooisma May 26 at 10:41
    
@AleStrooisma glad it worked, enjoy your Debian! +1 for mentioning about the arch. –  Alex May 26 at 13:23
    
I'm not sure having a 64 and chrooting into a 32 would fail, probably an argument for another question. –  Alex May 26 at 13:32

I always recommend install bootloader on separate partition: "/boot" Later you can do different manipulations without fear of harm or corrupt main OS (Windows).

In your situation i think it would be better to reinstall Debian with new partitions + "/boot" installed bootloader. Also pay attention maybe you have GPT, but not MBR. It can be a reason.

share|improve this answer
    
I don't think a separate /boot has any relation to the risk of corrupting Windows. Plus, the recommendation of separate /boot is void without a proper rationale. –  Pavel Šimerda May 18 at 17:09
    
I have had my PC installed like this for years, there's nothing wrong with the set-up. Normally however, GRUB installs correctly automatically, but this time I had to do it manually, because it had trouble picking the correct disk. –  Ale Strooisma May 27 at 10:40

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.