Windows boots from the wrong drive's bootloader, but is it worth fixing?
October 24, 2012 5:57 AM   Subscribe

I bought a new laptop that has 2 hard drive bays. It came with a hard drive with Windows 7 preinstalled. I bought an SSD, installed Windows and Linux fresh onto it, wiped the old hard drive and used it as a data disk, but something is slightly out-of-whack in the boot sequence (and a partition is marked "System" when it really isn't). Is it worth fixing?

So, long story short:
After I installed Windows on the SSD ("sda"), and made sure everything was on the up-and-up, I went to fix the partitions and reformat things.
I noticed, on the hard drive that was formerly the system drive ("sdb"), there was this 100MB "system" partition without a drive letter, followed by a full-disk partition that was formerly the C: drive.
I know now that this is standard practice of Win7 installations, but I didn't know or think much about it at the time.

What I ended up doing was this:
Delete the "rest of the drive" partition on sdb.
Extend the first sdb partition, still marked "System", to fill the whole drive (other than the space reserved for Linux). This may or may not have been a dumb idea.
Format that partition, and give it a drive letter.

On sda, I have my Windows "OS" partition (sda1), and my Linux Mint "root" partition (sda2).
I don't have the extra 100MB NTFS System partition on that drive; the installation simply didn't put one there for whatever reason.

I've installed grub, of course.
When I boot up, grub presents me with the option to boot Linux (sda1), or to boot Windows. That's great.
But the Windows option is still pointing at the boot sector of the secondary drive (sdb), where Windows -used to- be installed. Apparently, *that* boot sector is smart enough to say "hey, the root of Windows is actually over there on sda1". But it seems like an extra step.

What I would like to do is fix the boot sequence so that grub only boots Windows "from" sda1, and forgets about the boot sector that is on sdb.

But my question is: Can I fix this without destroying any data, and how? Can I remove the 'boot sector' from sdb, and add the 'Windows boot sector' back to sda while preserving grub (or reinstalling grub from my bootable usb key), and get grub to figure out the proper boot drive?
Do I have to find some way to mark the "System" bit on sda1 and/or remove the extraneous "System" bit from sdb?

Also, is it worth fixing, or am I better off just leaving it as-is, since there are no actual problems and the system boots up fine?

I realize that I also may not be adequately explaining the situation in words. I'd be happy to supply more information and/or screenshots.
posted by jozxyqk to Computers & Internet (15 answers total)
 
I shouldn't have waited until I got to work to post this; I can barely follow the story myself :)
I will definitely post at least a partition-editor screenshot this evening.
posted by jozxyqk at 6:25 AM on October 24, 2012


I once deleted the Windows SYSTEM partition on a single-disk, dual-boot machine, and never did figure out how to get back into Windows. The Windows bootloader, apparently, is very important. So I feel your pain.

If you haven't yet customized the system much, nuke it from orbit and start over: Remove sdb so the installers don't get confused (or temporarily disable it in the BIOS), delete sda's partitions, reinstall first Windows and then Linux. Reintroduce sdb after everything else works. While the installers are running, drink a cup of coffee and think of how blissful it is to not have to fuck around with grub configuration files.

I wouldn't leave it as-is. If sdb dies or if you want to swap it out for a larger disk, you'll render Windows useless.

Can I fix this without destroying any data, and how?

You can add grub entries non-destructively (backup your grub config and have a rescue disk ready), but you'll need to somehow move the important part of the SYSTEM partition to sda. gparted can resize partitions to clear the way, of course with some risk of mangling your data. You can resize Windows' NTFS partition, but never change its starting sector.
posted by qxntpqbbbqxl at 7:09 AM on October 24, 2012 [1 favorite]


@qxntpqbbbqxl but do you think it is dangerous to keep sdb's partition marked as "System" even though it shouldn't be? I could "easily" (time-consumingly) back that drive up and repartition it properly.

I wouldn't lose a lot by wiping and reinstalling from scratch; it will just take a lot of time, mostly in the area of re-downloading huge games from Steam. (Luckily Steam has all my savefiles nicely backed up).

I think if "nuke it from orbit" is the best answer, though, (still waiting to see if anyone has something else to say, and I'll still post those screenshots later), then I will leave things alone for now as long as they are still working.

It might be a project for my upcoming vacation time in December, though.
posted by jozxyqk at 7:17 AM on October 24, 2012


I've installed grub, of course.
On sda? In the MBR? Which version of grub? Knowing where grub is installed and which version you are dealing with is important.

You should be able to change the partition type of sdb from 0x27 (Hidden, NTFS Windows Recovery Environment) to 0x07 (NTFS) and remove sdb's boot flag, and it should start treating it like any other normal NTFS partition without too much trouble. You can do this through gparted/parted/fdisk on the Mint side and through DISKPART (from the command line) on the Windows side. (This is how things should work, not how they will work. As always, backup any data you can't bear to lose before fiddling with your partitions, and be prepared for things to fail horribly.)

Have you tried disconnecting sdb and trying to coax grub into seeing the Windows partition on sda? (You could try disconnecting sdb, booting up, and running update-grub from the command line to see if grub will detect and boot your Windows install on sda.) If you can get it to boot Windows without sdb present, then that is one fewer thing you will have to worry about when making changes to sdb.
posted by Avelwood at 9:32 AM on October 24, 2012


As far as I remember, grub is installed on sda in the MBR. (I set up the machine a few months ago, and only just yesterday noticed some of the parts of this "mess"; so, obviously, there aren't any huge problems in actual machine usage, just some "it should work this way" things)
posted by jozxyqk at 9:56 AM on October 24, 2012


You could try disconnecting sdb, running the Windows installer, and choosing the "repair" option. That might fix Windows so it boots from sda, but it will probably kill grub.
posted by qxntpqbbbqxl at 10:02 AM on October 24, 2012


(Sorry for babysitting thread)
With the "coulds" and "shoulds", it sounds like my safest option is still to nuke from orbit, for which my earliest convenience would be some time in December (few steps, but a lot of tedious time).

I remember in the olden days of early hard-drive-based PCs, there was a command called "fdisk /mbr" that could repair a broken MBR. Isn't there something like that in Windows 7? I've found some references to various commands but I'm not sure which one is appropriate.

If it ends up overwriting grub, that's easy enough to fix with a bootable USB key and reinstalling grub to get Linux back. And, honestly, I haven't put anything significant on the Linux partition yet; that is a much more straightforward reinstall-from-scratch if it came down to it.
posted by jozxyqk at 10:20 AM on October 24, 2012


Ok you have a couple different things going on here...so I'll try to break this into categories:

The old drive:

That 100mb partition you're seeing is the MSR. It's a place where the boot manager resides for your install of Windows. You'll notice it looks empty from DOS, but if you do a dir /a you'll see all the hidden stuff.

Does it need to be there? Well not really. But if you decide to delete the MSR or just move Windows to a new partition without grabbing the boot manager, you may find that it might not boot at all. You'll still need the boot manager somewhere.

The new drive:
You need to do a few things to make your Windows partition bootable again:

- From a Windows install CD press shift+F10 to bring up a command prompt (or F8 once in the GUI if using a PE 3.0 CD):

bcdboot c:\windows /s c: /v

This will install the boot manager on C: and make it point to C:\Windows as your main windows installation.

I'm assuming that the drive letter the windows partition gets is C: because the MSR is no longer present and the linux partition will not get a drive letter:. But you may want to verify by doing a "dir" on C: beforehand.

- Once you've installed the boot manager on your windows partition, you may need to still apply a boot sector to it. (this will likely overwrite your GRUB install, so be prepared to have your linux install CD handy to launch a GRUB repair) bootsect /nt60 c: is the command, but let's save that for a last resort if it doesn't work automatically once we try /dev/sda1.

You may also need to go into diskpart to verify partition 1 is "active"

GRUB:

Basically from this point, you can tell Grub to load the Windows partition (sda1) instead of the MSR (sdb). To test this first I believe you can press the letter 'e' to do an inline edit just to test this theory out. Where you see sdb referenced, simply replace this with sda1 and then try to boot it. Take note of any errors encountered.

If all works well, boot into your linux side and with admin rights, modify your menu.lst for GRUB to reflect the new partition (usually under /boot/grub/). After modifying menu.lst you'll have to invoke grub-install to install it back to your master boot sector.

(Sorry if anything is missing from this or seems rushed...wanted to get something written quickly before the idea of nuking from orbit was solidified. Feel free to memail me if you'd like further details!)
posted by samsara at 10:37 AM on October 24, 2012 [2 favorites]


Don't worry about being rushed, samsara. Like I said, I really won't be even attempting any of this until I know I have some uninterrupted system-tweak time in December for the worst case scenario. So I've got a few weeks to gather information about fixing the issue.

So keep the suggestions coming; I also probably won't mark a "best answer" until I go through with the fixes.

I learned about "That 100mb partition" after I went through this whole process.. the deal is, though, that "that 100mb partition" is now "that 650gb partition" and is mounted as my D: drive in Windows. This is one of the things that might need to be remedied; either changing its partition-type and hoping that Windows is OK with that, or by backing it up, nuking it, and restoring the files.
posted by jozxyqk at 10:51 AM on October 24, 2012


(I don't know if I will actually be able to post screenshots tonight, but it sounds like people are understanding the question better than I thought anyway)
posted by jozxyqk at 3:22 PM on October 24, 2012


Followup #1, for people going back to the thread:

I just tried booting up normally, selecting the Windows entry in grub, pressing 'e', and changing 'hd1' to 'hd0'. Without running any other fancy stuff. And that worked, to my surprise.

More experiments forthcoming... I won't bore you with all the details in between but I will post a final followup within the next few days.
posted by jozxyqk at 1:12 PM on December 1, 2012 [1 favorite]


Oh, I guess someone *is* still reading.
One more mini-followup: I decided to see what would happen if I changed that to "hd7" (or some nonsense). And it still booted. So, that's kind of inconclusive at the moment. I'd like to prove that I can make it fail so that I can prove that my changes do something.

Once again, that's it until I'm finished :)
posted by jozxyqk at 9:09 AM on December 3, 2012


Good to hear! I check in on "recent activity" often to keep track of posts and saw there was some progress. Once you're comfortable with the behavior of the new parameters you apply them via editing the menu.lst/grub.cfg for GRUB. (more info here)
posted by samsara at 9:23 AM on December 3, 2012


This is good:

I booted with my Win7 DVD.
Ran bcdboot c:\windows /s c: /v
Rebooted into Linux.
Ran sudo update-grub

It detected Windows 7 on /dev/sda1 and (magically) made it the default.

So far so good...
I still have a grub menu option for /dev/sdb1... and the whole "system bit" on sdb1 to contend with... but at least I can boot as-intended now.

(I'm not sure if it's "faster" but it is definitely booting the way it is supposed to...)

Maybe one more followup when I'm brave enough to try flipping the partition-type of sdb and figuring out how to _remove_ the boot sector...
posted by jozxyqk at 12:09 PM on December 3, 2012


After several reboots, I can confirm that there's at least a placebo effect; it seems to boot a few seconds faster.

More updates for future googlers who find my question:

I removed the sdb entry with the grub-customizer tool (found from here, although I suspect it will come back the next time my kernel updates.

I probably need to back up sdb, nuke it from orbit, and restore the backup to fix that "other" problem in the safest way possible, but I'm less apprehensive about that step and it seems less critical.

(In other tangential thoughts, I am thinking about blowing away Linux, and therefore grub, from this machine completely, since I don't really have a good use-case for Linux here, but I'll leave that situation alone at least until I run out of space or get really bored)
posted by jozxyqk at 8:16 AM on December 4, 2012


« Older I might be hired as a technica...   |  Will this computer run Armed A... Newer »
This thread is closed to new comments.