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

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • 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. Understanding the /etc/inittab File in Linux
  2. Defining System Jobs Using Cron under Linux
  3. CentOS / RHEL 6,7 : How to use yum history to roll back a yum update
  4. How to Disable/Enable services in Zimbra Mail Server
  5. How to mount USB flash drive in Linux
  6. Linux OS Service ‘smartd’
  7. How to Configure rsyslog to Filter/discard Specific IP Address in CentOS/RHEL 6,7
  8. CentOS / RHEL : How to Disable and Blacklist Linux Kernel Module to prevent it from loading automatically
  9. Linux OS Service ‘rpcgssd’
  10. How to Change the filesystem Labels in CentOS/RHEL

You May Also Like

Primary Sidebar

Recent Posts

  • JavaFX ComboBox: Set a value to the combo box
  • Nginx load balancing
  • nginx 504 gateway time-out
  • Images preview with ngx_http_image_filter_module

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright