Provision Devlink Line Cards Without Losing Track of Slot State
A chassis has empty slots, and one wrong line-card type can turn ports off or on that you did not mean to touch. devlink lc lets you inspect line-card slots, see which type a driver supports, and provision a slot with an explicit type, then clear it again. It uses the devlink utility from Ubuntu's iproute2 package, version 6.1.0-1ubuntu6.4 on this machine.
The route
Jump straight to the step you need, or tick off Done means at the end.
- Time: about fifteen minutes of command work, plus whatever change window your hardware requires.
- You need: a shell, the
iproute2package, and a devlink device whose driver implements line-card management. - Privileges: reading state is unprivileged only where the system permits it. Changing a line-card type is a privileged hardware operation, so use the account and change process your network platform requires.
Checkpoint
The read-only workflow ends after step 3. Steps 4 and 5 change slot configuration and need a confirmed device, slot index and supported type.
1. Confirm the utility and syntax
Check which executable is being used, then ask the installed binary for its line-card syntax:
$ command -v devlink
/usr/sbin/devlink
$ devlink -V
devlink utility, iproute2-6.1.0
$ devlink lc help
Usage: devlink lc show [ DEV [ lc LC_INDEX ] ]
devlink lc set DEV lc LC_INDEX [ { type LC_TYPE | notype } ]
The package version and the utility's reported version are related but not identical labels. The package is 6.1.0-1ubuntu6.4, while the utility reports the upstream release line 6.1.0. Record both when comparing with another host.
There is no separate devlink-lc executable. lc is a subcommand of devlink, so do not try to run devlink-lc.
2. List every line-card slot
Start with the broadest read-only query:
$ devlink lc show
This displays line-card attributes for all line cards on all devices. A useful response names the devlink device, the slot index and the attributes the driver exposes. The exact output is driver-specific, so do not build a script around a column layout copied from another machine.
A blank result means the query showed no line card. Check that the expected hardware driver is loaded and that the device is visible to devlink before attempting a set. Do not invent a PCI address from a diagram: get the real device name from another devlink query or your platform's inventory.
Checkpoint
Write down the complete device identifier and the slot index you intend to inspect. The device format is BUS_NAME/BUS_ADDRESS, for example pci/0000:01:00.0.
3. Inspect one slot and its supported types
Once you have a device and slot index, narrow the query:
$ devlink lc show pci/0000:01:00.0 lc 1
Replace both values with identifiers from your own system. The lc 1 part selects slot index 1; it is not a line-card name. The result includes the list of line-card types supplied by that driver, and that list is authoritative for the device. A type from documentation for a different adapter, firmware release or slot is not safe to substitute.
Before changing anything, save the current output in your change record. It is your recovery reference, but it is not a full hardware backup and does not undo a change by itself.
4. Provision a supported type
Warning
Setting a line-card type changes hardware provisioning. It may affect the interfaces or ports the device presents, and a platform may need a further reload or service change. Confirm maintenance impact, console access and the rollback plan first. The operation needs the appropriate elevated privilege.
Use the exact type string reported for the selected slot:
$ sudo devlink lc set pci/0000:01:00.0 lc 1 type 16x100G
The example type 16x100G is the form documented by the man page, not a universal capability. Replace it with a value your device actually reported. The command does not take a width and speed that devlink calculates for you, and the man page defines no generic default type.
Verify the result with the same narrow query:
$ sudo devlink lc show pci/0000:01:00.0 lc 1
Confirm the slot reports the requested provisioning and that any expected platform-specific interfaces are present. If the command fails, keep the error and exit status in the change record. Do not retry repeatedly while guessing at type names.
5. Clear the provisioning when you need to undo it
The documented way to remove a line-card type is notype:
$ sudo devlink lc set pci/0000:01:00.0 lc 1 notype
$ sudo devlink lc show pci/0000:01:00.0 lc 1
Warning
This clears provisioning on the selected slot. It changes state and is not a harmless display option. Use it only when your hardware procedure says the slot can be unprovisioned. Check the result before closing the change, and keep the original show output in case you need to restore the previous type.
Recovery
There is no separate undo command. To restore a previous configuration, run set again with the previously recorded, currently supported type, subject to the device's own change procedure. If the hardware is already in a failed or partially applied state, stop and follow the vendor recovery process rather than cycling types from a script.
Common traps
- Wrong device syntax: use
BUS_NAME/BUS_ADDRESS, such aspci/0000:01:00.0, not a friendly device label. - Wrong slot: indexes are supplied explicitly after
lc. Inspect all slots first and check the index twice. - Unsupported type: line-card types come from the driver. Copy the exact spelling from
devlink lc show. - Assuming output is identical everywhere: supported types and displayed attributes depend on the device and driver.
- Confusing display with change:
showreads state;setchanges it. Only the latter belongs in a maintenance window.
Done means
- Interface identified:
devlink -Vanddevlink lc helpshow the installed syntax. - Baseline recorded: you noted the real devlink device name, slot index and pre-change output.
- Type is genuine: the requested type came from that slot's reported supported types.
- Change was deliberate: a privileged
setran only after its service impact and rollback were understood. - Result confirmed: a follow-up
showconfirms the intended state, or the failed result is preserved for recovery.