LinuxCommandLibrary

delpart

Delete a partition from a disk

TLDR

Tell the kernel to forget about the first partition of /dev/sda

$ sudo delpart [/dev/sda] [1]
copy

SYNOPSIS

delpart device partition_number

PARAMETERS

device
    The disk device where the partition resides (e.g., /dev/sda, /dev/nvme0n1).

partition_number
    The numerical identifier of the partition to remove from the kernel's table (e.g., 1, 2, 3).

DESCRIPTION

delpart is a Linux command used to remove a specified partition entry from the kernel's in-memory partition table.
It does not modify the physical partition table on the disk (e.g., MBR or GPT).
This command is particularly useful when a partition has been removed or modified externally (e.g., using low-level tools like dd) and the kernel still retains an old, incorrect view of the partition.
By telling the kernel to forget a specific partition, delpart helps prevent confusion and errors, ensuring the kernel's internal state reflects the actual disk layout.
It requires root privileges to execute.

CAVEATS

delpart only affects the kernel's in-memory view; it does not modify the on-disk partition table.
If the on-disk table still contains the partition, the kernel might re-read and re-add it later (e.g., after a reboot or a partprobe command).
It is not a tool for deleting partitions from the disk; use partitioning tools like fdisk or parted for that purpose.
Improper use can lead to discrepancies between the kernel's view and the actual disk layout, potentially causing data access issues.
For informing the kernel about general partition table changes, partprobe is often a more comprehensive and commonly used command.

SPECIFIC USE CASES

delpart is often used in situations where other methods of updating the kernel's partition view fail or are not suitable.
For example, after using dd to overwrite a partition or a portion of a disk, or in rescue scenarios where the kernel has a stale view of a partition that no longer exists physically, and a simple partprobe doesn't resolve the issue for that specific entry.

HISTORY

delpart is part of the util-linux package, a collection of essential system utilities for Linux.
While its core functionality remains consistent, its direct usage has somewhat decreased with the advent of more automated tools like partprobe, which can detect and inform the kernel about changes across all partitions more dynamically.
delpart remains a valuable, targeted command for specific scenarios requiring the explicit removal of a single partition entry from the kernel's active table.

SEE ALSO

addpart(8), partprobe(8), fdisk(8), parted(8), kpartx(8)

Copied to clipboard