How to use the command delpart (with examples)
- Linux
- December 25, 2023
The delpart
command is a Linux kernel utility that allows users to instruct the kernel to forget about a partition on a specified device. This can be useful in situations where a partition needs to be removed or when there is a need to correct partition table information.
Use case 1: Tell the kernel to forget about the first partition of /dev/sda
Code:
sudo delpart /dev/sda 1
Motivation:
In some cases, there might be a need to delete a specific partition from a device. By using the delpart
command with the appropriate arguments, the kernel can be instructed to forget about the specified partition and remove it from the partition table.
Explanation:
sudo
: This command is used to execute thedelpart
command with administrative privileges.delpart
: The actual command that the kernel executes./dev/sda
: Specifies the device from which the partition needs to be deleted. In this example,/dev/sda
is the device.1
: Indicates the number of the partition to be deleted. In this example,1
refers to the first partition.
Example output:
The output will not be displayed unless an error occurs. If successful, the partition will be removed from the partition table of /dev/sda
.
Conclusion:
The delpart
command provides a straightforward way to delete partitions from a device. By specifying the appropriate device and partition number, users can accurately instruct the Linux kernel to forget about the partition, resulting in its removal from the partition table.