XFS Quota
Explore this Page
- Overview
- Requirements
- Enabling XFS Quota
- Managing and Modifying XFS Quota
- Modifying the XFS Quota Limits
- Limitations
Overview
To enforce storage limits, it is essential to enable and properly configure XFS project quotas. This document outlines the necessary prerequisites, installation procedures, filesystem configurations, and StorageClass setup required to enable XFS quotas.
Additionally, it describes how to create Persistent Volume Claims (PVCs), verify quota enforcement, and adjust quota limits when necessary.
By following the steps in this document, you will be able to successfully enable, configure, and manage XFS Quotas for deployments across various Linux distributions, including Ubuntu, Debian, RHEL, CentOS, and Fedora.
Requirements
To use XFS Quotas with Local PV Hostpath, ensure the following requirements are fulfilled:
- Install the
xfsprogs
package. - Confirm that the filesystem type is XFS.
- Configure the filesystem to use the
pquota
orprjquota
mount option.
Installing the xfsprogs Package
For Ubuntu/Debian Systems
For RHEL/CentOS Systems
For Fedora Systems
Mounting the Filesystem with pquota Option
Verifying Filesystem Type
Check if the hostPath directory (/var/openebs/local by default
) is using the XFS filesystem:
Filesystem Type Size Used Avail Use% Mounted on
/dev/nvme0n1p1 xfs 8.0G 959M 7.1G 12% /
If the directory does not exist yet, use the following script to determine the base directory and filesystem:
BASEPATH="/var/openebs/local"
until OUTPUT=$(df -Th $BASEPATH 2> /dev/null)
do
BASEPATH=$(echo "$BASEPATH" | sed 's|\(.*\)/.*|\1|')
done
echo "PATH=${BASEPATH}"
echo "$OUTPUT"
Checking Existing Mount Options
Verify whether the mount options for the device include pquota
or prjquota
:
If the mount options already include pquota
or prjquota
, you can proceed to the next section. If not, continue with Mounting the Device with pquota.
Mounting the Device with pquota
Root Filesystem
If the filesystem is mounted as the root (/
), follow these steps:
-
Edit the GRUB configuration.
-
Locate the
GRUB_CMDLINE_LINUX
entry and appendrootflags=pquota
.CopyLocate GRUB_CMDLINE_LINUX EntryGRUB_CMDLINE_LINUX="console=tty0 crashkernel=auto net.ifnames=0 console=ttyS0 rootflags=pquota"
-
Identify the GRUB configuration file path.
CopyPossible Locations/boot/grub2/grub.cfg
/boot/efi/EFI/ubuntu/grub.cfg
/boot/efi/EFI/debian/grub.cfg
/boot/efi/EFI/redhat/grub.cfg
/boot/efi/EFI/centos/grub.cfg
/boot/efi/EFI/fedora/grub.cfg -
Backup the existing GRUB configuration.
-
Regenerate the GRUB configuration.
-
Reboot the system.
-
After reboot, verify the mount options again.
Filesystem on a Data Disk
If the filesystem is on a data disk:
-
Unmount the device.
-
Mount the device with the
pquota
option.pquota
cannot be enabled using a remount operation. -
Verify the mount options.
-
Update
/etc/fstab
to persist the change.CopyAdd pquota Option to /etc/fstab FileUUID=9cff3d69-3769-4ad9-8460-9c54050583f9 /mnt/data xfs defaults,pquota 0 0
Enabling XFS Quota
Creating a StorageClass
Define a StorageClass with XFS quota support.
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: puls8-hostpath-xfs
annotations:
openebs.io/cas-type: local
cas.openebs.io/config: |
- name: StorageType
value: "hostpath"
- name: BasePath
value: "/var/openebs/local/"
- name: XFSQuota
enabled: "true"
provisioner: openebs.io/local
volumeBindingMode: WaitForFirstConsumer
reclaimPolicy: Delete
Advanced XFS Quota Configuration
Configure softLimitGrace
and hardLimitGrace
.
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: puls8-hostpath-xfs
annotations:
openebs.io/cas-type: local
cas.openebs.io/config: |
- name: StorageType
value: "hostpath"
- name: BasePath
value: "/var/openebs/local/"
- name: XFSQuota
enabled: "true"
data:
softLimitGrace: "0%"
hardLimitGrace: "0%"
provisioner: openebs.io/local
volumeBindingMode: WaitForFirstConsumer
reclaimPolicy: Delete
If no values are specified, defaults are softLimitGrace: "0%"
and hardLimitGrace: "0%"
, restricting volume size to the PVC's requested storage.
Creating a PVC
Create a PVC using the StorageClass name.
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: local-hostpath-xfs
spec:
storageClassName: puls8-hostpath-xfs
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
Check the status of the PVC.
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
local-hostpath-xfs Pending puls8-hostpath-xfs 21s
Mounting the Volume
Mount the volume to the application pod container.
apiVersion: v1
kind: Pod
metadata:
name: busybox
spec:
volumes:
- name: local-storage
persistentVolumeClaim:
claimName: local-hostpath-xfs
containers:
- name: busybox
image: busybox
command:
- sh
- -c
- 'while true; do echo "`date` [`hostname`] Hello from OpenEBS Local PV." >> /mnt/store/greet.txt; sleep $(($RANDOM % 5 + 300)); done'
volumeMounts:
- mountPath: /mnt/store
name: local-storage
Verify that the XFS project quota is enforced.
Project quota on /var/openebs/local (/dev/loop16)
Blocks
Project ID Used Soft Hard Warn/Grace
---------- ---------------------------------
#0 0 0 0 00 [------]
#1 0 5.7G 6.7G 00 [------]
Managing and Modifying XFS Quota
Identifying the BasePath Directory
Retrieve the BasePath directory.
Locating the Node
Identify the node where the volume exists.
Find the node.
Modifying the XFS Quota Limits
Changing Quota Limits
Retrieve the current quota report.
Project quota on /var/openebs/local (/dev/nvme1n1)
Blocks
Project ID Used Soft Hard Warn/Grace
---------- ---------------------------------
#0 0 0 0 00 [------]
#1 1G 2.0G 2.0G 00 [------]
Modify the soft and hard limits.
Verify the updated limits.
Project quota on /var/openebs/local (/dev/nvme1n1)
Blocks
Project ID Used Soft Hard Warn/Grace
---------- ---------------------------------
#0 0 0 0 00 [------]
#1 1G 3G 5G 00 [------]
Limitations
Quota resizing is not supported: If you need to adjust quotas, you must manually modify the soft and hard limits as shown above.
Learn More