Refresh Linux's Partition View with addpart

Storage changed underneath the kernel and it has not noticed yet, so addpart tells it about a partition that already exists on a block device. It updates the kernel's view only; it does not create or edit a partition table, and that distinction is the safety boundary for every example here.

Allow about 15 minutes, plus time to verify the partition map from a trusted source. You need util-linux and a shell. The installed manpage describes util-linux 2.39.3, while the executable on this machine reports util-linux 2.41.3, so check addpart --help and addpart --version on the host you are operating. The four-argument interface below is the same on both.

Warning: this is a privileged, state-changing operation. A wrong device, partition number, start sector or length can make the kernel expose an incorrect partition. It does not overwrite the disk by itself, but programs using the kernel's new view may then read or write the wrong range. Do not run the example until every value has been independently checked.

1. Confirm the local command

Start with the read-only checks; these need no elevated privileges:

$ addpart --version
addpart from util-linux 2.41.3
$ addpart --help
Usage:
 addpart <disk device> <partition number> <start> <length>

Your version line may differ. The help output confirms the argument order: disk device, partition number, start sector and length in sectors. There are no options for a partition table format, filesystem or unit.

Checkpoint: stop if the command is missing, the help text differs materially, or you are not operating the intended host. Install or upgrade util-linux through the host's normal administration process rather than improvising a replacement.

2. Record the current kernel view

Inspect the devices before deciding addpart is even needed:

$ lsblk -o NAME,PATH,TYPE,SIZE,START,SECTORS,PTTYPE,FSTYPE,MOUNTPOINTS
$ sudo fdisk -l /dev/sdX

Replace /dev/sdX only after identifying the disk by stable evidence such as its model, serial number or a documented storage map; do not use a guessed device name just because it happens to be present. The first command reads the kernel's current view, the second asks fdisk to read the disk's own partition information and may need privilege on your system.

Compare the trusted partition-table record with the kernel view. If the partition is already present with the correct size, do not run addpart merely to be thorough. If the partition table itself is wrong, use a partitioning tool and its documentation: addpart is not a partition editor.

3. Convert the range to 512-byte sectors

The start and length arguments are counts of 512-byte sectors: not byte offsets, not filesystem blocks, not MiB, and not the end sector. For a partition beginning at byte offset B and containing N bytes:

start = B / 512
length = N / 512

Both divisions must be exact. For example, a range beginning at sector 2048 and ending after sector 206847 has a start of 2048 and a length of 204800 sectors, because length is a count of sectors, not the final sector number. Prefer values copied from a trusted partition-table report over hand arithmetic.

Write the proposed invocation down before running it:

sudo addpart /dev/sdX PARTITION_NUMBER START_SECTOR LENGTH_SECTORS

Replace all four uppercase placeholders. The device is the disk, not the partition path; the first partition on /dev/sdX would use partition number 1, but that is only an illustration of numbering, not a recommendation for your disk.

4. Check for collisions and active users

Before changing the kernel view, check the proposed range fits inside the disk and does not overlap a partition Linux already knows about:

$ lsblk -o NAME,PATH,TYPE,SIZE,START,SECTORS,MOUNTPOINTS /dev/sdX
$ findmnt --source /dev/sdXPARTITION_NUMBER
$ sudo fuser -vm /dev/sdXPARTITION_NUMBER

The partition path in these commands is illustrative; replace it with the real path only if the kernel already exposes one. A mounted or actively used range needs a maintenance window and a recovery plan. Stop if the proposed interval overlaps an existing partition, a device-mapper target, a RAID member or a mounted filesystem, and resolve the storage design first.

Checkpoint: you should have a saved, trusted record of the disk identity, partition number, start sector and sector length. If any one of those is uncertain, this is the place to stop.

5. Add the partition to the kernel view

Only now run the command, with elevated privileges:

$ sudo addpart /dev/sdX PARTITION_NUMBER START_SECTOR LENGTH_SECTORS

On success, addpart normally prints nothing and returns status 0. Capture the status immediately if you need to record it:

$ printf '%s\n' "$?"
0

The command wraps the kernel's add-partition ioctl. It tells the kernel that range exists; it does not write a partition-table entry. That is why it can be appropriate after a storage change made by another layer, and also why it cannot repair a bad partition table.

6. Verify the resulting device

Refresh the listing and look for the new partition with the expected size and start:

$ lsblk -o NAME,PATH,TYPE,SIZE,START,SECTORS,FSTYPE,MOUNTPOINTS /dev/sdX
$ sudo fdisk -l /dev/sdX

Compare the reported range with the values you approved, not just the partition name. If a new device node appears, do not mount it or run filesystem repair tools until its identity and contents are established: a successful ioctl is not proof the values describe the intended filesystem.

If the command fails, preserve its diagnostic and status. Recheck the device, number, range and privilege. Do not keep changing numbers until something succeeds.

Undo and recovery

addpart has no undo option. To remove a partition from the kernel's view, use the matching delpart operation, but only after stopping users of the device and confirming the exact partition number:

$ sudo delpart /dev/sdX PARTITION_NUMBER

This also changes kernel state and is not a substitute for correcting the partition table. If the underlying table is authoritative, make the table and kernel agree using the appropriate storage workflow, then verify again. Do not use delpart as a casual cleanup command while a filesystem, RAID stack or device mapper may still be using the range.

Done means