fdisk Command: Tutorial & Examples

Manage partitions on hard drives and SSDs

The fdisk command in Linux is a command-line utility used to manage disk partitions. It allows users to create, delete, resize, and modify partitions on a disk. The fdisk command can be used to create partitions on both physical disks and virtual disk images.

Here are some examples of using the fdisk command:

To view the partitions on a specific disk (e.g. /dev/sda), you can use the command:

sudo fdisk -l /dev/sda

To create a new partition on a specific disk (e.g. /dev/sda), you can use the command:

sudo fdisk /dev/sda

This will open an interactive prompt where you can use commands like n to create a new partition, p to create a primary partition, w to write the changes to the disk. To delete a partition press d, then select partition number, and use w to write the changes to the disk.

It's important to note that fdisk should be used with caution, as any mistakes made while using it can potentially result in data loss. It's a good idea to make a backup of your data before making any changes with the fdisk command.

Except where otherwise noted, content on this site is licensed under a CC BY-SA 4.0 license CC BY SA