Make Linux Forget a Partition Safely with delpart
You will finish with a controlled way to ask the Linux kernel to forget one partition from a block device's current in-memory view. The partition table on disk is not edited. That distinction is the whole point of delpart, and it is also the boundary that makes the command easy to misunderstand.
The route
Jump straight to the step you need, or tick off Done means at the end.
Allow 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. Have a maintenance 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. Do not pass /dev/sdb3 as the first argument: delpart expects the disk device and a separate numeric partition number. The displayed names are examples only. Recheck them on the host where you will run the command.
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 that the partition table is not your intended 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"
Expected output is 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
Do not mistake status 0 for 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. 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. Do not recreate it 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
- Passing
/dev/sdb3as the disk argument. Pass/dev/sdband3separately. - Expecting 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 the executable and manual page from different installations. Check
command -vand--versionfirst.
Done means
- You identified the correct parent disk and numeric partition.
- You confirmed that the goal was to change the kernel view, not the disk layout.
- You stopped users of the partition and planned for service disruption.
delpartreturned status 0 under the intended privilege.- You verified the resulting kernel view and kept a documented reread or reboot path if recovery is needed.