How to dual-boot Linux and Windows

4th Jul 2010 | 11:00

How to dual-boot Linux and Windows

Partitioning, cross-platform apps and sharing data explained

Introduction to dual-booting

Many of us like to run more than one operating system on a single machine. It's a great way of experimenting with how the other half live, testing new distributions and even playing a few Windows-based games.

But dual and triple booting has always been considered something of a dark art. This is because it involves the double jeopardy of messing around with your disk partition tables and playing with a pre-installed operating system. If things go wrong, it can be a disaster. Or at least, that's the popular perception.

The reality is that dual booting needn't be a risk, and installation can be effortless. With the latest distributions, you might not even notice the process. All this means that if you've been put off by older installations and those old horror stories of things going wrong, it's time to try dual booting again, and our our aim is to demystify exactly what is happening and give you the confidence to delve into the world of dual boot.

But before we push off into the world of running Linux alongside Windows, and Linux alongside Linux, there are a couple of important considerations.

First, dual-booting still involves a lot of data shuffling, and while we've not seen the process go wrong for years, if your data is valuable, it's not worth the risk. If you've got anything on your system that you couldn't live without, make a copy of it now before it's too late.

Secondly, with multiple-boot systems, planning is everything. If you've got a blank system that you know you're going to install more than one operating system on to, you can save yourself a lot of time by working out how those systems are going to be arranged, how much space you'll need for each OS, and how you'd like them to be installed.

Partitioning your drive before you install the first operating system can save you tons of number crunching and the risk of repartitioning. If you do this, follow our partitioning guide, then install Windows first followed by your favourite Linux distribution.

Finally, as with all things Linux, the main thing is to enjoy the freedom of being able to dual boot, because Linux is the only mainstream operating system that actively encourages you to do so.

Install Ubuntu 10.04 alongside Windows with these three easy steps

1. First boot

There are two ways to dual boot with a Windows system preinstalled. The first is to add a new or spare hard drive to your system and use this for version of Linux you want to install. The second solution is to use the installer to automatically resize your Windows partition to make room for the new Linux one.

Step 1

This works well, and it's the method we've used, but there is a slight risk that if anything goes wrong during the resizing process, you may lose all your date. Back up now! Insert the Ubuntu disc into your optical drive and reboot your machine.

If your system ignores the disc and jumps back to Windows, you'll need to either look for a BIOS boot menu key as soon as your computer starts, or enter the BIOS and change the boot order manually.

If the drive is successfully read Ubuntu presents the welcome screen, from where you can choose between running the CD in live mode, or proceeding directly to the installation. We chose the latter.

2. Get the balance right

You now need to answer a couple of standard pre-installation questions, including which time zone you're located in and the layout of your keyboard. After these you'll see the 'Prepare Disk Space' page. If your Windows installation has been detected properly, the first line on the page will explain that 'This computer has Windows on it', and the default option of 'Install them side by side' will be selected.

Step 2

Keeping the options at their default value will create a dual-boot system. Use the divider in the horizontal bar at the bottom of the window to adjust the sizes of the Windows and the new Linux partition. The Ubuntu installer knows how much space is currently filled within the Windows partition, and it won't let you reduce the size of its partition to less that this.

Which partition you give the most space to depends on which you're going to use most, but we'd recommend at least 10GB for the Ubuntu installation, and much more than 10GB if you intend to make the Linux environment your main operating system.

3. Resize and migration

When you're happy with the division in space between the two operating systems, click on Forward. Resizing the Windows partition and creating new ones for Linux can take some time. In the background, Windows data is being moved into adjacent blocks of your hard drive before the partition table is rewritten to include the new Linux partitions and the resized Windows partition.

Step 3

When the resize processed has finished, you'll see the user account settings page. Enter a username, password and a name for your computer and choose whether to log in manually. The next page is Ubuntu's Migration Assistant. This will attempt to import data from the Windows partition and move it to your new user account.

You can choose to import your bookmarks, wallpaper, avatar, music, images and documents, all of which will be placed in their corresponding home folders. Finally, click on Forward, read the overview and click on Install to create a new Ubuntu installation.

How to partition your disc

Don't be scared of carving up your hard disk – we know what we're doing

The biggest hurdle that most dual-booters have to overcome is their fear of partitioning. This is the process of splitting up your hard drive into chunks so that you can install more than one OS.

It's not so daunting if you're working with a new hard drive, as even if something goes wrong, you're not going to lose any data. But many people want to re-adjust an existing configuration to make space for a new one, and this is where things can go wrong.

This is why you should make a backup. It's also wiser to do all your partitioning before you get to the installation stage. You can then make a better judgment about how much space you need, and ensure that the drive is configured correctly before you reboot with the install disc.

Write changes

Most distributions and installers use the same tool for partitioning: GParted. If you boot into the Ubuntu desktop from the CD by selecting the 'Try' option, you'll find GParted in the System > Administration menu.

You first need to select the drive you want to edit from the drop-down menu in the top-right. This will fill the graphical display with the layout of that drive and a list of partitions in the lower panel.

Each partition looks like a horizontal block, with the space used within that partition indicated by a block of colour. To resize a Windows partition, look for a block formatted as either NTFS or FAT32 and select it. Right-click on the partition and select 'Resize', and in the window that appears, use the arrow on the right to reduce the size of the Windows partition and free up space for new installation. Click on Apply to make the changes permanent.

Create a new partition

You should now have a large block of unallocated space. Right-click in this space and select 'New' to create a fresh partition. You should select ext4 as the filesystem and click on 'Add' to make the change permanent. You can do this as many times as you like, depending on how you want to configure your new system and the limitations of your hardware.

A SATA drive will only let you have a maximum of four partitions for example, and you will also need to create a small swap partition. When you come to install a Linux distro, make sure you select the manual partitioning option.

From there you will need to select one of your spare partitions and assign a mount point of /, as well selecting and assigning the swap partition. Your distribution will then be able to install the files to the correct place and add the appropriate boot menu entry for when it's time to reboot.

Make space for new partitions

1. Launch GParted

Step 1

Boot into live CD mode from the Ubuntu disc and launch GParted from the Administration menu. Select the drive, right-click on the existing partition and select Resize. Use the small window to reduce the main partition.

2. Create partitions

Step 2

In the newly released space, right-click and select New. Create one or two new large partitions alongside a smaller partition, which will be used as Linux swap space, then click on the 'tick' mark.

3. Use the partitions

Step 3

After the partitions have been created, you can install a new distro. When you choose the 'Custom' partition option, you'll be able to use your new partitions by assigning them to the / mount point and swap space.

Run Windows and Linux

You can get the best of both worlds by running the two side by side

With Windows and Linux together, you'll be able to choose between them from the boot menu that appears when your machine restarts, and the next step is to help them both live together in harmony.

Despite Windows and Linux being two completely distinct operating system, where almost everything that can be different is different, there's a lot you can do to help the two work together.

The first problem that most users encounter with a dual boot system is file sharing. When you first boot into Linux from the dual-boot menu, it's likely that you'll need to access files within your Windows installation, and when you switch back to Windows, you'll probably want to be able to read the files that you were working with.

The reason why this is a problem is because both operating systems use different filesystems. This is the indexing system used to save and retrieve files to your storage medium, and without a bit of outside assistance, neither Linux nor Windows can read the other's formatting.

Sharing data

Fortunately, the people who build Linux distributions mostly provide this help for you, and this should mean that you'll be able to read Windows partitions from your new Linux installation without too much difficulty.

The easiest way to check is to launch the file manager and see if your Windows storage device is listed in the device panel list on the left. It's unlikely to be labelled clearly, and it might just be named after its size, but if you click on it you'll be able to see the files of a standard Windows installation.

Personal files can be found by clicking on Documents And Settings, followed by the username of the folder you want to access.

Linux can load and save many of the most common files in exactly the same way that Windows does. JPG images from digital cameras, for example, can be viewed with a simple double-click, and you'll find the same level of integrated support for text files, many music files and most open document formats.

Windows

Mounting your Linux partition from within Windows isn't quite so easy and not as convenient as the in-built ability you'll find in most Linux distributions. The best solution we can find is to download and install a Windows tool called Explore2fs.

Explore2fs

This is a Windows application that enables you to choose your Linux partitions from a drop-down list in the top-left of the window, and display their contents using an old-style Windows explorer view in the main window. This means you can drag and drop files to and from this window just as you would with any other directory on your Windows operating system.

You can find your personal files within a Linux installation by clicking on the Home directory followed by the folder named after your account name. Distributions will normally place files within either the Download directory, or the Desktop directory.

It's worth noting that Explore2fs is also quite capable of reading Linux-formatted USB, floppy and external drives.

Cross-platform applications

Maximise efficiency by using the same software on both operating systems

If you want to ensure that the files you create within the Windows and Linux environments are equally compatible, you'll ideally need to use the same cross-platform applications on both.

If you use an office suite, for instance, using the free and open source OpenOffice.org suite instead of Microsoft Office will guarantee that files you save in Windows will look identical on Linux.

If you need to stick with Microsoft's tools on the Windows platform, OpenOffice.org will still do a good job at opening them and converting them within Linux, but you may run into problems with more complex documents, especially spreadsheets.

Cross platform software

You can also mitigate any internet browsing pain by using either Firefox or Chrome. Both are cross-platform and share almost exactly the same features, enhancements and plugins. You should be able to recreate exactly the same web browsing environment from both.

Bookmarks can be synchronised across platforms using the XMarks add-on in Firefox, or through Chrome's ability to sync browsers through your Google account. The manual option is to use the bookmark browser in either application to export your lists of bookmarks and import into the other.

Email

It's the same strategy for email. Most people who have been using Windows for a while will be using a variant of Microsoft's Outlook email client, and downloading their email using the POP3 protocol.

While Linux-based applications like Evolution and Thunderbird claim to import email archives from Microsoft's widely used Outlook series of applications, we've had little success using them to import our email.

There are third-party tools, most notably the commandline tools you can find hidden within the readpst package, but your best option is usually to run Thunderbird from Windows at the same time as Outlook and use its import function to grab a copy of your email database while both applications are running. You could then use Thunderbird on your Linux installation to move the mail database from Windows to your home directory.

But the best option for email is to switch from using POP3, where email is downloaded and saved locally, to IMAP, where email is usually kept on a mail server and synchronised with your email client. In this way, both Outlook and Thunderbird can access the same server and the state of your email is preserved.

How to run two Linux distros

There's no reason to limit yourself to just one flavour of Linux

Running Linux alongside Windows isn't the only reason for dual booting. Many of us also like to run Linux alongside Linux, enabling us to try new distributions and keep old ones running without having to resort to a complete system overhaul.

You should also encounter far fewer problems with running Linux alongside Linux, as most distributions know how to recognise one of their own and will adapt accordingly. They should be able to sidestep any currently used partitions and neatly add themselves to any existing Grub menu configuration.

As with Windows, the biggest consideration is always going to be the arrangement of partitions on your hard drives, and where you're going to find the space for a new Linux installation. If you can allocate space for a new Linux partition before installing a new one, the process is going to be easier than wrestling with your new distribution's partition manager, if it has one.

You can also make sure that any data you need is backed up at the same time, because resizing partitions always has a degree of risk. But even if you've got the space organised before you install the new system, it still might be worth taking a look at the custom partition configuration.

Account details

Unlike most versions of Windows, Linux doesn't require a 'Primary' partition to be able to boot. This isn't going to be an issue if you only intend to run Linux, but if you ever do want to add Windows to your partition table, you should try to make sure that the partitions used by your Linux distributions are configured as 'Extended' rather than primary, as this will leave space should you wish to add Windows later on.

Swap and share

Normally, a standard Linux installation will require a minimum of two partitions – one for the root partition that holds all your files, and another smaller one that's used as a swap partition.

A swap partition is basically an overflow area that's used to cache larger items from your RAM, as and when your system needs to. As a result, it's not used when the distribution isn't running and you can safely share the same swap partition among several Linux installations.

Swap partition

But there's one important exception to this rule, and that's hibernation. This is the power-saving ability that some configurations have where you can put your machine into a save-state, where the contents of memory are written to the swap partition and restored when the machine is turned back on. This can be quicker than a fresh start, and your machine will be in exactly the same state you left it.

If you share the swap partition with another Linux installation, that copy of what's running will be lost in exactly the same way it would be if there were a power outage. With many distributions, this won't be an issue.

If you install Ubuntu 10.04 alongside the 9.10 release, for instance, the installer will inform you that it has detected the previous installation in the 'Prepare Disk Space' screen. This is very similar to the Windows dual-boot view. Use the horizontal slider in the partition strip at the bottom of the window to alter the space allocation on your drive between the two distros in just the same way as Windows resizing.

You might also notice that the two distributions will be sharing a single swap space, just as we created manually. After you click on Forward, the existing partition will then be resized accordingly, hopefully keeping your data intact.

Emergency recovery

Don't worry if you lose your boot menu or partition name – we can help…

All this messing around with partitions and boot blocks can cause problems. So it's worth remembering that even if things look bad, there is usually something you can do to recover lost data.

If you realise you've made a mistake in re-partitioning a drive before you get to the point where those partitions are formatted, for instance, there may be a way to save your data. When a new partition table is written to your drive, none of the data is affected; only the part of the disk that indicates which partitions are where. There are a few tools than be used to trawl through this data and can recognise and log the changes between your files and the previous partitions boundaries.

Emergency recovery

We've found the best tool for the job is called TestDisk, which can usually be installed through your distribution's package manager, and on the command line with apt-get install testdisk on Debian and Ubuntu systems. Typing sudo testdisk on the command line will launch the menu-driven utility, and you'll need to select the log option you need followed by Proceed on the partition you're interested in.

The tool will run its magic. Then select Write and give a few confirmations that you're happy with the potential hazards that the tools could reap upon your data. But with a bit of luck, a single reboot later should see your partition table restored, along with your dual-boot abilities.

Come back Grub!

Similarly, losing your Grub menu can feel equally catastrophic, but you should be able to restore your system to full working order. For pre-Grub 2 installation of around a year old, boot the machine off an older live CD, open a command line and type sudo grub.

This will drop you into the command line mode of the Grub boot loader, and from there you need to type find /boot/grub/stage1.

The returned output will show you the location of your boot partition, and you'll need to replace hd0 with your own drive in the following commands – root(hd0,0) and setup (hd). Finally, type quit and reboot your system. You should find Grub re-installed.

For Grub 2-based systems, you should be able to just boot off a live CD and type sudo update-grub to restore the boot loader and get your system running again. This should leave you with all bases covered.

You can create partitions with confidence, install Linux alongside Windows and other Linux installations, and troubleshoot all the most common problems if anything untoward should happen. You can now sit back and enjoy the benefits of your new multi-booting system.

-------------------------------------------------------------------------------------------------------

First published in Linux Format Issue 133

Liked this? Then check out How to run Linux in a virtual machine

Sign up for TechRadar's free Weird Week in Tech newsletter
Get the oddest tech stories of the week, plus the most popular news and reviews delivered straight to your inbox. Sign up at http://www.techradar.com/register

Follow TechRadar on Twitter * Find us on Facebook

tutorial Linux Windows TRBC
Share this Article
Google+

Apps you might like:

Most Popular

Edition: UK
TopView classic version