Disks and file system

Command fdisk

Manage disk partitions

Linux · Bash examples · commands run on the selected server

When to use fdisk

Use fdisk's listing mode to inspect partition tables before planning storage work. Listing and interactive editing are different modes; do not enter write operations on a production disk simply to investigate its layout.

Syntax

fdisk [PARAMETERS] [DEVICE]

Square brackets mark optional arguments; an ellipsis means repetition. Replace example file names, user names and server addresses with your own values.

Common options and arguments

-l
Output partition tables without interactive modification.
-u sectors
Show positions in sectors.
-o FIELDS
Select columns in view mode util-linux fdisk.

Usage examples

View partition tables

sudo fdisk -l

Partition information is listed for visible disks without requesting edits.

Inspect a known disk

sudo fdisk -l /dev/vdb

The listing is restricted to one explicitly selected disk.

First determine the drive names

lsblk -o NAME,SIZE,TYPE,MOUNTPOINTS

A block-device overview helps associate disks, partitions and mountpoints before any change.

Notes and limitations

  • Interactive fdisk can modify the partition table and cause data loss after you write it.
  • The examples use -l to list information without writing changes. Verify your device instead of copying the example device name.

Common questions and troubleshooting

Do these examples create or format a partition?

No. They inspect existing layout. Partition creation and filesystem creation are separate destructive operations that require a backup and a verified target.

Why does the disk name differ on my server?

Virtualization, hardware and boot ordering affect device names. Identify the intended volume by its actual properties rather than copying an example path.

Further help

Options vary by version and distribution. Check the installed documentation with this command: man fdisk.