Roshan Book

My Tech Notebook

How to Choose a Partition Scheme for Your Linux PC


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.

Advertisements

20 responses to “How to Choose a Partition Scheme for Your Linux PC

  1. Martha Yaffe October 12, 2011 at 11:57 am

    I?m impressed, I have to say. Really hardly ever do I encounter a blog that?s both educative and entertaining, and let me inform you, you could have hit the nail on the head. Your thought is excellent; the problem is one thing that not sufficient people are speaking intelligently about. I am very glad that I stumbled throughout this in my seek for something relating to this.

  2. Replica Handbags Louis Vuitton December 2, 2011 at 11:19 am

    Highly beneficial appreciate it, There’s no doubt that your audience would definitely want a whole lot more well written articles like this maintain up the wonderful work.

  3. Louis Vuitton Luggage Sale December 5, 2011 at 2:07 am

    Truly insightful bless you, It looks like your trusty subscribers could perhaps want significantly more blog posts along these lines carry on the outstanding hard work.

  4. Replica Prada Bags December 5, 2011 at 4:47 am

    Another quality post. I posted a link for this blog at my web site. So, I am sure several persons forget the points you are discussing.

  5. Gucci Outlet Online December 5, 2011 at 8:57 am

    You should take part in a contest for one of the best blogs on the web. I will recommend this web site!

  6. LV Handbags Sale December 5, 2011 at 1:53 pm

    Very good read, thank you for posting.

  7. Knock Off Louis Vuitton Luggage December 6, 2011 at 1:38 am

    Surprisingly educative quite a few thanks, I believe your trusty subscribers could possibly want a superior deal more stories along these lines carry on the terrific work.

  8. Louis Vuitton Outlets December 6, 2011 at 2:50 am

    You actually make it seem so easy with your presentation but I locate this topic to be definitely something that I feel I would never understand. It seems too complex and pretty broad for me.

  9. giant wall stickers December 12, 2011 at 3:39 pm

    I loved as much as you will receive carried out right here. The sketch is attractive, your authored material stylish. nonetheless, you command get bought an impatience over that you wish be delivering the following. unwell unquestionably come more formerly again as exactly the same nearly a lot often inside case you shield this hike.

  10. invest liberty reserve December 12, 2011 at 5:00 pm

    An riveting communicating is designer note. I suppose that you should correspond more on this issue, it strength not be a inhibition theme but mostly grouping are not sufficiency to utter on specified topics. To the next. Cheers like your How to Choose a Partition Scheme for Your Linux PC Roshan Book.

  11. minecraft skins December 12, 2011 at 5:17 pm

    An riveting communication is worth observe. I imagine that you should indite statesman on this message, it strength not be a preconception theme but generally people are not sufficiency to utter on much topics. To the succeeding. Cheers like your How to Choose a Partition Scheme for Your Linux PC Roshan Book.

  12. Constipation remedies December 13, 2011 at 3:56 pm

    An intriguing language is designer annotate. I consider that you should make solon on this substance, it mightiness not be a prejudice theme but generally people are not sufficiency to verbalize on such topics. To the next. Cheers like your How to Choose a Partition Scheme for Your Linux PC Roshan Book.

  13. Scott Bergreen December 13, 2011 at 10:59 pm

    Educational and entertaining. I’ve additional your internet log to my “reading substance. ” Progress me updated!. . . .

  14. Fredda Venuto December 14, 2011 at 5:18 am

    I was examining some of your articles on this website and I conceive this site is real instructive! Keep putting up.

  15. ebay account suspended December 17, 2011 at 9:02 pm

    Did eBay suspend your account? I’m suspended for absolutely no reason! I misplaced all of my earnings, my business was online dependent. I needed to discover a solution. By the end I am again for real.

  16. cheap moncler jackets December 18, 2011 at 2:26 am

    I will be slightly sure they??ll be told a great deal of new stuff what follows than a single else!

  17. Eileen Garcia December 18, 2011 at 1:10 pm

    Negative news – Syria’s ‘mutilation mystery’ increases…

  18. Andrew Tingey December 23, 2011 at 3:13 pm

    ewtertrzrtz546zrzrtz547547rurtu

  19. small business web hosting comparison December 23, 2011 at 11:33 pm

    Excellent items from you, man. I’ve understand your stuff prior to and you are simply too wonderful. I actually like what you have obtained here, certainly like what you are saying and the way by which you say it. You are making it entertaining and you continue to care for to keep it sensible. I can’t wait to read far more from you. This is actually a terrific web site.

  20. dicas wp December 7, 2012 at 6:19 am

    Wow that was unusual. I just wrote an extremely long comment but after
    I clicked submit my comment didn’t appear. Grrrr… well I’m not writing all that over again.
    Anyways, just wanted to say superb blog!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: