Volume Expansion
detached
.There are two ways to expand a Longhorn volume:
allowVolumeExpansion
should be true
in the related StorageClass.storage
of the PVC spec. e.g.,apiVersion: v1
kind: PersistentVolumeClaim
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"v1","kind":"PersistentVolumeClaim","metadata":{"annotations":{},"name":"longhorn-simple-pvc","namespace":"default"},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"1Gi"}},"storageClassName":"longhorn"}}
pv.kubernetes.io/bind-completed: "yes"
pv.kubernetes.io/bound-by-controller: "yes"
volume.beta.kubernetes.io/storage-provisioner: driver.longhorn.io
creationTimestamp: "2019-12-21T01:36:16Z"
finalizers:
- kubernetes.io/pvc-protection
name: longhorn-simple-pvc
namespace: default
resourceVersion: "162431"
selfLink: /api/v1/namespaces/default/persistentvolumeclaims/longhorn-simple-pvc
uid: 0467ae73-22a5-4eba-803e-464cc0b9d975
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
storageClassName: longhorn
volumeMode: Filesystem
volumeName: pvc-0467ae73-22a5-4eba-803e-464cc0b9d975
status:
accessModes:
- ReadWriteOnce
capacity:
storage: 1Gi
phase: Bound
Modify spec.resources.requests.storage
of this PVC.
Expand
for the volume.detached
volume will be automatically attached to a random node with maintenance mode.If users revert a volume 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, users need to handle the filesystem manually:
ext4
, the volume might need to be mounted and umounted once before resizing the filesystem manually. Otherwise, executing resize2fs
might result in an error:resize2fs: Superblock checksum does not match superblock while trying to open ......
Couldn't find valid filesystem superblock.
Follow the steps below to resize the filesystem:
mount /dev/longhorn/<volume name> <arbitrary mount directory>
umount /dev/longhorn/<volume name>
mount /dev/longhorn/<volume name> <arbitrary mount directory>
resize2fs /dev/longhorn/<volume name>
umount /dev/longhorn/<volume name>
xfs
, users can directly mount then expand the filesystem.mount /dev/longhorn/<volume name> <arbitrary mount directory>
xfs_growfs <the mount directory>
umount /dev/longhorn/<volume name>
© 2019-2024 Longhorn Authors | Documentation Distributed under CC-BY-4.0
© 2024 The Linux Foundation. All rights reserved. The Linux Foundation has registered trademarks and uses trademarks. For a list of trademarks of The Linux Foundation, please see our Trademark Usage page.