Loko’s Domain You live and learn. At any rate, you live.

11Jan/0936

Adding Windows 7 to Linux Multiboot

Update: I appreciate the comments! Thank you for adding more technical information to this attempt at a simple guide to simplifying the process. A big thanks to LifeHacker.com and Tuxmachines.org for adding this article to their front page!

Word of Caution: Thanks to the anon for mentioning you might lose the ability to use BitLocker. I have not tested any of this yet, but I recommend using TrueCrypt over BitLocker. Also note a Dynamic Disk setup would probably be slaughtered. Again, I have not tested any of this, just a word of caution.

I received a question regarding my last post about Windows 7 being in my multiboot setup.

Read This Before Starting: To begin, you must have a basic understanding of GRUB and naming conventions in the GNU/Linux world. If (hd0,1) speaks your language, this will be a very easy to follow guide. If you do not know GRUB (GRand Unified Bootloader), then you are missing out on the best boot loader around. I should mention that LILO requires a bit more work and maintenance, but both possess the same functionality.

Extremely Important Notes: I recommend a novice editing the mapped devices in GRUB with the distro installation disc. It is the easiest way. If you do not have a distro disc handy, then I recommend trying to use the Super Grub Disc. With the SGD, you can restore GRUB to the MBR, but you will still have to edit mapped devices. The distro CD or DVD allows both jobs done in one step. I do not recommend editing the Windows boot.ini file.

What Happened to the GRUB: Installing Windows 7 will wipe add itself to the master boot record (casualprogrammer is right, it does not "wipe", bad choice of words) over your custom GRUB configuration. Do not panic when Windows begins booting without GRUB appearing first, this is normal. Since Windows Vista, the NTLDR has been replaced with several other components which are bootmgr.exe, Boot Manager, and winload.exe, the Operating System Loader. This might make people think that Vista or 7 are incapable of functioning under GRUB, but there are unnoticeable changes regarding the multiboot functions and performance with GRUB and bootmgr/winload.

What Happened to Windows XP: If you had Windows XP installed as your primary before, then XP will still be present. If you did not upgrade from Windows XP or format your hard drive, XP will still be present. Also if you did not install over the same partition that held XP. Windows 7 will take care of booting XP. When Windows boots, you are given a prompt and 30 seconds, by default, to choose to boot to Windows 7 or an Earlier Operating System. Choose Earlier Operating System to boot back into Windows XP.

Installing Windows 7: You can install Windows 7 on any other NTFS partition on your hard drive without worry. Seven will always be displayed and function like it is on the C: drive when running, even though it is actually installed on drive R:. This means that headaches will not result from installing it elsewhere. The installation is very straight forward, much easier than Vista, which says something because the Vista installation was a huge improvement from Windows 2000 and XP.

What Happens Next: After the installation, the computer can only boot into Windows because the newly added bootloaders are now priority after POST. No problem, but you will have to change this to get back into the capabilities of GRUB and boot back into your existing Linux installations. Pop in your tool of choice to edit the GRUB. The easiest way to do this involves your distro installation disc. Boot to the distro disc. Proceed through the language and other prompts to the Bootloader Configuration options. You may only have the choice to create a new bootloader. Select that and proceed.

Creating a New GRUB: If you only have one operating system using the Linux kernel and Windows 7 currently installed, this might be easier. Windows XP will not be in the device list and you should not be able to add Windows XP again while Seven is present. You can spot which partition holds what by the boot flags, such as "/boot". Linux should be the one with the output "/dev/hda3" or another consisting only of a forward slash (/). Add this and give it a relevant name. Windows may be installed under /dev/hda1, or (hd0,0). The title "Windows" should do, since it may be for both XP and 7.

Consummation: Apply the changes, wait for the BL update to finish, and you should be all set after the system reboots. You will be given the GRUB screen to choose between which O/S to boot. You're all done. It's been a couple of weeks, but I have experienced no issues and I am always bouncing from each operating system. I've been GRUBing it up with Windows XP Pro and Fedora for a long time without any hassles. Please respect my hard work. Pass this guide along if you've found it helpful, and feel free to leave a comment with any criticism. Enjoy.

Here are links with further information:

Arc Language Blog - Notes on dual-booting Windows 7 and Linux

APC - The definitive dual-booting guide: Windows 7, Linux, Vista and XP step-by-step

Comments (36) Trackbacks (4)
  1. Nice to know that seven won’t mess any more up than necessary. Thanks for the quick overview. I appreciate people who write useable information.

    But just a thought, wouldn’t you be able to add seven directly into the grub menu by doing something like this?

    —-
    title Windows seven
    root (hd0,4)
    makeactive
    chainloader +1
    —-

    Don’t mind me, just dumping some basic grub information that might make this work once the beta really gets rolling.

    —–

    grub> root (hd0,0)

    grub> setup (hd0)

    grub> quit

    ———

    (hd0,0) indicates the first primary/logical partition on your first (master) harddisk.

    See the grub manual for individual commands.

  2. Well,

    I did install Windows7 on a free partition of a WindowsXP and openSUSE multiboot system.

    Windows7 does _not_ “wipe out” anything, it doesn’t care for existing OS’s either. It plainly replaces the MBR with it’s own stuff.

    So you need to take care of you MBR _before_ installation, as well as prepare a GRUB or NTFS Boot diskette ( CD, USB Stick ) so you can boot to any of the pre-existing OS’s and copy back your saved MBR.

    Nothing for the faint of heart, especially not on a productive system.

    P.S. As far as I can see after a few hours digging, it’s not worth the hassle :-(

  3. @k4emic and casualprogrammer

    Thanks for the additional information.

    k4emic, thanks for the alternate route. Much appreciated. For those that want to learn more on advanced GRUB techniques, the manual on their website has amazing documentation.

  4. If you break the boot chain Windows may not be able to use things such as BitLocker. I don’t know it for a fact but it would be a good thing to take note of when you follow this guide and use BitLocker.

  5. I find myself a fairly competent linux user so I decided to try Windows 7. For the first time I was not able restore grub, the steps I went through are as below:

    root (hd0,0)
    setup (hd0,0)

    It came up with grub error 15: /boot/grub/stage1 or /grub/stage1 does not exist. Is there any way around this? As I cannot boot into linux currently.

    • You have to do find /boot/grub/stage1 which might output something different than (hd0,0). In my case its (hd0,2)

      then you set root(hd?,?) where ? are the values returned by the find above.
      and setup (hd0)

      google on reinstalling grub from a live cd and you will find the full steps

  6. @Luke

    GRUB error 15 typically means bad data. Did any installation fail? Were you able to boot into Windows 7 after it finished?

    Maybe it’s in your syntax. Comb through the manual for the proper installation.

    It’s easy to render your machine unbootable. If it’s serious enough, you can try using the System Rescue CD or the Super GRUB Disk and look at their listed solutions listed. All respective software have delicious documentation for common issues.

  7. Grub is wiped out by windows 7’s mbr ,but after restoring grub, windows 7 then merely changes the boot partition to itself by reflagging the partitions,and makes itself the boot OS. It probably does this when the pc is shut down.At least that’s my conclusion. I have restored the grub menu only to have windows reassign the ‘boot partiton’ to itself.I used gparted to reassign the boot partition with the flag option and voila there was grub restored, albeit only temporarily ’til we find a fix for this.

  8. Your instructions were extremely helpful. A few notes in addition: I was able to just reinstall my MBR from the disk image I made with Acronis Disk Image right before I installed W7. So if you use that program, you can substitute that for reinstalling Grub through the use of the Linux Live CD.

    My set up includes two SATA HDDs with XP on the first partition of the first HD. I installed W7 on my H: partition on the first disk (sda9). As it turns out, I did not have to edit my Grub menu.lst file as Windows is still booting off that C: partition. There are some new and rewritten files in C: in XP which concern booting. I’ve backed up those files as they existed before I installed W7 for the day I remove W7.

    Also, Easy BCD breaks my setup and should not be used if you’re using GRUB, even just to edit the Windows options. There are some postings, particularly in the Ubuntu forums, about that.

    Finally, I haven’t gotten bcdedit.exe to work to edit the W7 boot menu. I’ll have to research this one further.

  9. @DualBooter
    Two more things. First, the correct name of the program is Acronis True Image. Second, you can place bcdedit.exe into Windows XP and it will work. I’ve read that it won’t work if you place it into the Windows/System32 folder but will in any other. I placed it into a directory I created: Program Files/BCD.

  10. @BluesKaj
    I am facing the same problem. After installing windows 7, I tried restoring the GRUB bootloader through the SUSE 11 DVD. The GRUB bootloader installation is successful but GRUB just doesn’t show up when I reboot my PC. It simply shows the windows boot loader with xp and win 7.
    Please let me know if anyone has figured out a solution for this one.

    • For future readers: I was able to get grub going again in opensuse11.1 by checking the options “Mark boot partition as active”, “Boot from boot partition” and “Write Generic MBR” (those names are approx)

      I had some issue with the straight repair tool, and instead had to boot to the installer and use the repair tools from there.

      • I also used chainloader +4 as suggested below. Selecting windows 7 from grub returned me to grub until I used the win7 installed cd to repair “startup problems”. now things work great.

  11. Two things you can try. First, make sure that the issue is in fact with SUSE and that you didn’t do something wrong the first time out (it happens to the best of us). If it is a SUSE problem, then download the most recent version of Super Grub Disk and burn it to a CD. It will allow you to reinstall Grub. It won’t be the SUSE version, but it’ll be Grub and it should work. Then once you’re able to boot SUSE, see if you can reinstall Grub from your SUSE partition.

  12. BluesKaj :
    Grub is wiped out by windows 7’s mbr ,but after restoring grub, windows 7 then merely changes the boot partition to itself by reflagging the partitions,and makes itself the boot OS. It probably does this when the pc is shut down.At least that’s my conclusion. I have restored the grub menu only to have windows reassign the ‘boot partiton’ to itself.I used gparted to reassign the boot partition with the flag option and voila there was grub restored, albeit only temporarily ’til we find a fix for this.

    Can anybody verify that this is a fact? (that Windows 7 will overwrite the mbr after a reboot). That would be huge.

  13. @threecheese

    Same thing is happening for me. Not a *terrible* problem, just obnoxious.

    If you have a bios that allows you to prevent writing to the MBR, it will be really easy to circumvent (considered a virus protection feature most of the time).

    Another possible work around would be to force the bios to boot from the GRUB /boot partition.

    Of course, my bios allows neither of these options, so this just sucks.

    Does anyone know of a way to get the Windows boot loader to display linux/GRUB?

  14. @perturbed

    I did some more tweaks to my configuration, and I think I figured out what the problem is.

    Make sure you don’t set the “Make this partition active” flag for the Windows 7 partition and GRUB should continue to work even after restart.

    Hope this helps.

  15. @Lokonopa
    Maybe a solution to the problem is to use a Live CD, then type in terminal:

    sudo grub
    find /boot/grub/stage1

    this will find out which grub options are available to you. Then:

    root (hd0,0)
    setup (hd0)
    quit
    reboot

    Just use the appropriate number where your distribution is.

  16. The only necessary options for grub to boot windows 7 correctly (without a black/blank screen) is

    root (hd0,0) <– The location of the windows install
    chainloader +4 <– Yes, four. I figured this out the hard way

    No makeactive, no nothing else.

  17. Removing the active partition flag worked for me also. Thanks so much to the poster of this suggestion.

  18. @Spork
    never mind I still get bootmgr missing also

  19. I just installed Win 7 on my quad-boot computer. WinXP is (hd0,0), Win7 _should_ be (hd0,1) with both on an IDE drive. Ubuntu Jaunty was (hd1,0); Debian Lenny was (hd1,3). Ubuntu Jaunty is my normal grub stage1 drive.
    Booting to a Jaunty Live CD, terminal command to get to grub,
    find /boot/grub/stage1
    results in a file not found.
    Still investigating.
    Problem was using the command: grub
    instead of using command: sudo grub
    Hope this helps someone.

  20. title Find And Boot Windows 7
    find –set-root /bootmgr
    chainload /bootmgr

    title Boot Windows 7
    root (hd0,0)
    chainload /bootmgr

  21. I run Ubuntu, but I’m thinking of dual booting, so I just grabbed Windows 7 as part of a student promotion (http://www.win741.com). The first thing you download there is a download manager. This DM grabs the iso.

    Unfortunately, the download manager is designed to work from Windows. :(

    (Any suggestions?)

  22. Just use grub4dos to boot linux, and leave windows on the MBR. Create an option in the windows bootloader pointing to grub4dos, then use the grub4dos menu.lst to boot your linux distro.

  23. (here’s the post in the proper place, I’m sorry for the accidental reply)

    What happens if you disable the linux’ hdds, either physically or only in the BIOS, before installing windows, install windows, and after that, re-enable the linux hdds again, boot on linux, and add an option for windows on grub?

    I din’t try that yet, but that was what I would try if I didn’t thought of searching about the subject before possibly doing something that wouldn’t work.

    Will windows still somehow change this, switching its own partition as the one to boot from?

    • I’ve done this when it came to dual booting Vista and Win7 earlier this year. After I enabled the secondary drive, Windows 7 would not prompt me to boot into an earlier operating system. I had to use the BCDEDIT command while in Vista to add the Windows 7 installation.

      I’m questioning how relevant that was to your question, but I did not try this using a GRUB multiboot with multiple disks with other OSes installed on them. This tutorial was written using only one hard disk.

      Are you assuming that Windows is primary OS on the disk even after enabling the HDDs through the BIOS or is Win7 being installed on a secondary drive? I’m pretty sure you would still have to reconfigure GRUB.

  24. I am getting

    “The boot selection failed because a required device is inaccessible”

    using fake raid, any ideas?

  25. I tried win 7 first, shrunk the hard drive, then installed Suse Linux 10.0. Rebooted options-Suse linux, windows, Suse linux safe mode. Selected Wins. Bootmgr missing – ctrl alt delete. I tried replacing MBR & Boot & BCD. Booted straight to Wins, no Linux. I booted from Linux DVD and repaired grub. Back again to no access to wins from options

  26. I do really like your cool data! Could you compose the literature term paper as example? Because I know that a masters classification essay service can write custom research papers of brilliant quality.

  27. Before installing windows, install windows, and after that, re-enable the linux hdds again, boot on linux, and add an option for windows on grub?thesiss pure essays writing help


Leave a comment