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.

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:

``bash

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:

`bash

sudo mkfs.xfs /dev/nvme0n2p1

`

3. Create a Mount Point

Create a directory where the filesystem will be mounted:

`bash

sudo mkdir /mnt/data

`

Enable Quotas in /etc/fstab

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

`bash

sudo nano /etc/fstab

`

Add an entry for the partition:

`plaintext

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

`

Find the partition’s UUID using:

`bash

blkid

`

Remount and Verify

Remount all filesystems:

`bash

sudo mount -a

`

Verify the mount options:

`bash

mount | grep /mnt/data

`

Use Systemd Mount Units for Advanced Configuration

Create the Systemd Unit

Create a custom systemd unit file:

`bash

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

`

Add the following configuration:

`ini

[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:

`bash

sudo systemctl daemon-reload

sudo systemctl enable mnt-data.mount

sudo systemctl start mnt-data.mount

`

Verify the status:

`bash

sudo systemctl status mnt-data.mount

`

Check the Mount

Ensure the filesystem is mounted with quotas:

`bash

mount | grep /mnt/data

`

Initialize Quotas

Enable quotas on the XFS filesystem:

`bash

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

`

Check quota status:

`bash

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

`

Optional: Set User and Group Quotas

To set quotas for a user:

`bash

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

`

View quota usage:

`bash

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

`

Verify Persistence

Reboot the system to confirm the configuration:

`bash

sudo reboot

`

After reboot, verify the mount and quotas:

`bash

mount | grep /mnt/data

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

``

Conclusion

You have successfully configured an