The ‘fdisk’ and ‘cfdisk’ commands
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.
fdisk -l
, this one lists all disks and partitions found, along with sectors. The output will be something likesda
,sdb
,hda
,hdb
.fdisk -l /dev/vda
is a way to access the details of that partition.- 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.
- Type
fdisk /dev/vda
- Use
n
for creating a new partition. - At this point, you will need to set the partition type (primary, extended, or logic), with
p
,e
orl
options respectively. - 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).
- Then, use the
p
for detailing partitions, witht
select the first one. - With
L
you can change the type of partition available, use the83 (Linux)
option for this exercise. - 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.