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

PARAMETERS

device
    Full path to partition device (required, e.g., /dev/block/mmcblk0p1 or /dev/block/by-name/system)

DESCRIPTION

delpart is a specialized command-line utility designed for deleting Linux partitions, primarily used in Android development and embedded systems. It takes a device path (e.g., /dev/block/mmcblk0p1) as input, unlinks the corresponding /dev entry, and wipes the partition from the kernel's partition table. This makes the partition space available again without needing interactive tools like fdisk or parted.

Unlike general partitioning tools, delpart operates directly on block devices and does not resize filesystems or move data—it simply removes the partition metadata. It requires root privileges (su or running as root) and performs the operation irreversibly without confirmation prompts. This tool is part of the Android Open Source Project (AOSP) in the extras/partition_tools directory, aiding in custom ROM flashing, factory resets, or repartitioning devices like phones and tablets.

delpart is not included in standard Linux distributions (e.g., Ubuntu, Fedora) and must be compiled from AOSP source or obtained from Android build environments. It targets GPT or MBR tables and works on MMC, NAND, or other block devices common in mobile hardware.

CAVEATS

No confirmation prompt—irreversible data loss possible. Requires root. Can brick devices if wrong partition deleted (e.g., boot). Not for standard desktops; Android/embedded only. May fail on mounted partitions or protected tables.

EXAMPLE

delpart /dev/block/platform/sdhci-tegra.3/by-name/cache

Deletes the 'cache' partition safely after unmounting.

BUILD NOTE

Compile with Android NDK or AOSP: gcc delpart.c -o delpart. Source available at android.googlesource.com.

HISTORY

Developed for Android Open Source Project (AOSP) around 2009-2010 in system/extras/partition_tools/delpart.cc. Evolved for ARM-based devices; still used in AOSP builds for partition management during OTA updates and factory images.

SEE ALSO

parted(8), fdisk(8), gdisk(8), sfdisk(1)

Copied to clipboard