Linux "cfdisk" Command Line Options and Examples
display or manipulate a disk partition table

cfdisk is a curses-based program for partitioning any block device. The default device is /dev/sda. Note that cfdisk provides basic partitioning functionality with a user-friendly interface.


Usage:

cfdisk [options] [device]






Command Line Options:

-h
Display help text and exit.
cfdisk -h ...
-L
Colorize the output. The optional argument when can be auto, never or always. If the when argument is omitted, it defaultsto auto. The colors can be disabled, for the current built-in default see --help output. See also the COLORS section.
cfdisk -L ...
-V
Display version information and exit.
cfdisk -V ...
-z
Start with an in-memory zeroed partition table. This option does not zero the partition table on the disk; rather, it simplystarts the program without reading the existing partition table. This option allows you to create a new partition table fromscratch or from an sfdisk-compatible script.COMMANDSThe commands for cfdisk can be entered by pressing the corresponding key (pressing Enter after the command is not necessary). Hereis a list of the available commands:b Toggle the bootable flag of the current partition. This allows you to select which primary partition is bootable on thedrive. This command may not be available for all partition label types.d Delete the current partition. This will convert the current partition into free space and merge it with any free space imme‐diately surrounding the current partition. A partition already marked as free space or marked as unusable cannot be deleted.h Show the help screen.n Create a new partition from free space. cfdisk then prompts you for the size of the partition you want to create. Thedefault size is equal to the entire available free space at the current position.The size may be followed by a multiplicative suffix: KiB (=1024), MiB (=1024*1024), and so on for GiB, TiB, PiB, EiB, ZiB andYiB (the "iB" is optional, e.g. "K" has the same meaning as "KiB").q Quit the program. This will exit the program without writing any data to the disk.s Sort the partitions in ascending start-sector order. When deleting and adding partitions, it is likely that the numbering ofthe partitions will no longer match their order on the disk. This command restores that match.t Change the partition type. By default, new partitions are created as Linux partitions.u Dump the current in-memory partition table to an sfdisk-compatible script file.The script files are compatible between cfdisk, fdisk, sfdisk and other libfdisk applications. For more details seesfdisk(8).It is also possible to load an sfdisk-script into cfdisk if there is no partition table on the device or when you start cfdiskwith the --zero command-line option.W Write the partition table to disk (you must enter an uppercase W). Since this might destroy data on the disk, you must eitherconfirm or deny the write by entering `yes' or `no'. If you enter `yes', cfdisk will write the partition table to disk andthen tell the kernel to re-read the partition table from the disk.The re-reading of the partition table does not always work. In such a case you need to inform the kernel about any new parti‐tions by using partprobe(8) or partx(8), or by rebooting the system.x Toggle extra information about a partition.Up Arrow, Down ArrowMove the cursor to the previous or next partition. If there are more partitions than can be displayed on a screen, you candisplay the next (previous) set of partitions by moving down (up) at the last (first) partition displayed on the screen.Left Arrow, Right ArrowSelect the preceding or the next menu item. Hitting Enter will execute the currently selected item.All commands can be entered with either uppercase or lowercase letters (except for Write). When in a submenu or at a prompt, you canhit the Esc key to return to the main menu.COLORSImplicit coloring can be disabled by creating the empty file /etc/terminal-colors.d/cfdisk.disable.See terminal-colors.d(5) for more details about colorization configuration.cfdisk does not support color customization with a color-scheme file.ENVIRONMENTCFDISK_DEBUG=allenables cfdisk debug output.LIBFDISK_DEBUG=allenables libfdisk debug output.LIBBLKID_DEBUG=allenables libblkid debug output.LIBSMARTCOLS_DEBUG=allenables libsmartcols debug output.LIBSMARTCOLS_DEBUG_PADDING=onuse visible padding characters. Requires enabled LIBSMARTCOLS_DEBUG.
cfdisk -z ...