The ‘fdisk’ and ‘cfdisk’ commands

David E Lares S
2 min readFeb 9, 2024

--

The fdisk command is a utility command to modify the partition table of your disk, of course, you can find a lot of detailed information on the Internet. The goal here is to make a simple overview of how it's done.

fdisk has a lot of options. I will try to list the most popular ones.

  1. fdisk -l , this one lists all disks and partitions found, along with sectors. The output will be something like sda, sdb, hda, hdb.
  2. fdisk -l /dev/vda is a way to access the details of that partition.
  3. If no options-arguments are set, then a wizard will be displayed as an interactive mode, where you can add flags based on your purpose. The -m is for showing help, the -p for showing a partition table, -n for generating a new partition, -t for changing partition types, -d for deleting partitions, -w to write changes and -q for quitting the command.

Here’s an explained example for creating new Linux-based partitions.

  1. Type fdisk /dev/vda
  2. Use n for creating a new partition.
  3. At this point, you will need to set the partition type (primary, extended, or logic), with p, e or l options respectively.
  4. For the first sector, it is common to not make changes, and add a size to the last section (try to make it as a whole).
  5. Then, use the p for detailing partitions, with t select the first one.
  6. With L you can change the type of partition available, use the 83 (Linux) option for this exercise.
  7. After that, use the w to write changes into the partition table.

After completing the process, you can check changes with fdisk -l

There’s a GUI alternative to fdisk and it is the cfdisk. You can start customizing the table by doing: cfdisk /dev/vda and then follow the wizard

As usual, you can check the changes made with fdisk -l command.

--

--