Using cfdisk Command In Linux- Examples

cfdisk command in Linux is basically a tool allowing users to manipulate and display information about the disk partition table. Means, the users can easily create, delete, and modify partitions on disk through a text based GUI.

Some of the typical values for device arguments can be:

  • /dev/hda [default]
  • /dev/hdb
  • /dev/sda
  • /dev/sdb
  • /dev/sdc
  • /dev/sdd

Syntax of cfdisk command in Linux

cfdisk /dev/sda

Options available to use with cfdisk

  • -h | –help: Displays help information and exits
  • -L | –color[=when]: Used for Colorizing the output. The argument when here can be auto, never or always. Means, if the when argument is omitted, it defaults as auto. Also, the colors can be disabled. To see the default current built-in, check -help output.
  • -V | -version: Displays version related information and exits.
  • -z | -zero: Used for starting with an in=memory zeroed partition table. Means, if you use this option, it will start cfdisk program without reading the existing table, and helps to create a new partition table from scratch.

In addition to these, we can also use more other commands with cfdisk, which are as follows:

  • b: Used to toggle flag of the current partition, and allows the users to select which partition is primary in the bootable drive. To use it, just press b.
  • d: Used for deleting the current marked partition to free up space for new partition.
  • h: Displays the help screen and shows various commands to be used.
  • n: Creates a new partition of the marked free space.
  • q: Quits the application without writing partitions to table.
  • s: Used for fixing the partitions order.
  • t: Used for changing partition type by allowing you to select from the list.
  • u: Dumps the disk layout in a specified script file name.
  • W: It allows users to write the data to selected disk. When used, it will ask users to write or not by simply getting inputs as yes or no.
  • x: Used for hiding or displaying extra information of the partition.
  • Up-Arrow: Moves the cursor to previous partition.
  • Down-Arrow: Moves the cursor to next partition.
  • Left-Arrow: Used for entering into previous menu item.
  • Right-Arrow: Used for entering into next menu item.

Examples to use cfdisk in Linux

cfdisk /dev/sda

cfdisk command in Linux

Running the command as mentioned, will bring summarized information for the desk device at top of the window. As you can see, the partition table is displayed in the middle, where as the usable commands are displayed in brackets at the bottom of window. So, you can use the up and down arrow keys to select a partition in the shown list. And to select a command, you can use right or left arrow keys.