AnsiblePilot — Master Ansible Automation

AnsiblePilot is the leading resource for learning Ansible automation, DevOps, and infrastructure as code. Browse over 1,400 tutorials covering Ansible modules, playbooks, roles, collections, and real-world examples. Whether you are a beginner or an experienced engineer, our step-by-step guides help you automate Linux, Windows, cloud, containers, and network infrastructure.

Popular Topics

About Luca Berton

Luca Berton is an Ansible automation expert, author of 8 Ansible books published by Apress and Leanpub including "Ansible for VMware by Examples" and "Ansible for Kubernetes by Example", and creator of the Ansible Pilot YouTube channel. He shares practical automation knowledge through tutorials, books, and video courses to help IT professionals and DevOps engineers master infrastructure automation.

Configure XFS Filesystem with Quotas on Fedora

By Luca Berton · Published 2024-01-01 · Category: installation

Step-by-step guide to mounting XFS filesystems with user and group quotas on Fedora using fstab and systemd mount units.

Configure XFS Filesystem with Quotas on Fedora

Managing storage is a critical aspect of system administration, and the XFS filesystem is a popular choice due to its performance and scalability. This guide explains how to configure an XFS filesystem with quotas on Fedora, using both /etc/fstab and systemd mount units.

Introduction

This article walks you through the steps to: • Configure an XFS filesystem on a secondary disk. • Enable user (uquota) and group (gquota) quotas. • Manage mounts using /etc/fstab or systemd units.

Let’s dive into the configuration.

See also: Ansible Delete File: Remove Files & Directories (state=absent Guide)

Prerequisites

• A secondary disk (e.g., /dev/nvme0n2p1) is attached to your system. • Familiarity with basic Linux commands.

Configure the XFS Filesystem

1. Identify the Disk

Use lsblk to identify the disk and its partition:

lsblk
Ensure the disk (e.g., /dev/nvme0n2p1) is recognized.

2. Format the Partition

If the disk is not formatted, initialize it with the XFS filesystem:

sudo mkfs.xfs /dev/nvme0n2p1

3. Create a Mount Point

Create a directory where the filesystem will be mounted:

sudo mkdir /mnt/data

See also: ansible.builtin.find Module: Search Files by Pattern, Size & Age (Guide)

Enable Quotas in /etc/fstab

To enable quotas during boot, edit /etc/fstab:

sudo nano /etc/fstab

Add an entry for the partition:

UUID=27acffe0-c3d5-43b7-8614-baa5d9ffce60 /mnt/data xfs uquota,gquota 0 0

Find the partition’s UUID using:

blkid

Remount and Verify

Remount all filesystems:

sudo mount -a

Verify the mount options:

mount | grep /mnt/data

Use Systemd Mount Units for Advanced Configuration

Create the Systemd Unit

Create a custom systemd unit file:

sudo nano /etc/systemd/system/mnt-data.mount

Add the following configuration:

[Unit]
Description=Mount XFS filesystem with quotas on /mnt/data
After=local-fs.target

[Mount] What=/dev/nvme0n2p1 Where=/mnt/data Type=xfs Options=defaults,uquota,gquota

[Install] WantedBy=multi-user.target

Enable and Start the Unit

Reload systemd and enable the unit:

sudo systemctl daemon-reload
sudo systemctl enable mnt-data.mount
sudo systemctl start mnt-data.mount

Verify the status:

sudo systemctl status mnt-data.mount

Check the Mount

Ensure the filesystem is mounted with quotas:

mount | grep /mnt/data

See also: Ansible Search String in File: lineinfile & regex Guide

Initialize Quotas

Enable quotas on the XFS filesystem:

sudo xfs_quota -x -c "quota" /mnt/data

Check quota status:

sudo xfs_quota -x -c "report" /mnt/data

Optional: Set User and Group Quotas

To set quotas for a user:

sudo xfs_quota -x -c "limit bsoft=500m bhard=600m username" /mnt/data

View quota usage:

sudo xfs_quota -x -c "report -h" /mnt/data

Verify Persistence

Reboot the system to confirm the configuration:

sudo reboot

After reboot, verify the mount and quotas:

mount | grep /mnt/data
sudo xfs_quota -x -c "report" /mnt/data

Conclusion

You have successfully configured an XFS filesystem with quotas on Fedora. Whether you use /etc/fstab or systemd, this guide ensures your filesystem is ready to enforce storage limits for users and groups.

--- If you found this guide helpful, consider supporting the community or sharing your success story!

References

Learn More About XFS FilesystemSystemd Documentation

Related Articles

How to install Ansible in Fedora 34 - Ansible installHow to install Ansible in Fedora 35 - Ansible installHow to install Ansible in Fedora 36 - Ansible install

Category: installation

Browse all Ansible tutorials · AnsiblePilot Home