Home / Alt manpages / devlink-resource(8)

  • devlink-resource(8)
  • Admin command
  • linux

Resize a devlink Device Resource Safely

Your switch or NIC has run out of room in one of its hardware tables, and devlink resource set is the knob that reallocates it. You will find the exact resource path, save the current allocation, resize it and check the result, in about 10 minutes.

The examples use the command shipped by iproute2 6.1.0. Add time to confirm that changing the device will not interrupt anything using it.

Before you start

You need the devlink command and a device managed through devlink. The installed command reports its version like this:

devlink -V

On this machine the result is:

devlink utility, iproute2-6.1.0
  • Device identifier. It takes the form BUS_NAME/BUS_ADDRESS. For a PCI device that commonly looks like pci/0000:01:00.0. Swap in the identifier for your own device.
  • Reading is normally non-mutating. System policy can still restrict access to device information.
  • Resizing needs elevated privileges.

1. Check that the resource commands are available

Start with the built-in help. It confirms the local syntax without touching a device:

devlink resource help

Two operations matter: show displays resources, and set changes one resource's size. The installed manpage defines no universal resource list and no default device, so never copy a resource path from an unrelated adapter.

2. Record the current resource tree

Put your actual device identifier in a shell variable, then show its resources:

DEV='pci/0000:01:00.0'
devlink resource show "$DEV"

Expect a device-specific listing with resource names or paths and their current sizes. The exact output depends on the driver and hardware. Do not change anything on a guess.

Save the output before you continue. A plain terminal capture is enough:

devlink resource show "$DEV" | tee devlink-resource-before.txt

Checkpoint

You should now have the exact device identifier, the exact resource path and the old size written down. If the command says the device does not exist, stop and correct DEV. Do not try alternate paths at random.

3. Select one resource and its new size

The resource path is passed separately from the device. The manpage example uses /kvd/linear. That path is only an example, not a promise that your device provides it.

Choose a new size the driver and hardware support, and keep the old size from your capture so you can restore it. For example, if your listing shows /kvd/linear and you have deliberately chosen 98304 as the new size:

RESOURCE_PATH='/kvd/linear'
NEW_SIZE='98304'

Do not treat that number as a universal unit conversion. devlink accepts a resource size, while the driver decides which values are valid and how the resource is represented.

4. Warn users and apply the change

Warning

Changing a device resource can affect the device's capacity, and depending on the driver and what is using the device it may be rejected or disruptive. Schedule the change, stop or drain dependent workloads if your device documentation requires it, and make sure you have console access for recovery.

Now run the mutating command with elevated privileges:

sudo devlink resource set "$DEV" path "$RESOURCE_PATH" size "$NEW_SIZE"

Success may print nothing. A diagnostic means the path, size, device state or permissions were not accepted. Even a clean return only means the command accepted the request, so inspect the allocation before you believe it.

5. Verify the resulting allocation

Read the resource tree again and compare it with the saved output:

devlink resource show "$DEV" | tee devlink-resource-after.txt

Checkpoint

The intended path reports the requested size, and unrelated resources still hold the values you expect. If the resource is missing or unchanged, or the command fails, keep both captures for diagnosis. Do not repeat the change with a different guessed path.

6. Restore the old size if you need to undo the change

There is no separate undo operation. Run the same command with the recorded old size:

OLD_SIZE='REPLACE_WITH_THE_RECORDED_OLD_SIZE'
sudo devlink resource set "$DEV" path "$RESOURCE_PATH" size "$OLD_SIZE"
devlink resource show "$DEV"

Replace the placeholder before pressing Enter.

Recovery

If the driver rejects the old value after other device changes, stop and follow the hardware or driver documentation instead of forcing more allocations. A reboot or device reset is not a generic fix. Use one only when the device documentation explicitly supports it.

Common traps

  • Wrong device syntax. DEV must be BUS_NAME/BUS_ADDRESS, not a friendly interface name such as eth0.
  • Copied resource path. Paths are device-specific. Get yours from devlink resource show.
  • Missing privileges. Ordinary privileges work for inspection where permitted. resource set needs sudo.
  • Unrecorded old size. Without the before capture, restoring is guesswork. If you have not saved it, stop before changing anything.
  • Silence taken for success. Rerun resource show and compare the reported value.

Done means

  • Device identified. You have it as BUS_NAME/BUS_ADDRESS.
  • Before capture saved. You have the original resource listing.
  • Sensible target. The path and size you used were shown or justified by the target device.
  • Change applied properly. You used the required privileges.
  • Result confirmed. A second devlink resource show reported the new size.
  • Way back kept. You retained the old size and know the command that restores it.