Dual-Boot Windows 7 and Linux (Ubuntu)

For today, a quick (but hopefully thorough) walkthrough on how to dual-boot Windows 7 and a Linux distribution. Whether you’re starting from a clean machine or an existing Windows 7 computer, desktop or laptop, these general instructions should work for you. Note that this is just one way to do it. Also, others may recommend some changes or tweaks to this approach. But it should be useful if you’d like an example of how to set up a dual-boot system. (Disclaimer: I’m not responsible for anything at all, ever. Try this at your own risk. BACK UP YOUR DATA FIRST!)

I’ve done this on a home-built, clean desktop, and on a Lenovo x220 laptop where I kept the existing Windows 7 install. So I will draw on these as examples. Both times, I installed Ubuntu, which is commonly known as a user-friendly distribution of Linux that is good for first-timers. These instructions, however, should work in general.

What you’ll need: A computer, a way to back up your data, some disks/USB drives for installation. You’ll also need to be willing to Google some things if you haven’t done them before — in the interests of brevity, I won’t explain how to click through each menu or every step in detail. If you’re stuck on a part, leave a comment and I’ll try to explain; there are also lots of resources out there on the web! Finally, expect to do a little troubleshooting after installation to get Windows and Linux to work together with your Data partition, etc. It may take a bit of setup work, but should be worth it!

Before we head out onto the field, here’s the general game plan. We’re going to create three main partitions: one with our Windows 7 installation, programs, etc; one with our Linux installation, applications, etc; and one for all of our data. The two operating systems will both be able to access the data partition, so they can both read and write to the same folders and files.

Ready? Let’s go.

Step 1: Back Up Your Data/Computer

If you have any data stored on your computer, you need to back it up first. You should hopefully already have an external hard drive or some other backup method; if not, get one!

You’ll also want a way to reinstall Windows 7 if it’s pre-installed. (You may not end up using it, if you are able to simply “shrink” the Windows 7 install, but you will want it down the road if your computer crashes.) My laptop, for example, had an option of creating backup disks which could be used to return it to its factory state if something went wrong. I used this feature to create a backup on a 16 GB USB drive.

Step 2: Get Install Disks/USB

If you already have Windows 7 installed, you may be able to shrink the install to fit its partition without needing to reinstall Windows. If you want to reinstall Windows or have not yet installed it, you’ll need a Windows install CD or some other bootable device, like a USB drive, that allows you to install Windows 7.

You’ll also need a bootable CD or USB drive for your Linux distribution (I created mine using Ubuntu.com). Ideally, it would come with the application GParted, which we will use to partition our hard drive. If not, you’ll need a bootable drive that does. (Worst-case scenario: create a bootable Ubuntu CD, use it in Step 3 to use GParted, then get rid of it and use your favorite Linux distro when it’s time to install.)

Step 3: Partition

Now we’re going to partition the hard drive. First, let’s figure out how many gigs each partition will need. Remember, all of our data (documents, music, everything) will go in the Data partition. But programs and applications will go in the partitions of the respective hard drives. Modern video games, for example, take up a lot of space.

  • Windows partition. Windows 7 alone is over 20 GB, so 30 GB is probably a bare minimum. I recommend at least 40 GB, possibly much more if you expect to install large programs.
  • Linux partition. The memory used varies by distribution but is very likely under 5 gigs. Add in the programs you’re running and 10 GB is probably a bare minimum, but I’ll recommend at least 20. If you have a large hard drive, it probably can’t hurt to leave extra space on these.
  • Data partition. This will be all the space that you have left.

Now, it’s time to actually make the partitions. First, a quick primer on partitions. Partitions are ways to divide up your hard drive. You can split a hard drive into partitions of two types: primary partitions and extended partitions. A primary partition is a chunk of the hard drive, plain and simple. And extended partition is also a chunk of the hard drive space, but an extended partition must itself be partitioned up into one or more separate chunks. These sub-chunks are called logical partitions.

You may only have up to four total primary/extended partitions on your hard drive. However, you can subdivide an extended partition into a number of logical partitions, enabling you to sidestep this limit.

Now, insert your Linux boot media (CD or USB drive) that has GParted on it. Shut down the computer. We will need to boot from the media. To do so, you may have to go into your BIOS menu and change the boot order. For my laptop, I was able to press F12 on startup, giving me an option of which device I wanted to boot from.

Once it’s booted up, find and run the program GParted. (Note: GParted asks you to select sizes in terms of megabytes, but here we’ll mainly be talking in terms of gigabytes. So be aware of the conversion!)

If You Already Have Windows Installed

Your disk will have a small partition at the very beginning (created by Windows for booting and/or system recovery; we don’t have to worry about it), then the rest of the drive is your Windows installation. (You may also have another partition at the end; my laptop, for instance, has a ~10GB partition at the end of the hard drive containing system recovery tools. If so, leave that one alone as well.)

The large Windows install is the partition we want to shrink. (It is a primary partition.) Click on it and select “Shrink Partition.” Hopefully, you will be able to shrink it to the size you want. If not, you may have too much data or it may be too fragmented. You can try defragmenting the drive and coming back to this step, or you can format this partition, erasing Windows. If you end up formatting the partition, follow the instructions for not having Windows installed. If you did shrink the Windows install successfully, you can skip to the section “Create Linux and Data Partitions”.

If You Don’t Already Have Windows Installed

It’s always nice to start from a clean slate. If there are any partitions on your hard drive, use GParted to delete them. Then create a primary partition at the beginning of the drive for Windows 7. Make it the size you decided on above and format it as ntfs. Then move on to the next step.

Create Linux and Data Partitions

Now, we’ll take the remaining space (located after our Windows partition) and allocate it as one big extended partition; then, we’ll divide it up into logical partitions for Linux and for our data.

In GParted, select the space after the Windows partition and choose to create an extended partition. Now we’re ready to create logical partitions within that big extended partition.

First, we’ll create what’s called the “swap”. Basically, this is space on the hard drive that Linux uses as extra RAM if your RAM is used up. If you don’t know about swap space, I recommend making your swap partition the same size as your RAM (if you have 4 GB of RAM, you can make the swap partition 4 GB). To create it, select the extended partition and create a new logical partition of the appropriate size. Format this partition as “swap” or “linux-swap”.

After that (but still within our extended partition), we’ll create a logical partition to hold our Linux operating system. Do so in the area after the swap space, within the extended partition. Format this as ext4, which is a standard format for Linux.

Use the remaining space in the extended partition to create a logical partition for Data. We’ll format this as ntfs, so that Windows and Linux can both read/write to it. Once that’s done, we’re done creating partitions and ready to install!

Step 4: Install Windows (if not already installed)

If you don’t have Windows installed, we need to install Windows first. Boot from the Windows CD (or USB drive if you have it on that disk image) and do a fresh install. Make sure to install it onto the partition you created specifically for Windows.

Step 5: Install Linux Distro

To install Linux, boot from your Linux installation media. You’ll want to do an advanced install (in Ubuntu, select the “Manually specify partitions” option). You will choose which partitions to use for installation. There are two partitions to worry about in this step. Set your swap area as “swap”. (Duh.) Set your Linux area (located right after your swap) as /. This is where the Linux install will go. For mount point, choose the entire device (probably called “/dev/sda”).

Now you should be able to go ahead with the installation!

Interlude: Working Machine

You should now have a fully functioning dual-boot system! When you start up the computer, your Linux boot manager screen should come up, allowing you to manually select which operating system to boot, or selecting Linux after a few seconds of inactivity. You can boot each OS to make sure they were installed correctly. Then, let’s finish the job with Step 6.

Step 6: Configure Each OS to use Data Partition

We’ll start with Linux, since it can be a bit trickier. What we want is for Linux to automatically mount the Data partition upon startup, and we want to be able to read and write the partition. In Ubuntu, I was able to successfully do so by following instructions from ubuntuguide.org. I will list the steps below; note that your mileage may vary on other versions of Linux.

First, you need to know the name of the Data partition. For example, mine was called /dev/sda7. You can figure it out with GParted, or by opening a Terminal and running “sudo fdisk -l”.

Now, we’ll make a folder to be the mount point for the partition. (“Mounting” the partition just means loading it up so the system can access the partition.) When the partition is mounted, it will appear in this folder. For this step, I created a folder named “Data” in the /media folder, since /media is where drives are usually mounted. To do this from the Terminal, you can run “sudo mkdir /media/Data”.

Now we need to change how the drive is loaded on startup. The file that controls this is called fstab and is located in the /etc folder. First, you should create a backup copy of fstab in case you mess something up. You can do that on the command line by running “sudo cp /etc/fstab /etc/fstab-backup.bak”. This copies fstab into a file named fstab-backup.bak.

To edit fstab, we can open it up in Gedit (a text editor): “sudo gedit /etc/fstab”.

There will be one or two lines describing how to load up your Data partition. For example, if it is called /dev/sda7, you might have a line that looks like:

/dev/sda7  auto nouser,atime,noauto,rw,nodev,noexec,nosuid 0 0

Comment it out by placing a # at the beginning of the line (if there are two, comment both out):

#/dev/sda7  auto nouser,atime,noauto,rw,nodev,noexec,nosuid 0 0

Now, we will add a line that mounts the partition to our chosen folder with read/write permissions. Add the line:

/dev/sda7 /media/Data ntfs-3g quiet,defaults,rw 0 0

where /dev/sda7 is the name of your Data partition and /media/Data is the folder where you’d like it to mount.

Now, reboot your system and boot back into Linux. The Data partition should be mounted and you should be able to read and write to it. To test it out, you can navigate to /media/Data (or wherever your mount point is) and create some folders. I personally put the following folders in my Data space: Documents, Media, Other, Temp, and Trash.

Last thing on Linux. On a normal Linux install, your own personal files are stored in “/home/username/”, where username is, well, your user name. To make things easier, we can make links (shortcuts) from inside this folder to our Data. I created a link to each of the above folders: Documents, Media, Other, Temp, and Trash.

Now, reboot into Windows. Windows should automatically mount the Data partition as a drive (on my system, it is D:\). You should be able to open it and see any folders and files you created on Linux. To finish things off, I recommend making similar shortcuts on Windows: In your C:\Users\username folder, delete the “Documents”-style folders and replace them with shortcuts pointing to D:\Documents and so on. You can also drag these folders into your Favorites and Library bars in Windows Explorer (on the left side) for easy access.


I hope these instructions were clear and worked well. If not, let me know!


Build Your Own Computer Part 4: Put It Together

Putting together a computer should be easy. In fact, it is easy. So let’s do it.

If you’re interested in the entire process of building your own computer, starting from scratch, then I encourage you to check out Part 1, Part 2, and Part 3. They detail the steps of understanding and choosing your components. But if you’ve got all the components and are ready to install, then it’s time for…

Continue reading

Build Your Own Computer Part 2: Understanding the Options

You want to build your own computer, right? Of course you do. By now, I’m certain that you’ve read Part 1: The Basics. If you know what the parts of a computer are, you probably skipped it. The main point I want to recapitulate is that this article was written in March 2011. [UPDATED: current as of July 2011.]  In this business, you’ve got to use recent sources.

Previously, we looked at what components go into building a PC. Now we’re going to go over that list another time, but in detail. Our goal here is to understand the options available to us when it comes time to pick out parts and make a budget.

Continue reading

Build Your Own Computer Part 1 – The Basics

Building your own computer is a piece of cake, and can be really useful besides. But it can be tough to figure out where to start. Processors? Motherboards? RAM? This post is the first of a series that will guide you through the steps to take if you’re interested in building your own computer. We’ll go from understanding the different parts of the computer, to selecting and ordering parts, all the way to installation and setup.

In Part 1, we’ll look at exactly what parts are required and what they do.

Part 2 goes a little more in-depth on the technical aspects and options available.

Part 3 offers a guide on how to pick out your parts, once you know your choices.

Part 4 is a guide on how to actually put the thing together.

This is what we're going for

Continue reading