How to use the command 'cfdisk' (with examples)

How to use the command 'cfdisk' (with examples)

The ‘cfdisk’ command is a program that allows users to manage partition tables and partitions on a hard disk using a curses UI. It provides a simple and intuitive interface for creating, deleting, and resizing partitions.

Use case 1: Start the partition manipulator with a specific device

Code:

cfdisk /dev/sdX

Motivation: This use case is useful when you want to manage the partitions on a specific device. By specifying the device name, you can launch the cfdisk interface and work with the partitions on that device.

Explanation:

  • /dev/sdX: This argument specifies the device for which you want to manage the partitions. Replace ‘X’ with the appropriate device identifier, such as ‘a’ or ‘b’.

Example output: When you run cfdisk /dev/sda, the cfdisk interface will open, displaying the partitions on the ‘sda’ device. You can navigate through the interface using the arrow keys and create, delete, or resize partitions according to your needs.

Use case 2: Create a new partition table for a specific device and manage it

Code:

cfdisk --zero /dev/sdX

Motivation: This use case is helpful when you want to start with a clean slate and create a new partition table for a device. It allows you to remove all existing partitions and start fresh.

Explanation:

  • --zero: This argument instructs cfdisk to zero out the partition table on the specified device before creating a new one.
  • /dev/sdX: This argument specifies the device for which you want to create a new partition table. Replace ‘X’ with the appropriate device identifier, such as ‘a’ or ‘b’.

Example output: Running cfdisk --zero /dev/sda will erase all existing partitions on the ‘sda’ device and create a new empty partition table. You can then utilize the cfdisk interface to create new partitions according to your requirements.

Conclusion:

The ‘cfdisk’ command is a versatile tool for managing partition tables and partitions on a hard disk. By utilizing its capabilities, users can easily create, delete, and resize partitions, providing flexibility and control over disk usage. Whether you need to manage existing partitions or create a new partition table, cfdisk offers a straightforward interface to accomplish these tasks effectively.

Related Posts

How to use the command ngs (with examples)

How to use the command ngs (with examples)

The command ngs is a scripting language created specifically for Ops.

Read More
How to use the command 'oathtool' (with examples)

How to use the command 'oathtool' (with examples)

This article will guide you through different use cases of the ‘oathtool’ command, which is a part of the OATH Toolkit.

Read More
How to use the command 'mc' (with examples)

How to use the command 'mc' (with examples)

Midnight Commander is a terminal-based file manager that allows users to navigate the directory structure using arrow keys, the mouse, or by typing commands into the terminal.

Read More