Volumes are expanded in two stages. First, Longhorn expands the frontend (the block device), then it expands the filesystem.

To prevent the frontend expansion from interference by unexpected data R/W, Longhorn supports offline expansion only. The volume will be automatically attached to a random node with maintenance mode.

Rebuilding and adding replicas is not allowed during the expansion, and expansion is not allowed while replicas are rebuilding or being added.

If the volume was not expanded though the CSI interface (e.g. for Kubernetes older than v1.16), the capacity of the corresponding PVC and PV won’t change.

  • The volume to be expanded must be in the detached state.

Via PVC

This method is applied only if:

  • The PVC is dynamically provisioned by the Kubernetes with Longhorn StorageClass.
  • The field allowVolumeExpansion should be in the related StorageClass.

This method is recommended if it’s applicable, because the PVC and PV will be updated automatically and everything is kept consistent after expansion.

Usage: Find the corresponding PVC for Longhorn volume, then modify the requested spec.resources.requests.storage of the PVC:

Via Longhorn UI

Usage: On the volume page of Longhorn UI, click Expand for the volume.

  • The expanded size should be greater than the current size.
  • There is a Linux filesystem in the Longhorn volume.
  • The Longhorn volume is using the block device frontend.

Handling Volume Revert

If a volume is reverted to a snapshot with smaller size, the frontend of the volume is still holding the expanded size. But the filesystem size will be the same as that of the reverted snapshot. In this case, you will need to handle the filesystem manually:

  1. Attach the volume to a random node.

  2. Log in to the corresponding node, and expand the filesystem.

    If the filesystem is , the volume might need to be mounted and once before resizing the filesystem manually. Otherwise, executing resize2fs might result in an error: