Original URL: https://www.theregister.com/2010/06/23/reg_linux_guide_2/

The Reg guide to Linux, part 2: Preparing to dual-boot

Lining it all up

By Liam Proven

Posted in OSes, 23rd June 2010 11:02 GMT

On Monday, we suggested Ubuntu as a good starting point for experimenting with desktop Linux. If you have the option, dedicate a machine to it – by 2010 standards, even a modest-spec PC will run it fine. You'll be very pleasantly surprised by the transformation from a lumbering old XP box burdened with years of cruft to one with a fresh install of an OS that doesn't need multiple layers of security software.

If you don't have that option, though, you'll have to run the two systems side-by-side. There are three main ways:

  1. The traditional dual-boot arrangement, using multiple disk partitions.
  2. Wubi, which means installing Ubuntu inside a file in the Windows filesystem.
  3. Virtualisation.

Option 3 is for weenies. You don't learn anything about the performance or feel of the OS on native hardware running it in a VM, and you might lose the joyous experience of hunting for drivers – although there's a pretty good chance these days that you won't need any. The second option, Wubi, works fine, but it's a bit slower and less flexible than a native install, and if you decided to “go native” and switch to Ubuntu full-time, you can't get rid of Windows later – you're lumbered with the virtual-hard-disk-in-a-file arrangement.

We recommend the old-fashioned way: shrink your Windows partition to free up some space, create some new partitions and put Linux in there.

Before you do this, though, it pays to do some preparation and do a little housekeeping on your Windows system. The following assumes you're on XP – some of these steps are significantly harder work on Vista or Windows 7.

Housekeeping

You can do a lot of this from the command line, but if you're using Vista or 7, it won't let you. Save yourself some time and make an Admin-mode command prompt shortcut – create a shortcut to CMD.EXE, then right-click it, choose Properties and set it to run in administrative mode.

First, clean out your TEMP folders, both the global one, C:\WINDOWS\TEMP, and the user one. If you're on XP, that's in C:\Documents and Settings\%USERNAME%\Local Settings\Temp, where %USERNAME% is the short form of your sign-in name. (If you're on Vista or Windows 7, it's in C:\Users\%USERNAME%\AppData\Local\Temp.) "DEL *.* /s/q" is your friend here. If you have several user accounts on the PC, don't forget to clean out everyone's Temp folder. It's safe to delete everything in there, but to remove stubborn hangers-on, you might need to reboot, or better still, start the PC in Safe Mode. For a really thorough clean-up, you can search the disk for files matching "~*.*" and remove them – they're temporary files which MS Office tends to litter all over your drive.

Next, look in C:\WINDOWS. You'll probably see loads of uninstall folders for Windows updates - usually, these are called things like $NtUninstallKB898461$: anything with a name starting and ending with a dollar sign and called "NtUninstall" followed by a number or name. Only delete these ones - leave everything else, including the folder $hf_mig$ if you have it.

Reboot to make sure everything still works. If all seems fine, empty the Recycle Bin. Next, open a command prompt and do a CHKDSK /F on all of your drives.

If you've got a single hard disk drive with multiple partitions and you want to dual-boot, for simplicity's sake, it's easiest to consolidate all your files onto drive C:, or at least cut things down to just two partitions, one for software and one for data. Similarly, if you've got multiple hard disks, for an easy life, shuffle your stuff around so as to give Linux a whole drive to itself.

After you've rebooted and done the disk checks, defrag any Windows partitions you're going to resize. This isn't essential, but it can speed things up a bit. Don't waste your time on third-party tools - the built-in free defragger is good enough. For a slightly faster and more thorough job, do it in Safe Mode.

Getting a copy

Decide what you're going to run. Vanilla Ubuntu 10.04 is easiest. If you can't stand the thought of window buttons on the left or you would like your media codecs pre-installed, try Mint 9 instead – it's the same underlying OS.

If you have a 64-bit PC and 4GB or more of RAM, by all means try the 64-bit edition. It's a little faster, but some drivers and plugins, notably Flash, can be problematic. If you're not sure whether your CPU is 64-bit capable – for instance if it's a late-model Pentium 4 – an easy way to find out is to try to boot 64-bit Linux. It won't work but it will print a nice little message telling you why.

If you just want the least hassle, or if you have 3GB or less RAM and don't plan to upgrade, go with the 32-bit edition. In any case, the 32-bit version can access more than three-and-a-bit gig of RAM with a workaround called PAE and you'll probably never notice the slight slowdown.

If you're feeling adventurous, you can multi-boot several distros on the same PC, including 64-bit and 32-bit side-by-side. It's safe to share the same home and swap partitions between them, but to avoid getting settings muddled, use differently-named user accounts on each one.

The easiest way is to download an ISO file from the server nearest to you and burn it to a blank CDR. (Don't burn a CD image on a DVDR – this can confuse some BIOSes. If you only have DVDRs to hand, there's a special DVD image under "Alternative downloads". It's the same OS - they just put a few more packages on the disk.) You can either download a file in the usual way – the DownThemAll extension makes it a bit quicker for Firefox users – or grab a torrent and help other users by leaving it running for a while.

If you're on XP and you don't have additional CD-burning software, don't try to use XP's built-in burning functionality to write the CD: you'll just end up with a disc with one honking great file on it, which is no use. ImgBurn is free, easy and does the job.

If you haven't got a burner or have restricted bandwidth and can't readily download 700MB of data, Canonical will even post you media free of charge. To install on a PC with no optical drive, UNetbootin will let you create a bootable USB key.

Partitioning

Soon enough PCs will shift to EFI firmware, like the Intel Macs, and the BIOS will shuffle into history, but for now, we have to live with the limitations of the PC BIOS from the heady days of 1981. This means no more than four primary partitions per drive and the PC looks for the boot sector on the first physical drive. The recommended config is a single primary partition on the first drive, with all other partitions as logical drives in a single extended partition. If you have multiple drives, use only logical drives on all the others. You don't have to do this but it makes life easier. Also note that you might have a hidden recovery partition that counts for another of your four primaries.

For Linux, the minimal recommended config is three partitions: one for the root filesystem (FS) ("/" in Unix shorthand), which holds the OS and apps; one for the home filesystem ("/home"), which stores your home directory; and a third, right at the end of the disk, for swap – Linux' virtual memory system. You don't need a huge amount of space – 8GB will do for the root partition, 16GB is plenty and 32 or more is almost overkill. The advantage of keeping the home directories in a separate partition is that it makes it much easier to re-install or even change to a different distro.

For the swap partition, the traditional sizing recommendation is twice physical memory. Today, there's not much point going above 2GB of swap. If you have more than 2GB of RAM, 2GB of swap will probably be plenty, but if you have disk space to burn and 12GB of RAM, feel free to assign 24GB of swap that you will never use. Once you've worked out how much space to take from Windows and how much to give to the root FS and swap, give the rest to your home FS.

An old guideline when building a multi-boot PC is to manipulate partitions under their native OS where possible. The snag here is that XP doesn't have the functionality to shrink its own partitions. Vista and Windows 7 do, although sometimes not by as much as you might expect.

If you can, use Windows to shrink its own partitions. If not, boot the PC from your new live CD and use the partitioning tools on there. The setup program will walk you through partitioning, but it's arguably preferable to do it in your own time with the "Gparted" tool – a Linux equivalent of PartitionMagic. You'll find it under the System menu in Administration.

After you've shrunk the Windows volumes, check that Windows still boots OK. If not, you can use an XP, Vista or 7 install CD or the Windows 7 Recovery CD to repair it. Even if it comes back up fine, it's a good idea to run a CHKDSK again, just in case.

To avoid problems, don't try to put Linux first on the disk, followed by Windows. Linux expects to share; Windows doesn't. The same goes for putting Linux on your first hard disk and Windows on the second - just don't. The ideal simplest setup is Windows in a single primary partition, followed by an extended partition containing all the Linux partitions, or Windows alone on the first physical drive and Linux alone on the second.

If you've got multiple drives, it is possible to disable one in the BIOS, install on the other, then use the BIOS to switch between them – but if you get it wrong, this can be risky, it makes it harder to share data between OSs and in any case the Linux boot menu is painless and far easier. Linux will happily access and both read and write FAT, FAT32 and NTFS volumes, so you can get at your Windows files and documents while you're in Linux. Your Linux volumes will be invisible from within Windows, though, without additional software.

When creating the partitions, make sure that you create them in their on-disk order. If necessary, use a calculator – there is one on the live CD under Applications | Accessories – to work out the sizes, rather than creating the root partition first, then the swap partition on the end of the disk, then finally filling the remaining space with the home partition. Linux is perfectly happy with out-of-order disk partitions, but they can cause problems with Windows.

Some other gotchas to watch out for include RAID setups. There are basically three kinds of RAID – software, firmware and hardware. Unfortunately, the most common on Windows desktops is firmware RAID, where the disks are attached to motherboard controllers and the array is created in the BIOS and managed by a special driver under Windows. You can't partition such an array and share it with Linux. Proper hardware RAID, with the disks on a dedicated controller card, can be shared, but it's complex and not worth the effort. Don't bother; split the array up into standalone drives and dedicate some disks to Windows and some to Linux. True software RAID is only found in Server editions of Windows, which you probably wouldn't want to dual-boot anyway. Linux has its own excellent software RAID system, but it's not interoperable with others OS's implementations. In any event, RAID is primarily a server thing and dual-booting a desktop one; don't mix them.

Summary

So the preparatory steps are:

  1. Clean up your Windows drives.
  2. If you've got multiple partitions or drives, consolidate your stuff down onto as few as reasonably possible.
  3. Download an ISO of your choice of distro and burn it to an optical disc.
  4. Check the PC boots from it OK.
  5. If you're using Vista or Windows 7, use it to shrink your partitions down to make room for Linux. Otherwise, use the live CD to do it.
  6. Check Windows still boots OK.
  7. Create your new Linux partitions.

Once all this is done, you're ready to actually install the new OS and set it up – which we'll cover in tomorrow's article. ®