Introduction

One of the first things to hit a new Linux user is partitioning of the hard drive. If you haven’t yet, you need to check out my Intro to the Linux file system for an overview of each of the important directories.

What is a partition

A partition is a division in the hard drive (HDD). One HDD can be separated into multiple partitions. This devision is actually done by putting an entry into the proper partition table on the HDD pointing to the block that begins the partition. There are two types of partitions, logical and extended. There can be up to 4 partitions in the primary partition table. HOWEVER, the extended partition points to an extended partition table and can have even more partitions within it.

Filesystem Type

This is a whole post within itself. Usually the default will be fine. EXT3 is pretty popular. Unless your doing something really specific, EXT3 should be fine. Another filesystem type is swap. There should always be a swap partition. Generally it should be twice the size of your ram. It is a special filesystem used by the operating system.

Mount Points

First, let’s talk about mount points. A mount point is simply a directory on one partition that is used to mount the root (top level of that partition) of another partition. What this means is that once you mount the numerous partitions, you can navigate to them just as they were part of the root partition. Say you had a partition (we’ll call this one “p1″) with two directories inside named mounted and not_mounted. Their paths would be of course /mounted and /not_mounted. Inside each of those directories you create a file called seeme. The structure would like like this:

root
|__ /mounted
|   |__/mounted/seeme
|__ not_mounted
    |__/not_mounted/seeme

Now say you had another partition (this one is “p2″) with 5 files in the root of it. Say the files were simply called one, two, three, four, and five. The structure for this partition would be like this:

root
|__/one
|__/two
|__/three
|__/four
|__/five

Do you know what would happed if you mounted “p2″ to “p1″ using /mounted as a mount point? Let’s see what happens to the file structure then. You get:

root
|__/mounted
|   |__/mounted/one
|   |__/mounted/two
|   |__/mounted/three
|   |__/mounted/four
|   |__/mounted/five
|__/not_mounted
    |__/not_mounted/seeme

Now what happened to /mounted/seeme? It’s still there, but will be invisible while that directory is being used as a mount point. Usually, if a directory is being used as a mount point, it stays empty itself.

Benefits of using separate partitions

Put simply, keeping directories that tend to fill up separate from directories needed by the system to function safeguards the system against a crash. If /home and /tmp were both on the same partition, they would share the same HDD resources. When /home fills up, the operating system would not be able to allocate storage to other important system functions that need /tmp.

Another plus is that you can format one partition and keep the data on another. You can reinstall your operating system without losing data on the /home partition. Also, in the case of a partial HDD failure, your chances of saving data is increased.

Deciding which directories to partition separate

There are so many correct ways of partitioning your HDD. Of course, this is based on the needs and available resources for your system. You may choose to only have one partition (plus another swap partition). Here are some considerations:

  • swap should be twice the size of your ram
  • most of the storage is going to be used by the /home directory for a desktop
  • keeping /home on a separate partition allows you to reinstall another operating system and keep the data on /home

Example

I will explain my setup as an example:
Fedora 7 on 100GB HDD /sda

partition logical or extended mount point size notes
sda1 logical /home 37GB
sda2 logical /boot 100MB I use this for multiple Linux installations
sda3 logical swap 2GB 1 GB ram x 2
sda4 extended N/A remaining ~61GB This contains the other partitions
sda5 extended / or /mnt/FC6 15G This is my Fedora Core 6 installation
sda6 extended / or /mnt/F7 15GB This is my Fedora 7 installation

Conclusion

This is by no means a complete tutorial or Howto, but I hope it gives you some insight into how to partition your HDD as a new linux user. Let me know what you think.

Leave a Reply