Page 1 of 1

repair grub after win7 reinstall

Posted: Sun Nov 21, 2010 9:04 pm
by qbicdesign
I've been running a triple boot for a while with the following order of installs:

first installed winxp
second installed win7 64bit
third installed LMDE

LMDE has since become my preferred OS, but I need to keep some apps from Windows - yes I know i could run them in virtualbox, but they're graphics programs requiring too much video and system resources for that.
After a while struggling with Win7 64bit driver issues, i decided to scrap both Win7 64bit, and XP and install only Win7 32 bit, whilst keeping LMDE
The install went fine, and as you'd expect, I cannot boot into LMDE after without reconfiguring grub, which is turning out to be more complicated than I would like.

Fristly, I noticed that from the LMDE boot dvd there is no rescue option... is that normal?
Right now I booted LMDE using Supergrub2 boot disk, but I'd like to get the boot menu properly fixed.
I have already ran update-grub from terminal, and grub detected and re-added Windows 7 to the list

Can I now simply remove the boot flag from the Win7 partition and add it to my LMDE partition instead? Or are there more steps I need to take?

Win7 is installed on sda2, but the mbr seems to be in sda1 (a 100mb partition created during win7 install)
LMDE is installed on sda5

Does anyone have any advice how to complete this grub repair?

Re: repair grub after win7 reinstall

Posted: Sun Nov 21, 2010 9:46 pm
by hemimaniac
I see this more and more, here is your fix

only consideration you need to take that the article doesnt explain very well is grub must be installed to the first HDD/Partition the bios sees

so if sda1 is xp
sda2 is win7
sda3 or sdb1 etc etc is linux but the bios sees the sda disk first, that is where grub gets installed to as per the article instructions

Re: repair grub after win7 reinstall

Posted: Mon Nov 22, 2010 8:52 am
by cwsnyder
I see a potential problem not covered by the article, responses, or responses here. Windows Vista and Win7 both install a separate partition boot loader partition and competitor to GRUB/LILO. When Windows is installed first, this Vista boot partition is installed as the first partition (or modifies WinXP), and I have known Windows Update to re-install the Vista boot. GRUB/GRUB2 wants to take over the MBR and part of that partition and gets clobbered regularly. Windows XP has clobbered GRUB when re-installed, but not on updates.

The only stable configuration which I personally have maintained were with separate hard disks, selecting the system I want to boot by my BIOS boot selector. I have my /dev/sda drive set up for Windows with /dev/sda1 as the Vista boot partition and Windows XP, /dev/sda2 is Windows 7. Windows XP was installed first, Windows 7 was installed as an upgrade afterward. My Windows XP OEM modified install disk will only install and run as the first partition (PC Angels mod). /dev/sdb is my Linux partition with LMDE as /dev/sdb1, /dev/sdb3 is the W95 Extended (LBA)partition, /dev/sdb5 Debian 5 (Lenny) /, /dev/sdb6 is my Swap partition, /dev/sdb7 is /home for Debian. This is as seen by LMDE after booting from /dev/sdb.

You could also use the Vista boot loader to get to your Linux options after (manually) modifying the Vista boot loader which Win7 inherited with the proper Windows utility so that the Registry and flags get reset properly. Windows does not automatically detect Linux partitions/installations.

Note that with this configuration Windows XP is not recognized by GRUB2 at all! Win7 does show up and will run from GRUB. Before I installed Win7, XP only caused me to have to fix GRUB Legacy when I had to re-install Windows for whatever reason, and Windows XP would show up for GRUB Legacy. WinXP is a boot option within the Vista boot loader, as 'older version of Windows'. I never had GRUB2 installed without Win7.

With this configuration, I have re-installed Windows XP and Win7 as needed (of course you know you will have to re-install Windows occasionally if you use it?) and upgraded/installed Linux as needed for changing releases without corrupting the boot process for either Windows or GRUB2 for about 18 months now.

I did have a problem that LMDE did not properly recognize a separate /home partition on /dev/sdb2, which is why my LMDE is on a single partition, but I was able to combine / and /home without disturbing my Debian install. I figured if LMDE was a rolling release there was not the urgency of using a separate /home partition that there had been using Ubuntu and upgrading every 6 months.

Re: repair grub after win7 reinstall

Posted: Mon Nov 22, 2010 10:10 am
by qbicdesign
Well I'm glad to say the suggested solution worked perfectly.

The potential problem mentioned is a very real concern, but for me it was OK since Windows 7 was installed to the same physical drive as Linux. both are on sda.
Linux was able to successfully write grub to the boot sector as needed.
I guess there may be issues if windows is installed to a different physical drive than Linux.