Home / Alt manpages / delpart(8)

  • delpart(8)
  • Admin command
  • linux

Make Linux Forget a Partition with delpart

The kernel still thinks a partition exists, and delpart tells it to forget that one partition. The partition table on disk is not edited, which is the whole point of the command and the reason people misunderstand it. This guide takes about ten minutes for a read-only check and a single kernel-state change.

  • You need: the util-linux package, a shell, the parent disk device, and the partition number.
  • Book a window: if the partition is mounted, in use, part of a volume group, or backing a service. The command may disrupt processes that still expect the kernel's partition device to exist.

Warning

Do not use delpart as a partition editor. It does not remove bytes, resize a partition, clear a filesystem, or rewrite a partition table. It tells the kernel to drop its current partition object. Do not proceed until you have identified the correct parent disk and number.

1. Check the local command

Start with read-only checks. The installed manual page is generated for util-linux 2.39.3, while this machine also has a delpart executable from util-linux 2.41.3 earlier in PATH. Check the binary that your shell will run:

$ command -v delpart
/home/linuxbrew/.linuxbrew/sbin/delpart
$ delpart --version
delpart from util-linux 2.41.3
$ delpart --help

Usage:
 delpart <disk device> <partition number>

Checkpoint

Record the version and path. If your host has several util-linux installations, do not assume that a manual page from one installation describes a different binary. The basic interface is the same here, but version differences are worth resolving before an administrative operation.

2. Identify the parent disk and partition number

Use your normal inventory command to establish the exact relationship between the partition and its parent disk. For example, this is a read-only listing:

$ lsblk -o NAME,PATH,SIZE,TYPE,FSTYPE,MOUNTPOINTS
NAME   PATH         SIZE TYPE FSTYPE MOUNTPOINTS
sdb    /dev/sdb     100G disk
`-sdb3 /dev/sdb3     20G part ext4   /srv/archive

The example target is parent device /dev/sdb, partition number 3. The displayed names are examples only, so recheck them on the host where you will run the command.

Warning

Do not pass /dev/sdb3 as the first argument. delpart expects the disk device and a separate numeric partition number.

Before continuing, stop anything using the partition and unmount it if your change plan requires that. Check mounts and consumers with tools appropriate to your system. A successful ioctl does not make active filesystem, swap, RAID, LVM, database, or container use safe.

3. Confirm the partition table is not your target

Pause here if your real goal is to delete or resize the partition. delpart cannot do that. Use a partitioning tool selected for your table format and recovery plan, and take a verified backup first. This guide covers only the narrower case where the on-disk table is already correct, but the running kernel has a stale partition object.

This is also the checkpoint for scripts. Keep the disk and number as separate, quoted variables, and make a human review the values before an elevated command:

DISK='/dev/sdb'
PARTITION='3'
printf 'About to ask the kernel to forget partition %s on %s\n' "$PARTITION" "$DISK"

Checkpoint

You should see a single confirmation line containing the values you supplied. This shell fragment changes nothing.

4. Ask the kernel to forget the partition

Run the command with the privilege required by your host. This is the state-changing step. It uses the disk device and partition number, not a partitioning operation:

$ sudo delpart /dev/sdb 3

sudo is shown because ordinary users commonly lack permission for block-device administration. If your system grants the required privilege without sudo, use the local policy. Do not turn a permission failure into a reason to guess a different device or number.

A successful invocation normally produces no standard output. Treat the exit status as the first result:

$ printf 'delpart exit status: %s\n' "$?"
delpart exit status: 0

Tip

Status 0 is not proof that a filesystem was unmounted or that an application is safe. The command is a wrapper around the kernel's "delete partition" ioctl. The manual explicitly says that it does not manipulate partitions on a block device.

5. Verify the kernel view

Re-run the inventory check and inspect the specific device path:

$ lsblk -o NAME,PATH,TYPE,MOUNTPOINTS /dev/sdb
$ test ! -e /sys/class/block/sdb3
$ printf 'partition sysfs entry status: %s\n' "$?"
partition sysfs entry status: 0

The final status is 0 when the example sysfs entry is absent. Output can differ across systems and device stacks, so treat the parent disk, partition number, and current kernel state as the authoritative things to inspect.

Recovery

If the entry remains, stop rather than repeating the command blindly. Investigate mounts, holders, device-mapper layers, permissions, and the command's diagnostic output.

6. Know the recovery boundary

There is no delpart undo option. The command did not erase the partition table, so the data describing the partition should still be on disk, but the running kernel no longer has the partition object that this operation removed.

Warning

Do not recreate the partition with addpart from memory or guess its start and length.

If the kernel must recognise the unchanged on-disk partition again, use your distribution's documented partition-table reread procedure, or reboot during an approved maintenance window. Verify that procedure separately on the target system. If you intended a persistent partition change, stop and use a partitioning workflow instead. Recovery is a new, deliberate operation, not a second attempt at delpart.

Common traps

  • Wrong disk argument. Passing /dev/sdb3 as the disk fails the contract. Pass /dev/sdb and 3 separately.
  • Waiting for a success message. Silence is normal; check the exit status and kernel state.
  • Assuming the disk has changed. The command forgets a kernel object and does not rewrite the partition table.
  • Running against a mounted or service-backed partition. Administrative success does not make active users safe.
  • Mixing installations. The executable and manual page can come from different installations. Check command -v and --version first.

Done means

  • Right target. You identified the correct parent disk and numeric partition.
  • Right goal. You confirmed the aim was to change the kernel view, not the disk layout.
  • Users stopped. You stopped users of the partition and planned for service disruption.
  • Clean exit. delpart returned status 0 under the intended privilege.
  • Verified and recoverable. You checked the resulting kernel view and kept a documented reread or reboot path.