delpart
Delete a partition from a disk
TLDR
Tell the kernel to forget about the first partition of /dev/sda
SYNOPSIS
delpart disk partition
PARAMETERS
disk
The disk to modify (e.g., /dev/sda).
partition
The partition number to delete (e.g., 1 for /dev/sda1).
DESCRIPTION
The delpart command is used to delete a partition from a disk in Linux. It directly manipulates the partition table, so extreme caution should be exercised when using this command. Incorrect usage can lead to data loss and make your system unbootable. It's crucial to understand the partition scheme (MBR or GPT) of the disk before using delpart. For GPT disks, use gdisk or parted instead. This command is typically part of the util-linux package, and is generally intended for use on MBR disks. It is often run with tools that are meant for automating installation processes. It's imperative to backup your data before attempting any partition modifications. Due to its potential for data loss, delpart is not as commonly used as tools like fdisk, parted, or gdisk which offer more user-friendly interfaces and safety features.
CAVEATS
Deleting a partition permanently removes the partition table entry. This does not erase the data on the partition itself, but the data becomes inaccessible without the original partition information. Backups are essential before using delpart. Using delpart on GPT disks is not recommended. Using the wrong command may corrupt the disk, use commands specifically designed for GPT disks.
ALTERNATIVE TOOLS
For interactive partition management, consider using fdisk (for MBR), parted (for both MBR and GPT), or gdisk (for GPT). These tools provide more user-friendly interfaces and safety features, such as the ability to review changes before writing them to disk.
DATA RECOVERY
If you accidentally delete a partition, data recovery is possible, but not guaranteed. Tools like TestDisk can attempt to locate and recover lost partitions. However, the success of data recovery depends on several factors, including whether any new data has been written to the disk after the partition was deleted.
HISTORY
delpart has been available as part of the util-linux package for quite some time. It's often been used in system installation scripts or automated deployment scenarios where direct partition table manipulation is needed. However, due to its low-level nature and risk of data loss, it's less commonly used in interactive scenarios.