SEARCH

How-To Geek

How to Choose a Partition Scheme for Your Linux PC

hdd part (dmyhung) cropped

Afraid of the dreaded “p” word?  You’re not alone.  Partitions can get complicated, so here’s an explanation of what they are, how they’re used, and a simple template to use for your own Linux installation.

Image by dmyhung

What Are Partitions?

Partitions are divisions in the formatting of the hard disk.  It’s a logical – as opposed to a physical – division, so you can edit and manipulate them for various purposes.  Think breaking a disk into two configuration parts.  Partitions are really handy because they act as a sandbox.  If you have a 1 TB hard drive partitioned into a 250 GB partition and a 750 GB partition, what you have on the latter will not affect the other, and vice versa.  You can share one of those partitions on the network and never worry about people accessing information on the other.  One could have Windows installed, riddled with viruses and trojans.  The other could be running a very obsolete, security-hole addled Linux installation.  Never shall the two interfere, unless either you make them or the hard drive itself physically dies.

The other useful thing is that you can have multiple partitions, each formatted with a different “file system.”  A file system is a formatting of the disk into a table that the operating system can read, interpret, and write to.  Only have one hard drive?  That’s okay, because you can still install multiple operating systems on it without actually having another physical disk.

While there are tons of file system types, there are only three kinds of partitions: primary, extended, and logical.  Any given hard disk can only have a maximum of four primary partitions.  This limitation is due to something called the Master Boot Record which tells the computer which partitions it can boot from, and so primary partitions are usually reserved for operating systems.  But what if we want more than four?  That’s where the extended partition comes into play.  It serves as a hollow container for any number of smaller, logical partitions.  You can make as many as you like there, as well as make it home to your non-OS sections.

If extended partitions are so great, why not just use them?  That’s because you can’t directly boot from anywhere inside an extended partition.  There are ways to get around this, but the best thing to do is to plan properly beforehand with primary partitions.  In addition, the way partitions are numbered by the system depends on these types.  First, the machine will number based on all primary partitions, and then by logical ones.  This can cause changing drive letters if you switch between OSs or add or delete partitions later.

Mount Points in Linux

partition scheme (methoddan)

Image by MethodDan

On Windows, things are pretty clearly cut: it lives on your disk, usually on one partition, and that’s that.  If you have other drives, and they have a compatible file system, then it’ll read them as well.  If not, it’ll usually ignore them, or offer you the ability to reformat.  Linux – and anything resembling Unix, really – doesn’t quite work that way.

The way Linux works is that it puts everything onto a tree.  If you have another partition or disk, it gets “mounted” as a branch in a specific folder, usually /media or /mnt.  The directory that a partition gets mounted to is called a “mount point.”  This method works better with Linux’s tree structure, and you can mount partitions as folders nearly anywhere.  In Windows, this is not so easily done; new partitions generally show up as separate drives.  In addition, Linux can work with many more types of file systems natively than Windows.

Remember how there could only be four primary partitions?  If you want to boot 145 OSs like someone on the JustLinux forums did, you can set up a primary partition for /boot, which houses a boot-loader, like GRUB or LiLo, which handles initial functions and then continues booting into the extended partitions.

What Scheme Should I Use?

The standard partitions scheme for most home Linux installs is as follows:

  • A 12-20 GB partition for the OS, which gets mounted as / (called “root”)
  • A smaller partition used to augment your RAM, mounted and referred to as swap
  • A larger partition for personal use, mounted as /home

The exact size requirements change based on your needs, but in general you start with swap.  If you do a lot of multimedia editing, and/or have a smaller amount of RAM, you should use a larger amount of swap.  If you have plenty of memory, you can skimp on it, although some distributions of Linux have a problem going into standby or hibernating without much swap.  The rule of thumb is that you choose between 1.5 to 2 times the amount of RAM as the swap space, and you put this partition in a place that is quick to reach, like at the beginning or end of the disk.

Even if you install a ton software, a maximum of 20 GB for your root partition should be enough.  Most distributions of Linux use either ext3 or ext4 as their file system nowadays, which has a built-in “self-cleaning” mechanism so you don’t have to defrag.  In order for this to work best, though, there should be free space for between 25-35% of the partition.

Finally, whatever else you have should go to your /home partition.  This is where your personal stuff is stored. It is functionally the equivalent of the “Users” directory in Windows, housing your application settings, music, downloads, documents, etc, and those of any other users you have on your system.  It’s useful to have /home in a separate partition because when you upgrade or reinstall your OS, you don’t have to backup anything in this folder!  Isn’t that convenient?  To top it off, most of your program- and UI-related settings are saved as well!

Screenshot-Install

If you’re running a server with a lot of users and/or a lot of media, you could optimize performance by using two hard drives.  A small solid state drive would be perfect for the OS to live on, maybe 32 GB at most, and you could throw the swap partition on the beginning of a 1 or 2 TB “green” drive that’s mounted on /home.

If you’re into more tinkering, you can even set up different partitions for things like the temporary directory (/tmp), for your web server’s content (/var/www), for programs (/usr), or for log files (/var/log).

Specifying Mount Points During Installation

In our example, we’ll be using showing the partition setup during an Ubuntu Maverick Meerkat installation.  When you get to where it says “Allocate drive space,” choose “Specify partitions manually (advanced).”

installation manual

Don’t panic just because you see “advanced”; it’s really not that difficult and you’ll be getting some real rewards from the process.  Click forward and you’ll see the partition table.

new partition

Click on the free space row in the table and then click on “Add…”  If you don’t have free space, click on your Windows partition, hit “Change…” and shrink it to a more palatable size.  This will give you some free space to work with.

Create partition

Here, you can see that I’ve created a Primary partition of about 11.5-odd GB at the beginning of the disk and I’ve specified it to use root as the mount point.  You will have to use a Linux-compatible file system, so I used the default ext4, although you can use ext2, ext3, ReiserFS, or whatever else.  Do some research online and you’ll be able to choose the best, but if you’re in doubt, stick to the default.  You can adjust yours to more space if you have it, but again, you probably won’t ever need more than 20 GB unless you’re installing/compiling a lot of software.  Click “OK” and you’re set to create another partition.

swap

This time, as you can see, I’ve chosen a logical partition (the partitioning program automatically creates an extended partition for this).  Since this machine has a 512 MB of RAM, I’ve approximated 1.5 times that, and designated it as “swap area.”  Also note that I’ve stuck this at the end of the disk, which will help keep disk seeking times at a minimum.  Click “OK,” and let’s create another partition.

home

I’ve selected all of the rest of the space in the middle to be my /home partition.  The compatible file system I’ve chosen is again ext4.  Now here is the gray area: should it be primary or logical?  I went with primary because I know that I won’t be installing another OS on here, otherwise I would have gone with logical.  If you don’t plan on installing more than three OSs, you can just make it primary for simplicity’s sake.

When you’re all finished, you can resume installation.  Here’s my resulting partition table:

finished!

If you get cold feet, you can quit the installation at this point without fearing any data loss.  Nothing is actually done to your disk until you hit “Install Now,” so you can go back and edit things as you wish.


Now that you know what partitions are and how to optimally set up your Linux installation, feel free to continue your search online.  There’s a lot more to learn!  Have any advice or tricks to the process?  Maybe some useful experiences to share?  Be sure to leave a comment!

Yatri Trivedi is a monk-like geek. When he's not overdosing on meditation and geek news of all kinds, he's hacking and tweaking something, often while mumbling in 4 or 5 other languages.

  • Published 11/17/10

Comments (33)

  1. Wasp

    While Linux variants can certainly recognize and mount a wide variety of file systems, is it able to mount the same variety as /home? If your goal is to have a single primary partition on which to hold both your Windows personal files and Linux personal files, as in a unitary /user and /home partition – how can you do that if Linux can’t mount ntfs as /home and Windows can’t recognize ext3 or ext4?

  2. Grant Johnson

    It is a bit more advanced, but I like to use LVM, and set the sizes to the minimum I can get away with, leaving lots of space on the volume group. This means that I can put the space just where it needs to be, and if I was WAY off and need to add an extra drive (or a few) they can all be part of the same directories.

  3. Sausage

    I concur with Wasp

    Exactly what I want to know, i keep getting told to use NTFS as my shared data (which is a fail becuz Linux can’t mount home there) or I’ve been told to use an EXT3 file system and then use a Windows driver but I’ve been told that there are issues using that as well.

    I just want a well thought out and reasoned response to happily dual booting.

  4. fearlex

    Excellent tutorial !

  5. Tommie

    EXT2 /boot 100mb beginning of the disk,…

  6. Yatri Trivedi

    I’ll see what I can do about a “happy dual-booting” how-to!

  7. bonbonboi

    as i knew /boot should be formatted as ext2 ext3 but if u formatted it as ReiserFS, or whatever else, then u will get problems to boot up the machine especially if u used grub…

    any idea ?

  8. bonbonboi

    btw, what befits we get if we make more partitions to separate the /tmp /usr /var once we really still working on the same physical hard disk, means the hdd’s heads going to still working from here and there like crazy….

    any idea ?

  9. Lisa

    Thanks so much for this! While I haven’t managed to mess it up yet, partitioning always scares me silly. This helped! :)

  10. Mr. X

    thanks so much, this really help me to install linux on my pc.

  11. Hatryst

    Very nice. If i carry out the same procedure on a USB thumb drive, will there be any differences?

  12. Mike-RaWare

    @Hatryst: Yes there is a difference: you can’t have more than one partition on most thumb drives in Windows, I’m not sure about Linux.

  13. bassmadrigal

    One benefit with partitioning other directories, is if you want to wipe the install and start fresh, you can just unmount those directories beforehand and not have any data loss. For example. You have a webserver, so /var/www that holds all your webserver content and /var/lib/mysql for the database info. If you have them as separate partitions you can just not mount them while installing. Then when the install is finished, you can mount them and not lose any data. The same can be said for the /etc directory if you like to keep all your program and OS settings backed up.

  14. Bhala

    Adding /boot will help in what way ? Will it be easier to deal with dual booting incase the boot record is corrupted ?

  15. mark

    Just finished a fifth (and successful) attempt at a quad-boot system last weekend. If you’re installing multiple OSs, the order of installation is another important consideration. Windows should almost always be installed first, if you are including Windows. Also, some OSs want a primary partition where others will be okay with a logical partition.

  16. Bill Miller

    Nice article thanks…
    How I have been dual booting Windows and Linux for 10 years, it is simple and seems to work real well for me. Perhaps someone else has a better way, by all means take this modify it tear it up and improve it?

    Boot off of windows Cd

    Assign 1st 300-400 megs “NTFS to C”
    Assign next 500 megs to a gig as “ Type doesn’t matter D”
    Assign half the the drive to “NTFS E”
    View partitions you will see C D E and free space
    Delete D partition

    Reboot
    Boot up on windows CD view partitions
    It will show “C NTFS” and “D NTFS”

    Install windows now into D drive NTFS (do not let it format the space between C and D)
    Make sure that any and all drivers don’t install themselves in the C partition as it only has 400 megs and would fill up quickly.

    Boot up on Linux CD Select Install and use partitions manually
    I always select the 1 gig empty space as /Boot
    I select everything left on the drive
    but the last 5 gigs for / (Slash)
    I select the last 5 gigs of the drive for /Swap

    I always select ReiserFS when possible as it seems to have a safer quicker recovery than any other File System I have found, if machine is powered off and on.
    The reason I usually select 1 gig for /Boot is because the Kernel updates can take up to several hundred megs of disk space a year which puts someone in /boot and /boot/grub cleaning up the old files you don’t use anymore.
    In case anyone wants to know why I use the windows CD to create windows partitions. It is because I know windows likes windows partitions.

    Hope this helps someone.

  17. Jimmy

    I Installed my ubuntu on a extended partition
    same with the swap, but it seems hibernating is a fail (which is odd)

    also, a /home partition which works crossplatform would be usefull
    at the moment, fat32 is the only one to go, which sucks for big files

  18. Grant

    @Bhala
    The small /boot at the beginning of the drive helps with BIOS that cannot access the whole drive.

    If you have a drive bigger than you can address, the OS Kernel needs to be in the section that BIOS can see. With Windows, you have to use a “Drive Overlay” driver (disk comes with the drive) to use a drive bigger than BIOS can see, but Linux is fine with it once it boots. If your BIOS can see the whole hard drive, then the /boot thing really doesn’t matter.

  19. asdf-chan

    I didn’t see any information about a seperate boot-partition … basic knowledge about linux is missing!

  20. Demon Lord

    Great article about partitioning especially for people who are new to Linux.

    Just a little addition: Most recent BIOSes can access the whole hard drive I think. and If you have 2 or more hard drives on the same machine it’ better to put the Swap partition on a hard drive other than the one root is installed onto. This will greatly help the speed of swap-ing.

    I have a question. I’m running a quad boot machine. Win 7, Win XP, Ubuntu and Kubuntu. I share swap, /home and /tmp between linux but the problem is Kubuntu sometimes can’t mount the /tmp at startup which sometimes prevent Kubuntu from working. Any ideas?

  21. asdf-chan

    Check /etc/fstab under both linux systems and use google

  22. Demon Lord

    @asdf-chan:

    I don’t know what to look for in /etc/fstab and didn’t find a solution on google. I made Kubuntu use it’s own /tmp partition. It solved the problem so far.

  23. asdf-chan

    Well excuse me if i am rude but if you don’t know what fstab is used for, you should go back to windows only

  24. bonbonboi

    fstab = File System Table

  25. bonbonboi

    and nobody has answered me

  26. asdf-chan

    @bonbonboi
    Why would you need a journaling filesystem for your boot partition?

  27. YatriTrivedi

    Some help:

    Using something like GParted, you CAN partition thumbdrives and external HDDs. In my experience they’ve always worked. u3 tools were similar to this idea.

    @Demon Lord, You are correct! Most, if not all, modern BIOS- and UEFF-based motherboards can boot anywhere on the HDD. A separate /boot partition is only needed for older hardware. You should check to see if your /tmp directory is being left locked or left with data on it after a reboot. No idea why that would happen, but that may be a cause.

    @bonbonboi, if you have a /boot partition, it would be small and you wouldn’t really gain anything by using a Journaling FS like Reiser. I haven’t used LiLo in years, but maybe that works better for something like that? Sorry, wish I could help more!

  28. asdf-chan

    You don’t even need gparted. cfdisk and fdisk are just fine

  29. Demon Lord

    @asdf-chan, I didn’t say I don’t know what fstab is. I said I don’t know what to look for. It looked fine to me. I believe at some point you were a linux newbie too.

    @YatriTrivedi, Linux should empty the /tmp at startup but I’ll check it. Thanks.

  30. Mike

    I have successfully navigated the Windows partition world, but have yet to find a good explanation of the Linux model. I have looked at the GUI presented by Linux and Gparted and can’t make sense of either. Every time I ask a Linux geek I get a Disdainful RTFM comment. Well, I have read the man pages and let’s just say that it is as acerbic the geek.

    It would be nice to see an article with pictures of the GUI and explanations of the partitioning and what the images in the GUI mean. Maybe even a comparision to fdisk and the Windows system. So far I have been reduced to inference based on articles like this about Linux.

  31. Scott

    @Mike – The idea of partitioning is the same no matter what OS you are using. Partitioning is a function of the hardware and it will present these partitions to the OS as the fundamental abstraction of disk space. These partitions can then be formatted with a particular filesystem that the OS can understand and use. Once a filesystem is on them, they can be presented to the user by mounting them somewhere that can be easily accessed (C, D, etc on Windows, or /home, /var, /boot, etc on linux). That may be the (seemingly) big difference that is confusing you (i dunno, maybe not). Partitions with a filesystem on them can only be shown as a seperate lettered drive in Windows, whereas in linux, there is no concept of drive letters – all the filesystems (virtual filesystems as well) are mounted off of ‘/’, root.

    Partitioning is just slicing up a disk, no more, no less. There are many reasons you would want to break a disk into different partitions, but the two biggies that i can think of off the top of my head are 1) you want to use several different filesystems (NTFS, ext234, reiser, etc) and 2) recovery in case of a corrupted filesystem.

    I don’t really use partitions too much these days, as Logical Volume Management is really what you want to be doing anyway. But that is a layer of abstraction on top of partitions and filesystems, so i guess its best to know them.

  32. Dana

    @ bonbonboi
    The reasons you would seperate those directories into partitions is typically a reason for server administrators – seperating /tmp for example is done so that hard links (a type of shortcut for the windows folk) are not used in tmp which allows universal access to be made to core system files. (hard links cannot work from one partition to another) and you would place /log on a new partition in case someone uses an attack to fill up your log files and eats your partition size it doesnt affect the root login. Some also put /root into it’s own partition so they have access to the system if the drive is otherwise filled up or has a problem. (there will be usable memory on that partition if the core fills up)

    So while there is no real performance increase during normal use, after a problem happens partitions can be of value.

  33. youngbud

    @Wasp use symbollink links

Enter Your Email Here to Get Access for Free:

Go check your email!