Fdisk for partitioning | FreeOS, free operating systems
Pick a Free OS

User login


Fdisk for partitioning

As you, by now, have realized that partitioning the hard drive is essential part of Linux usage. Partitioning data provides us with logical blocks for effective separation of data. Also, it's quite common to see multi-os machines these days, which require you to partition your hard drive. Fdisk is the tool you use for this purpose. Here we bring you a howto on fdisk for Linux, which mind you, is separate from the fdisk for Windows that most of us are familiar with. This is a matter of confusion for most rookies. For apart from sharing a name, there’s a world of difference between the two.

Currently, most distributions offer nicer GUI front-ends. These not only hide much of the complexity but also lack the power that fdisk brings. Although it seems difficult at first, fdisk becomes a lot easier as you continue working with it.

To begin

Fdisk is started by “fdisk device”. The device will be the hard drive that you want to partition. You have to be the root.

# fdisk /dev/hda

You will now find yourself at the fdisk command-prompt. A “m” will bring up the available commands.

Command (m for help):

The first command that you give is “p”, to list the partitions on your drive.

Disk /dev/hda: 255 heads, 63 sectors, 4963 cylinders

Units = cylinders of 16065 * 512 bytes

Device Boot Start End Blocks Id System

/dev/hda1 * 1 262 2104483+ 83 Linux

/dev/hda2 263 785 4200997+ 83 Linux

/dev/hda3 786 1308 4200997+ 83 Linux

/dev/hda4 1309 4963 29358787+ 5 Extended

/dev/hda5 1309 2583 10241406 8e Linux LVM

/dev/hda6 2584 3858 10241406 8e Linux LVM

/dev/hda7 3859 3924 530113+ 82 Linux swap

Lets now look at the naming convention used by Linux to represent the various partitions.

You will encounter three kinds of partitions--primary, extended and logical. Historically, the partition table, which stores the size and location of partitions, was limited to four partitions. These were the primary partitions. As hard drives grew in size, so did the need for more partitions. And this gave rise to the extended partition, which is a primary partition with the capability of being split into an infinite number of partitions (actually, 63 partitions for IDE disks and 15 for SCSI) using a different kind of partition table storage. The extended partition is the container for logical partitions. Logical partitions, thus, are just partitions within the extended partition.