Partitioning a Hard Drive with the fdisk Command

Use the fdisk command to prepare a new hard drive with one or more partitions. fdisk is not the most intuitive Linux command but it can be used to quickly prepare a hard drive for use.

Don't overwrite the partition you're running on

If you need to repartition a hard drive that's already in use, be sure to unmount it first. If it is ever necessary to repartition the hard drive you have / mounted on, you should boot into single user mode first.

SEE ALSO

For more information on run levels, see page 355.

  1. Log in as the root operator. Use the fdisk command to prepare and partition a hard drive by specifying the drive's device name on the command line:

    # fdisk /dev/sda
    Command (m for help): m
    
  2. fdisk ...

Get Practical Linux now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.