X
Tech

Windows to Linux Considerations

I have been asked by several people recently, both through here and privately, about the steps involved and the decisions to be made in converting a PC running Windows to Linux. After repeating the whole thing a few times, I decided to put it here for reference.
Written by J.A. Watson, Contributor

I have been asked by several people recently, both through here and privately, about the steps involved and the decisions to be made in converting a PC running Windows to Linux. After repeating the whole thing a few times, I decided to put it here for reference. These are based on my own experiences - anyone who has different, better or additional ideas should add them in the comments.

- First, especially if you are starting with a new PC, make sure that you have complete Windows recovery media. This is even more important (and potentially tricky) today than it has been in the past, because a lot of new systems today do not come with Windows installation CD/DVDs included, they only have a "recovery partition" on the hard drive. In this case make sure that you use whatever the manufacturer's "recovery media creation utility" might be to create yourself a set of disks - it will usually be about 3-5 DVDs. Yes, I know, we all hate Windows and we will be glad to see it getting wiped from the disk, never to return... but you never know what is going to happen to that PC, and perhaps someday you will want to sell or pass it along to some poor schmuck who insists on running Windows...

- Decide whether you want to run Linux exclusively, or whether you want to dual-boot Linux and Windows. I am not going to discuss the option of running Linux under Windows (wubi) here, because I choose not to do it and I know nothing about it. Likewise, I will not discuss running Linux from a Live CD or USB stick, since there isn't much to consider - just do it! If you decide that you want to run Linux exclusively (congratulations!) you can skip the next step and proceed directly to partitioning and allocating the disk space.

- If you are going to keep Windows and dual-boot with Linux. you need to make sure that Windows has been completely installed, and thus is done monkeying around with the disk. A lot of new systems today don't have Windows really "installed" when they are sold, but when you boot them for the first time they run through the installation procedure from the recovery partition on the disk drive. This is likely to change the disk partitioning and write the Windows bootloader to the disk, and I can tell you from experience that it is VERY frustrating to spend the time installing Linux and then have Windows scribble all over it. So, if you are installing on a brand new PC, make sure that you have booted it at least once and gone through the "Preparing Windows for First Use" procedure before you install Linux.

- Ok, here comes the part most people find tricky, confusing, difficult or whatever. It really isn't that big of a deal, you just need to understand what is going on. First, for very old historical reasons, a PC disk drive can only have four partitions. However, one of those partitions can optionally be an "Extended" partition, which is then able to contain a lot more "Logical" partitions. This means that in the simplest case your disk drive can be one huge partition - which many/most Windows systems were until fairly recently, with one huge C: drive - and in the most complex case it can have three "Primary" partitions and one "Extended" partition, and the extended can contain some more "Logical" partitions. Again for very old historical reasons, I don't create more than 15 partitions in total, but with most Linux distributions today you can have more than that. Great, so what does that all mean? Well, new PCs today typically come with at least one partition allocated to Windows, for the C: drive, and sometimes with a second Windows partition for the D: drive, and you might even be given the opportunity to set the relative sizes between those two. In addition there might be a "Recovery" partition containing the Windows installation image, and a "bootloader" partition (you can tell this one because it is very small, something like 100MB). Finally, if you are very unlucky, there might even be a vendor-specific "Tools" partition - HP is particularly known for this one, but they are not the only ones who do it. Whew, that's a lot of partitions, and a lot of information! Fortunately, it turns out to be easier in practice than it is in theory...

- Once you have an understanding of what disk partitioning is about, and what you might find on your disk, you need to look and see what is actually there, and how it has been allocated. I have found the Windows "disk management utility" to be worse than useless in this regard, because it is often actually misleading. It seems that Microsoft has decided that there are some partitions that you don't need to know about, so they don't bother showing them. That is unfortunate, when you are really trying to manage your disk drive. So I use one of the Linux disk/partition management programs; something like "Parted Magic" on a Live CD/USB, or one of the other disk management recovery distributions is well suited for this purpose. However, I have found that Ubuntu and most of it derivatives, such as Linux Mint, always have the gparted utility on their Live image, so at this point I just boot up a Mint Live US stick, and use that for partitioning and installing at the same time. When you run gparted you will see what the partition layout on your disk really looks like. If there are less than four partitions, you can make this very simple and not worry about whatever else is on there.

- Let's take the simplest case first - you find that there is only one partition on the disk, which is being used for Windows. All you need to do is reduce the size of that partition to make room for Linux, and gparted knows how to do that! Hooray! I typically reduce my Windows partitions to something like 32GB or 64GB, depending on how large the disk is and how much data I have under Windows. Whatever size you decide on, click the Windows partition, click the "Change Size" icon, and enter the new size. Then click Go and let it work for a few minutes. Once the change has fininshed, it is not a bad idea to boot Windows right away - it will complain that someone has been messing with the disk drive, but it should run checkdsk and cleanup whatever it doesn't like, then everything will be fine. Then go back to the Live media, run gparted again, and make yourself some Linux partitions - for a very simple installation, two of them would be enough, one for swap and one for the Linux root filesystem. Unless you have a very large amount of memory or a very small disk drive, I would make the swap space 4GB, and the root filesystem something like 16GB or 32GB. Of course you can make it larger than this if you want/need and have the space, and I have on occasion made the root as small as 4GB.

- Another reasonably simple case is when the Windows installation has allocated a second partition for the D: drive, and you aren't using it (or haven't used it yet, in a brand new installation). In this case, after confirming and re-confirming that you have nothing on the Windows D: drive, you can just take that over, turn it into an Extended partition (it will be a Primary the way Windows creates it), and then create your Linux setup as Logical partitions within that Extended partition. It is NOT necessary to have three Primary partitions before you can make an Extended partition; even if your disk drive only has two partitions, you can use it this way and make one of them Extended. In order to do this, you tell gparted to delete the second partition - MAKE SURE you know which one is which and point at the right one - and then create a new Extended partition in its place. Then at a minimum you create a swap and a root partition within that, and you're ready to go!

- Finally, if you find that your disk already has several partitions for Windows, Recovery, boot, tools or whatever, you have to give a bit more thought to the whole situation. If there are less than four partitions, you can simply proceed as described above, reduce the main Windows partition and create an Extended partition, and put Linux there. If there are already four (I've seen this a few times on HP laptops), you're going to have to delete one of them to make room for Linux. If you have already make a set of Recovery disks, the obvious choice is to wipe the recovery partition, or if you know the recovery disks included the contents of a separate "tools" partition, you can wipe that. If none of this looks like it is going to work out, or it doesn't make any sense, GET HELP. Don't "just try something", because you can inadvertently wipe your Windows installation, or otherwise render it unbootable, and then you are stuck re-installing Windows (ugh). Another thing you might find on the disk is an "instant-on" or "minimal boot" partition (I've seen these on some Lenovo laptops/netbooks). These are often stripped-down Linux systems, so if you know what you are doing, and you're going to install your own Linux anyway, you might want to dump that one. However, keep in mind that if there is a nice little "Quick-Boot" button or some such, it is not going to work after you wipe that partition.

Ok, in summary let's consider three cases. In the simplest case, there was only one huge partition on the disk drive containing the Windows C: disk. This was often the case with Windows XP, but we aren't this lucky very often any more. In this case you can reduce the Windows partition, then create two more partitions for Linux swap and root, and then you're ready to install. If you're really ambitious (or curious) and want to install even more Linux distributions, you could create a fourth partition, as an Extended partition, and then make some more Logical partitions in there to play with. Wow, nice. Oh, I should also mention here that it is perfectly ok for multiple Linux installations to use the same swap partition, there is no reason to create a separate swap for each different distributions you install. Well, not exactly no reason, but very little reason, and it isn't worth going into here, just let them share.

In the more typical case these days, when you buy a PC with Windows 7 installed, there are two or three partitions on the disk already, containing some combination of Windows C:, D:, Recovery and boot/diagnostic. If you want to keep everything more or less intact, you can reduce one of the Windows partitions, then create an Extended partition and work entirely within that. If you don't really need the Windows D: partition, you can delete it and either create Primary partitions for swap and root, as above, or replace it with an Extended partition.

In the worse case these days, you find that there are already four partitions allocated and used on the disk drive. You have no choice, you have to delete at least one of the existing partitions. The important thing is to make sure you know what each partition is used for, make sure that you have backups or recovery disks, and "choose wisely". Assuming that you have the recovery media, deleting the Recovery partition probably makes the most sense. Then just proceed as above...

One last thing to wrap this up. I know that Ubuntu, and its derivatives, have an install program with a built-in "Install Linux beside Windows" option, which is supposed to do all of this for you automatically. I have never used that option, so I can not vouch for how well it works, but I assume that it is good - it has been around for quite a while, and I haven't ever heard any complaints about it. I'm just a bit old-fashioned and conservative, and I don't like for programs to "help" me by making changes to my disk partitioning. But if you don't have a good understanding of what you are doing, it might be a better choice to let the installer do it for you automatically rather than try something yourself and screw it up. You can always go back and look at what the installer did, and learn from that.

Comments, advice and other experiences are welcome, as always.

jw 6/10/2011

Editorial standards