Pin Me

How to Dual Boot Linux and Windows 7

written by: Lamar Stonecypher•edited by: Rebecca Scudder•updated: 11/8/2009

Are you a Linux user wondering about all the Windows 7 hoopla? No matter what you think about Microsoft, nobody will mind if you try it out in secret. Here we’ll look at shrinking a Linux partition to make room for Windows 7 and then installing Windows 7 on the PC.

  • slide 1 of 26

    Obtain a Windows 7 Version

    First, you’ll needa copy of Windows 7. A previous version of this article talked about downloading a beta or release candidate version and using it. However, now that we're past the release date, we'll assume that you have a real copy of Windows 7 that you want to install on your Linux box.

  • slide 2 of 26

    Creating a Windows Partition

    Once you have the installation DVD, the next step is to create room for Windows 7. We tested this on a notebook running openSuse Linux 11.1 and used the included "Expert Partitioner" application to shrink an existing partition. This could also be done using a Linux rescue disk or a GParted Live CD, which should work with any distribution using a common Linux file system.

  • slide 3 of 26

    In openSuse, click Menu → More Applications → Utilities → Yast. Enter your super-user password, and then open Partitioner.

  • slide 4 of 26

    In Expert Partitioner, click on /dev/sda in the left-hand pane and the Partitions tab in the right-hand panel. The image below shows the partitions after the shrinking. The space for the 93 GB partition for Windows 7 was taken from /sda3.

  • slide 5 of 26

    Expert Partitioner Results 

  • slide 6 of 26

    The steps involved are clicking the partition you want to resize and then clicking the “Resize" button at the bottom. This brings up the “Resize Partition" dialog. Dragging the pointer sideways adjusts the existing partition’s size. The new, unallocated space will show up as “Unused Disk" in the legend above the slider. Then just click OK to shrink the partition.

  • slide 7 of 26

    Partitioner Partition Details 

    Partitioner Resize Partion 

  • slide 8 of 26

    Shrinking a Partition with GParted Live CD

    GParted can be downloaded at the SourceForge website.

    You’ll need to follow the same process that you used to create the Windows 7 installation disk on your PC to create the GParted Live CD.

    At startup, the installer asks for the keyboard configuration and preferred language followed by the desired video mode. This then left me looking at a Debian/Gnome home screen with GParted open.

  • slide 9 of 26

    GParted 

  • slide 10 of 26

    Mebibytes and Gibibytes

    You may soon find yourself wondering what “MiB" and “GiB" are. You may wonder this as soon as you select the partition that you want to resize. GParted shows the sizes in Gibibytes and Mebibytes.

    What are MiB and GiB? Besides a subject of technical discussion, they are hard drive size measurements that can be directly compared to RAM size measurements. 1024 (and not 1000) Mebibytes equals 1 Gibibyte. Even better, GParted expects us to know this and compute the changes ourselves. So let’s give it a try.

    Our /dev/sda3 partition, according to openSuse and Expert Partitioner is 276.08 GB. We want to shrink it 100 GB for the new Windows 7 partition. GParted says that the partition is 271.56 GiB.

    GB and MB come from an industry practice by hard drive manufacturers where they label capacity in MB = 1000 bytes and 1000 MB = 1 GB. This sounds much more attractive, they think, to purchasers who get their new drives installed and then discover that that the OS reports that it only has about 93% of the capacity they thought they were buying.

  • slide 11 of 26

    Mebibytes and gibibytes would solve this problem – if the hand-drive manufacturers would adopt the standard. 1024 MiB of hard drive capacity = 1 GiB in the same way that 1024 MB of RAM = 1 GB.

    Anyway, we want Windows 7 to have 100 GB. 100 GB = 93 GiB, and 93 GiB = 95,232 MiB. That’s how much we want to shrink the drive in GParted.

    Doing this same task in Windows Vista a few days ago, I used the “Shrink Tool" in Vista to shrink the partition, format it, and mark it “active." For our purposes here, we’ll use Gparted to shrink the partition and see how it goes.

  • slide 12 of 26

    Next: Shrinking the Drive, Installing Windows 7, and Fixing GRUB to Dual-Boot

  • slide 13 of 26
    After using Expert Partitioner or a GParted Live CD to shrink a Linux partition, the unallocated space can be made into a partition and formatted for the installation of Windows 7. Windows 7 adds itself to the master boot record, but it does not wipe it out. Instead it gives itself priority. Three ways to restore GRUB are to use the distro disk's repair tool, to find and boot into Linux, or to use the SuperGRUBDisk to fix the GRUB menu. gparted live CD, super GRUB, super GRUB disk, linux partition
  • slide 14 of 26

    To actually perform the shrinking, click the partition and then click “Resize/Move" in the upper panel. Insert 95,232 (or your desired size, of course) in the “after" entry field and click OK. This will cause a message about the pending shrinkage to appear in the lower panel. To start the shrinking, click on Edit → Apply All Operations.

  • slide 15 of 26

    GParted Apply Operation 

    GParted Confirm Apply 

  • slide 16 of 26

    GParted displays a progress indicator while it runs, which took about twenty-two minutes.

  • slide 17 of 26

    GParted Shrink in Progress 

    GParted Shrink Complete 

  • slide 18 of 26

    At this point, you may want to right-click the new, unallocated space and set it to a "Primary" partition. You can also elect to format the partition to NTFS right from GParted. That's purely your option, as the Windows 7 installer can do it, too. We tried it both ways, and the results were the same.

    To exit the GParted Live CD, click the Exit icon at top right and wait for the shutdown to be broadcast. After several seconds, it will ask you to remove the CD, close the tray "if any," and press Enter.

  • slide 19 of 26

    Installing Windows 7

    After rebooting from the Windows 7 DVD, the installation will begin. It will first ask for language, currency and time, and keyboard layout.

    Windows 7 installed will take up about 17 to 20 GB on your new partition.

  • slide 20 of 26

    Windows 7 Install 

  • slide 21 of 26

    If you elected to not to partition the unallocated space, the Windows installer will automatically highlight it. However, clicking "Next" at this point will create an error message. Instead, click "New" and you'll be able to create the new partition and format it, or rather, set it up to be partitioned and formatted. The actual formatting takes place when the main install progress screen is showing.

    Windows 7 will restart once during installation. Watch for this notification because this is when you'll be removing the DVD. This restart will automatically go back to the Windows installer. Of course, this means that Windows has added itself to the master boot record. Don't worry, though. Unlike Windows XP, Vista and Windows 7 don't wipe out the GRUB configuration. It's still there, even thought Windows will mark itself as the primary OS.

  • slide 22 of 26

    Here are a couple of other notes about installing. If you have an Internet connection during setup, Windows 7 will ask you which group - home, work, or public - to add the connection to. If you select "Home Group" and it detects a Wi-fi radio, it will give you a group password. This automates setting up home networks somewhat, but it only works with other Windows 7 PCs.

    Also, soon after starting Windows for the first time, it will warn you about needing antivirus software. (This is Windows, after all.) Clicking the link in the dialog will take you to the Windows 7 Security page. Scroll down and you'll find links to antivirus trials by Kaspersky, McAfee, and AVG.

    I like this part, so here's an image from the earlier version of this article. It was what the Windows 7 release candidate looked like after setup.

  • slide 23 of 26

    Windows 7 

  • slide 24 of 26

    And, yes, that background was a pun. That's a Siamese Fighting Fish, which is also known as a beta fish. (Some users have reported that they see a different background when they install Windows 7 RC. I did not. Alas, this image is not among those in the released version of Windows 7.)

  • slide 25 of 26

    Getting GRUB Back

    There are several ways that you can get the GRUB menu back. Probably the easiest method is to boot the PC from your Linux distribution's installation DVD. Then select "Repair" to find the tools to correct the boot loader or to create a new bootloader. Both methods will find and include the Windows installation. (openSUSE marks it as "windows/c.")

    You could also use the distro disk to start Linux from the hard drive. Then the commands

    sudo grub

    root (hd0,0)

    setup (hd0)

    in a terminal should repair GRUB and display the Windows option as well.

    And if you're looking for something educational that you can later brag about, try using the SuperGRUBDisk to restore your MBR.

  • slide 26 of 26

    Finishing Up

    And there you have it - how to dual boot Linux and Windows 7. As a long time Linux enthusiast (and before that an OS/2 user), I'm optimistic that this time Microsoft is getting it right for the mass of Windows users. It won't satisfy every user, just as no one Linux distribution does. If it makes things easier for the casual, non-expert user, that's all good.

    Thank you for reading this, and thank you for visiting Bright Hub. I hope this article helped you install Windows 7 on your Linux box.