• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

fdisk Command Examples in Linux

by admin

The fdisk utility is a menu-driven program that is used to create, modify, or delete partitions on a storage drive. Using fdisk, you can create a new partition table or modify existing entries on the partition table. The fdisk utility understands the DOS and Linux type partition tables. The fdisk utility also enables you to specify the size of partitions.

Syntax

The syntax of the fdisk utility is:

# fdisk [options] {device name}

fdisk Command Options

The fdisk utility supports a number of command-line options.

Option Used To
-b {sector size} Specify the number of drive sectors.
-H {heads} Specify the number of drive heads.
-S {sectors} Specify the number of sectors per track.
-s {partition} Print the partition size in blocks.
-l List partition tables for devices.

fdisk menu options

Aside from supplying command-line options, you can also choose various options when you are working in the fdisk menu.

Option Used To
n Create a new partition.
d Remove a partition.
p List existing partitions.
w Write changes to drive and exit utility.
q Cancel changes made and exit utility.

Using fdisk to list a storage device’s partitions.

fdisk command options

fdisk Command Examples

1. To set the sector size of a disk:

# fdisk -b 1024 /dev/sdd
(sector size = 512, 1024, 2048 or 4096) 

2. To specify the number of cylinders of the disk:

# fdisk -C 1024 /dev/sdb 

3. To Specify the number of heads of the disk:

# fdisk -H 1024 /dev/sdb 

4. To Specify the number of sectors per track of the disk:

# fdisk -S sects /dev/sdb 

5. To list the partition tables for the specified devices and then exit:

# fdisk -l
# fdisk -l /dev/sdb 

6. To get the size of a particular disk:

# fdisk -s /dev/sdb 

7. To switch off DOS-compatible mode:

# fdisk -c  

8. To get the help for fdisk:

# fdisk -h 

9. To get the version of the fdisk:

# fdisk -v

Filed Under: Linux

Some more articles you might also be interested in …

  1. “git verify-tag” Command Examples
  2. CentOS / RHEL 5, 6 : how to disable NetworkManager
  3. LVM error “WARNING: Inconsistent metadata found” – How to resolve in CentOS / RHEL
  4. hostess Command Examples
  5. How To Send Mails To an External User With Mailx on Linux
  6. mate-screenshot Command Examples in Linux
  7. bmon Command Examples in Linux
  8. cheat: Create and view interactive cheat sheets on the command-line
  9. Backtick (`) symbol in Linux Shell Scripting
  10. csvgrep: Filter CSV rows with string and pattern matching

You May Also Like

Primary Sidebar

Recent Posts

  • Vanilla OS 2 Released: A New Era for Linux Enthusiasts
  • mk Command Examples
  • mixxx Command Examples
  • mix Command Examples

© 2025 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright