The cfdisk command is a frequently preferred method for examining disk structure on servers, partitioning new disks, or checking the existing structure. It can be easily used via remote connection over SSH and presents disk partitions with a graphic-like display through a text-based interface. In this article, we will discuss step by step how to use the cfdisk command by connecting to the server via SSH.
1. Connecting to the Server via SSH
You need to connect to the server with root or an authorized user:
ssh root@server_ip_address
If not root, connect with a user who has sudo privileges:
ssh user@server_ip_address
2. Make Sure the cfdisk Command is Installed
On some systems, cfdisk does not come by default. It can be installed with the following commands:
Debian/Ubuntu:
sudo apt install util-linux
RHEL/CentOS/AlmaLinux:
sudo yum install util-linux
3. Listing Disks
To list the disks on your system:
lsblk
This command gives the disk names (example: /dev/sda, /dev/nvme0n1). Use the cfdisk command according to which one you will examine.
4. Running the cfdisk Command
For an example disk:
sudo cfdisk /dev/sda
With this command, the disk partitioning interface opens in the terminal. Here:
-
You can see the existing partitions
-
You can create a new partition (New)
-
You can delete existing ones (Delete)
-
You can save changes (Write)
Warning: If you exit without saving with the Write command (Quit), no changes will be made.
5. Exit
After seeing the necessary information or completing the process, you can exit with the Quit option from the menu.
cfdisk is a useful, interactive terminal tool for examining disk structure or partitioning new disk areas. It is easily accessible via SSH and offers an intuitive menu instead of complex commands. It is important to take a backup before starting any operation on the disk structure.