Partitioning for Linux – part 2: the how

Posted by: Rea Maor In: Linux and Unix - Wednesday, June 6th, 2007

If you are installing Linux for the first time, you have two options in regards to handling partitions:

(1) Pick out a nice, friendly distro like Red Hat, Fedora, Mandriva, Xandross, or other enterprise-level Linux that does the partitioning for you in a nice GUI. For instance, here’s the Fedora install program, Anaconda, giving you a nice, friendly partition round-up before making the changes:

partitioning a disk in Anaconda

(2) Get a copy of GParted, which stands for “GNU Partition Editor”, a special live CD tool built especially to make partitioning your drive easy and painless. I really, really recommend this, a lot.

(3) Be a computer scientist and do it yourself by hand. Doing it by hand will involve ugly stuff like using a command-line tool like the fdisk or cfdisk program. Among the many things you will need to know before you set about this task:

  • What PC architecture you use. There are different rules for i386, i686, Sparc, alpha, Opteron, and so on.
  • What Linux kernel you’re using. These days, that would usually be 2.6+, which will be less of a concern.
  • What you’ll be using the computer to do. For basic home use, you won’t much care. Power users: If you do memory-intensive stuff like play 3D games on Cedega or render glorious 3D movies in Blender, you’ll want some extra swap space. Sys-admins with multiple users may want to give everybody their own partition for their /home folder storage. Mail and print servers will want a separate partition for the relevant storage so that if something goes wrong, it doesn’t hose the whole system. Performance Nazis who will loose sleep over tiny 0.01 Megahertz performance hits will want to keep folders with short-lived files, such as /temp and /var, on a separate partition from folders with long-lived files such as /bin and /usr.
  • How much RAM you have, how big your disk is, and a good way to calculate cylinders to gigabytes.

Here is one, specific example: You have a clean, empty hard drive 10Gigs in size, and all you want it to do is run Linux. You will have a happy life if you just do this:


10MB for boot, 500MB for swap, and the rest for the Linux system proper. A close enough guess that should keep basic users happy.

“How much swap do I need?” Really, these days, none. Swap is just “spare RAM”. The Random Access Memory (those long chips that plug directly into your motherboard) these days runs to a Gigabyte and more. Back in 1998, it might have been 256MB. 256MB can be eaten up with (oh, say) Firefox running three tabs, one of which is a Flash game, while reading a PDF. So back then, the rule of thumb was “have twice as much swap memory as you have RAM”. Just in case, since running out of RAM will freeze your computer. These days, swap memory is almost unnecessary for average PC use, but what the heck, let’s be on the safe side and give it 500MB, since hard drive space is so cheap.

Logging in as root and starting “fdisk /dev/hda” (‘hda’ being ‘hard drive a’, the only hard drive) on one of my present systems, and hitting ‘p’ to print the partition table gives me this:

Command (m for help): p

Disk /dev/hda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1   *           1           9       72261   83  Linux
/dev/hda2              10         140     1052257+  82  Linux swap
/dev/hda3             141        1550    11325825   83  Linux
/dev/hda4            1551        9729    65697817+   5  Extended

The ‘extended’ partition is where I’m planning on plopping another system, if I get to it some day. The rest really does take up only 10.25Gigs, which is roomy enough for my usage on this machine.

Seriously, you don’t want to risk needed data with this stuff unless you know what you’re doing. Mandatory reading is the fdisk man page, and also check with our fine friends at the Linux Documentation Project who host the Partition HOWTO – practically a book on partitioning. In addition, most Linux installers will give you some form of instructions while you’re installing, and many of them will have recommended defaults.

For a bare disk, you might want to play with it for a while first. Fdisk will let you preview the scheme before committing to it, and you can hit ‘q’ to quit without committing to any changes. Always practice on a disk with no important data on it, so you don’t lose anything. Finally, you are really well off to join a forum or chat and ask a salty Linux veteran to advise you on a case-by-case basis, since the needs here will change from one user to another. Partitioning questions are one area where Linux users understand that they should patiently tutor new users.

Related Posts:

One Response to “Partitioning for Linux – part 2: the how”

  1. Make Money Online » Make Money Online June 6, 2007 12:20 pm Says:

    […] Partitioning for Linux – part 2: the how (2) Get a copy of GParted, which stands for ?GNU Partition Editor?, a special live CD tool built especially to make partitioning your drive easy and painless. I really, really recommend this, a lot. (3) Be a computer scientist and do it … […]

Leave a Reply