'

How to: Disk partitioning for Linux and Windows dual-booting

One of the most confusing and intimidating parts of installing Linux for dual-booting with Windows is the disk partitioning required.

In the comments on my recent posts about installing Linux on a netbook for a novice user (see my recommendations and my own results), someone mentioned that figuring out the disk partitioning was very difficult and particularly intimidating for new (or prospective) Linux users.

I suppose that is true, and I have to admit that I haven't contributed much to solving this issue in my blog, because every time I write about a Linux installer, I just sort of wave my hands at that part and say "pay no attention to that man behind the curtain" because the partitioning on my systems is far too complicated to be used as an example. Every computer I own has 6 to 10 Linux distributions and occasionally Windows as well (although Windows is thankfully becoming less and less common on them).

What I would like to do in this post is present a couple of simple examples of installing Linux for dual-booting on an existing Windows system. I will be using an old Lenovo T400 notebook running Windows 7, with MBR disk partitioning and legacy BIOS boot - I will not discuss GPT partitioning or EFI boot in this post.

If you don't know what MBR, GPT or EFI mean, don't worry: it basically means the laptop disk I use will be very similar to most computers purchased with Windows 7 or older, but not like one with Windows 8 or Windows 10.

In order to understand disk partitioning and make really good, informed decisions about this part of installing Linux, a lot of underlying information is required. If I try to present all of that first, though, a lot of readers are going to give up and move on to a more interesting article. Even worse for me, some readers are just going to throw up their hands and say "this Linux stuff is just too complicated", when in fact it really isn't.

So once again, I am going to present things in a sort of backwards order - I'm going to show the installation dialog, and I'm going to run through the installation in the simplest possible way. Once that is done, I will spend some more time (a lot more time) explaining what really happened, and what the alternatives are.

I recently posted screen-shot walk-throughs of several common installers, so I won't repeat all the steps which lead up to this point - if you want to see those details, please refer to Calamares and Ubiquity or Anaconda and Mint Install.

partitions.png

Calamares Installer Partitioning

The screen shot shown here is the Partitions step of the Calamares installer. The layout shown here is one of the simplest situations, and probably also one of the most common. It shows that my T400 has one disk drive, about 150GB, which contains two partitions:

  • Windows 7 Loader
  • Windows C: drive

This would be very typical on a new PC that is preloaded with Windows 7.

The task here is to change the partitioning of this drive so that Linux can be installed. The options that Calamares offers are:

  • Install Linux alongside the existing Windows installation: The installer will automatically make the necessary changes and ask you for approval.
  • Replace a partition: This one is conceptually very easy, if you know that there is an existing partition that is not being used, you can just say "put Linux here". This could be the case, for example, if you have a new computer with a C: and a D: drive, and you know that D: hasn't been used for anything.
  • Erase disk: This is the best option, of course. Get rid of the Windows rubbish that is cluttering the disk and start over from scratch. As with the first option, the installer will automatically allocate the new partitions
  • Manual Partitioning: This is the option for those who know what they are doing and how they want to allocate the disk space. If you choose this option the installer changes to a more detailed partition management screen, and you can do pretty much anything you want.
alongside.png

For this first very simple example I am going to choose, 'Install Linux alongside the existing Windows installation'. Calamares then adds a second graphic bar showing the proposed new disk layout, and asks me to select a partition which will be reduced to make room for Linux installation.

In this case there's not much choice - there is only one partition that is large enough to be used, so I select that one by clicking the button between the two bars.

Calamares then splits that partition in the middle, and puts a bar there which I can drag in either direction, to give more or less space to Linux or Windows. When I'm happy with the sizes, I click Next.

Believe it or not, that's all I have to do! The Linux installer will reduce the size of the WIndows partition, and create what it needs to install Linux in the space that it recovers by doing that. I can then continue through the rest of the installation. When it is finished I will have Linux installed, and when I reboot it will present a multi-boot menu where I can choose Linux or Windows, with Linux as the default. Zowie, that was amazingly easy!

gparted.png

To see exactly what happened to the disk, I have used my preferred Linux disk management utility, Gparted. Here you can see that what it did was the absolute simplest thing that it could - made one new partition, formatted with the Linux ext4 filesystem, and loaded Manjaro Linux there.

I know a lot of you might be saying "wait a minute, it can't be that easy!", but it is. You need an absolute minimum of one partition to install Linux. I will explain more about this below, so please just bear with me for now.

Let's take another look at that process with a different Linux installer. This time I will use Linux Mint 18 (Beta). This installer is derived directly from the Ubuntu installer (ubiquity), so what you see below is very, very similar to what it would be like when installing Ubuntu.

installationtype.png

Again, I am going to skip over the steps leading up the the disk partitioning, and start with this window. It is similar to the window we saw the first time, although this time it doesn't give you a graphic of the disk partitioning. The choices that it offers are:

  • Install Linux Mint alongside Windows 7: Pretty much the same as the last time
  • Erase disk and install Linux Mint: Still the best choice in my opinion
  • Something else: For experienced users who know what they are doing and what they want

Once again I am going to choose, 'Install Linux Mint alongside Windows 7' and then click Continue.

disklayout.png

The next screen shows me what Mint is going to do, and gives me the opportunity to fine-tune it. There are a number of subtle points about this window which are quite interesting.

First, obviously, it shows what the relative size of the (resized) Windows partition and the (new) Linux partition(s) will be, and there is a handle between those two which I can drag to change the sizes, pretty much the same as the previous example. Nice, clear and easy.

Second, if you look at the fine print inside each of those partitions, you can see that the installer has figured out that the Windows partition is an ntfs file system, and that 31.8GB of space is actually used in it. (Really? 32GB used for not much more than a simple Windows 7 installation? Bletch.) That's useful to know, because if I want to reduce the amount of space left for Windows, now I have a good idea of how much it really needs.

Third, you can see that the partition it is going to create for Linux will be formatted with the ext4 file system. That's a good general-purpose choice, especially if you are a novice Linux user.

Finally, on the line below the partition graph, it tells you that the installer is not showing you one other smaller partition - that would be the 6GB "Windows 7 Loader" partition. Fair enough, we don't have anything useful to do with that anyway. If you really want to see all of the gory details, you can click the link in that line of text to bring up the advanced partitioning tool.

continue.png

When I click Continue, the installer brings up this window to remind me that the changes I am about to make are irreversible.

If it were my choice I would add a bit of text which said "Are you sure that you wouldn't rather just wipe the Windows partition", but that's just my personal prejudice showing through...

confirmchanges.png

So, one more click on Continue and the installation starts. Whoops, no it doesn't, the installer puts up yet another confirmation window. Wow, they want to make sure you are really, really sure that you want to do this, aren't they?

There are two new bits of information in this window that are interesting. First, it explicitly tells you that it is going to change the partition table (duh, yeah, that is what we came here for...), and second it tells you that it is not only going to create a Linux root partition, it is also going to create a swap partition - Calamares didn't make a swap partition in it's simplest installation above. It doesn't tell you how large the swap area is going to be, but we will see that in a few minutes.

Click Continue one more time, and the installation will finally, honestly, really start. The dialog will also continue, to get the timezone, keyboard and user information. The whole process will take something like 10 minutes, and then it will be ready to reboot to the installed system.

As with the Calamares (Manjaro) installation, there will be a multi-boot menu which offers to start either Linux Mint 18 (by default) or Windows 7. Good, that is why we are doing all of this...

gparted.png

I boot Mint, login, and run gparted to see what the disk really looks like now. Ok, there is one obvious thing and one not-so-obvious thing in this display.

The obvious thing is what we saw in the final screen of the installer, that there is now a Linux swap partition - but now we can see how large it is, 4GB. Good.The not-so-obvious thing is that the Mint installer didn't just create the two new partitions for root and swap. If you look carefully at the partition list below the graph of the disk layout, you can see that it created an Extended partition (/dev/sda3) and then put the root and swap partitions inside of that. While this is technically not really necessary yet because four partitions are allowed on a simple MBR disk, it is a good idea because if it isn't done this way, you couldn't add any more partitions later without a lot of trouble.

If you're not interested in the nuts-and-bolts of disk partitioning, this would be a good time to bail out. If you are interested, this would be a good time to get a fresh cup of coffee.

I'm going to assume that anyone reading this post at least understands the basic concepts of disk partitioning. Just to make sure that the terminology I am going to use is clear, I will summarize it by saying that partitioning is the process of dividing one disk (called a physical drive) into multiple pieces which can be viewed and processed separately (called logical drives). Windows users might have seen this concept when they bought a computer with a very large disk drive that shows up in Windows as separate C: and D: "Hard Disk Drives". (Pop quiz: who knows what happened to A: and B:?)

Linux has the ability to use multiple disk partitions for various purposes within one installation. Note that I said "the ability", not "the requirement". As we saw with the first installation above, the absolute minimum number of partitions required for a Linux installation is one. That has not always been true, but it is certainly true of every Linux distribution I am familiar with today. Now, before all the experienced (and semi-experienced) Linux users panic and start writing nasty comments, let me say that one partition is not a typical installation, and it is almost certainly not an optimal installation, but it is possible. I will explain more about this below.

Keep in mind that when you are a Windows user who has absolutely no experience or knowledge of Linux, and you're trying to make your first Linux installation, getting through the door with a minimum installation that actually works is a lot better than just standing outside confused and intimidated by information about root, boot, home and so on.

As I said at the beginning, I am only talking about the original MBR partition table (also sometimes known as DOS partitioning), I am not going to talk about the newer GPT partitioning. I might write about GPT partitioning and EFI boot later. Maybe.

One of the all-time worst ideas that was ever foisted on PC users was that four partitions on a disk was enough. That is the limit for MBR disks. Unfortunately, by the time Microsoft realized how stupid that arbitrary and very small limit was, it was too late.

Rather than really fixing it, they came up with yet another kludge to glue on top of it - the concept of "Primary" and "Extended" partitions. An "Extended" partition can then have any number of "Logical" partitions within it. Well, at least they were starting to learn a little bit - I would have expected them to impose some arbitrary limit (like four, or maybe a very adventurous sixteen) on the number of Logical partitions, but at least they managed to avoid that.

The new limits were then a maximum of four "Primary" partitions or three "Primary" and one "Extended" partition, and no limit on the number of "Logical" partitions within that one "Extended" partition. We have managed to live with these limits for quite a few years, and they are what you are likely to have on any PC which was purchased with Windows until sometime after Windows 7 was introduced, when they started switching to GPT partitioning.

Hmm. Well, maybe that's not entirely right, I heard some rumblings about GPT partitioning with Windows Vista, but since you can't even get Microsoft to admit any more that they every made anything called "Vista", this is difficult to pin down. No matter, I suppose.

Now I need to relate all of this partitioning information to what Linux needs, wants and can make use of. First, what does Linux need?

As I said above, Linux systems today require a minimum of just one partition, to hold what we call the root filesystem - if you will excuse my cringe as I say this, root is roughly the equivalent of the Windows C: drive. A typical Linux installation will need somewhere between 4GB and 8GB of disk space, and you need at least a bit of space for user files, so I generally make my root partitions at least 12GB-16GB.

Next, what does Linux want? That's a bit more tricky, because it gets into questions which cross over between functionality and personal preference.

The other partition that most (nearly all) Linux installations have is a swap partition. This will only be used if the total amount of memory required for all running applications is greater than the amount of physical memory installed. That means it is possible to install a Linux system without a swap partition, if you are willing to accept the potential limitation on the total size of running programs you can have.

How large should the swap partition be? Don't ask. That depends. The first dedicated swap device I can remember installing was a DEC fixed-head disk drive, I think it was an RS03 or RS05, I'm not sure. Something like 512KB or 1MB. That's probably not enough today...

If you run some very large, memory-hungry programs like graphic image editors or publication/presentation programs, it might need to be very large - but you will know that because you will get "out of memory" errors. If you never run anything but a web browser and an email program, you might not need a swap partition at all.

The rule of thumb that I use is to create a swap partition which is at least equal to the RAM memory, and preferably double that. But honestly, that has little more basis in fact than reading tea leaves, or dissecting a frog and reading the entrails. If you don't have a swap space, or you don't have enough swap space, you'll find out because you will get "out of memory" errors. If you have too much, who cares? As long as you are not short on disk space, it doesn't matter.

One other partition that falls between need and want is the boot partition. This is where Linux has traditionally kept whatever it needs to boot, including various kinds of binary and configuration files. It has been kept in a dedicated partition for a couple of reasons over the years, but the most common has probably been that the Linux kernel has progressed with new and different filesystem formats much faster than the various Linux bootloaders have.

The current example of this is UEFI firmware systems, which keep their boot files in a FAT partition. No Linux system is going to use FAT for the root partition, so you have to have a separate boot partition for this.

If you have an ext4 root partition, and use Legacy boot (not UEFI), then you don't need a separate boot partition. You can have one if you want, though.

There are several other partition uses that fall in the "can make use of" category. One common example is the home partition. This is just what the name implies, a separate partition which contains all of the ordinary users' home directories and files. This can be good for several reasons - it keeps you from having to make the root partition arbitrarily large, it gives you the possibility of expanding more easily, and it makes it easy to update/upgrade the Linux installation itself without having to backup and restore all of the users data. But again, this is not required and Linux can be installed and used just fine with the home directories in the root partition.

I think you're probably getting the idea by now. There are more examples, such as /usr/local or /data, but the discussion turns out to be pretty much the same. Use them if you want, they can be good for logically separating things and preserving them across other changes.

Whew, that was a lot of text even by my standards. Let's break it up with one more example installation, before I try to summarize it all. This time I'm going to look at the installer for openSuSE, because it does a couple of things that the first two examples didn't do.

yast2-000.png

This is the openSuSE Suggested Partitioning window. That long list of partitions looks pretty scary, but don't worry it's only there because openSuSE uses a btrfs file system by default. I don't want to get into a discussion of btrfs right now, so I am going to ignore/avoid it.

Fortunately openSuSE gives you the possibility to change the parameters it uses to make the Suggested Partitioning and get an updated automatic proposal.

yast2-001.png

Click on Edit Proposal Settings to get the Proposal Settings window. All I have to do here is change the File System for Root Partition to ext4, and then click OK.

You can also see in this window that openSuSE gives you the choice of having a separate home partition, and of the filesystem type to use if you have one.

Click OK to return to the Suggested Partitioning window, which will then show a new proposal based on using ext4 for the root filesystem. That looks a lot more reasonable, especially compared to that long list of partitions shown in the first proposal. This list is short enough you can see and understand exactly what the openSuSE installer is going to do.

yast2-002.png

The line at the top in red says that it will start by shrinking the existing Windows partition to 67GB. That sounds reasonable, we saw earlier than Windows is currently using about 32GB of space, so it will have about 50% free space.

It will then create an Extended Partition in the 75GB of space that it frees up by shrinking the Windows partition. This time it really needs the Extended Partition, because it is going to create a total of more than four partitions.

Finally, it will create Logical Partitions for swap, root and home within that Extended partition.

yast2-003.png

Rather than just completing the installation and showing another gparted view of the layout, here I have selected the Expert Partitioner. You would normally not have to go to this window for a simple installation, but it gives a different view of what the disk is going to look like.

This shows the partition table, and which partitions will be mounted at what points. If you wanted to use any additional partitions, this would be the place where you would come to create and position them.

That completes the three "simple" Linux installation partitioning cases that I want to show here. But before I finish, there is one more thing I want to do.

I have been asked several times about the configuration of my Samsung N150 Plus. I know it sounds like an extreme case because it is multi-booting eight different Linux distributions, but it is really just a continuation of the last two examples, using an Extended partition to hold multiple Linux installations.

gpartedn150.png

This is the gparted view of the disk in the N150 Plus. The first Primary Partition is openSuSE - it is actually Tumbleweed, not Leap, that label is wrong. That partition is large enough to hold all the pictures I unload from my cameras when I am traveling. When I am at home it looks like a lot of wasted space.

Next, I almost always put the swap in a Primary Partition, but that is more out of habit than necessity.

Then there is another Primary Partition where I currently have Fedora installed. This is only because I use the N150 for testing lots of different distributions; if I were setting it up just for everyday use (or just for traveling use) I would probably use the third Primary Partition for home and make the root partition much smaller.

Finally, there is an Extended Partition for all the other Linux distributions I am trying out on this little netbook. The actual number installed varies depending on what I am doing. There are currently six different distributions installed there, and there is enough free space at the end to add one or two more if I want.

The important thing here is that the Linux grub bootloader will boot either a Primary or a Logical Partition without requiring any unusual manipulation of boot files or partitions.

Ok, that's enough - probably more than enough. I hope that what all of this showed was that installing Linux doesn't require complicated disk partitioning, it can actually be quite simple.

Read more of Jamie's Mostly Linux Stuff