Most common fdisk invocations

Show partitions on all disk drives: fdisk -l (here's some sample fdisk -l output)
Partition first IDE drive: fdisk /dev/hda
Partition first SCSI drive (includes SATA, USB, and Firewire): fdisk /dev/sda

Partitions, cylinders, sectors, and tracks

Back in the bad old days, hard disks were limited in the number of sectors, tracks, and heads they could have. Hard disk manufacturers worked around this by choosing numbers that were not really correct, but were within the geometry limitations, and then dynamically mapped this "virtual geometry" to the true geometry within the hardware. While these limits are much larger now, this practice is still in wide use, and drives that are the same size from the same manufacturer can still have vastly different geometries. This means that cylinders and not necessarily consistent in size, and these size differences need to be accounted for when partitioning.

Intel-based PC platforms use a common partition layout format. Partitions are usually created on cylinder boundaries (all heads and sectors on the same track are on the same cylinder). Partitions numbers 1 - 4 are called primary partitions. Partition numbers 5 and over are extended partitions, which can be further subdivided. If you want more than 4 partitions on a drive (you probably don't, but you might not know one way or the other when you partition the drive), you must have an extended partition.

Common fdisk commands

When in interactive mode, the following fdisk commands are used frequently:
  • p: Print partitions and drive summary (same as fdisk -l - see the sample fdisk -l output for examples).
  • n: New partiion - supply the partition type (primary or extended), number, beginning & end cylinders (or specify an absolute MB or GB size), and type.
  • d: Delete partition - supply the partition number.
  • t: set a partition Type - type l after this to see a list (all numbers are in hexadecimal). The most commonly used types are 82 (Linux swap), 83 (Linux filesystem), and FD (RAID autodetect).
  • a: set the Active partition - normally this will be /boot.
  • w: Write the partition table to disk (until you do this, no changes are permanent, and if you quit fdisk before writing, the disk will be unchanged)
  • q: Quit fdisk
  • ?: Not really a valid help command, but it will give you the list of valid commands.

Expert mode

Expert mode can be used to force the drive geometry to match another drive:
  • x: Enter expert mode
  • c: Change the number of cylinders
  • h: Change the number of heads
  • r: Return to normal mode