How to Create, Quota, and Expand an XFS Filesystem on RHEL/CentOS 7
This guide walks through creating an XFS filesystem on a new partition, configuring LVM physical, volume, and logical volumes, formatting with XFS, enabling user and group quotas, assigning quota limits, testing quota enforcement, and finally expanding the logical volume and growing the XFS filesystem.
XFS is a high‑performance, scalable filesystem and the default on RHEL 7/CentOS 7, offering metadata journaling, online defragmentation, and resizing.
Below are the step‑by‑step commands to create an XFS filesystem, set up LVM, enable quotas, and expand the filesystem.
1. Partition a 2 GB disk and enable LVM
[root@localhost ~]# partprobe /dev/sdb
[root@localhost ~]# parted /dev/sdb mklabel gpt
[root@localhost ~]# parted /dev/sdb mkpart primary 4MiB 2048MiB
[root@localhost ~]# parted /dev/sdb set 1 lvm on2. Create a Physical Volume (PV)
[root@localhost ~]# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created3. Create a Volume Group (VG) named xfsgroup00
[root@localhost ~]# vgcreate xfsgroup00 /dev/sdb1
Volume group "xfsgroup00" successfully created4. Create a Logical Volume (LV) xfsdata of 1 GiB
[root@localhost ~]# lvcreate -L 1G -n xfsdata xfsgroup00
Logical volume "xfsdata" created5. Format the LV with XFS
[root@localhost ~]# mkfs.xfs /dev/xfsgroup00/xfsdataNote: XFS cannot be shrunk after creation; use xfs_growfs to enlarge.
6. Mount the filesystem with quota options
[root@localhost ~]# mkdir /xfsdata
[root@localhost ~]# mount -o uquota,gquota /dev/xfsgroup00/xfsdata /xfsdata
[root@localhost ~]# chmod 777 /xfsdata7. Configure and verify quotas
# xfs_quota -x -c 'report' /xfsdata
# xfs_quota -x -c 'limit bsoft=100M bhard=120M zhongq' /xfsdata
# xfs_quota -x -c 'report' /xfsdataAssign a soft limit of 100 MiB and a hard limit of 120 MiB to user zhongq.
8. Test quota enforcement
# su zhongq
$ dd if=/dev/zero of=/xfsdata/file1 bs=1M count=100
100+0 records in
100+0 records out
$ dd if=/dev/zero of=/xfsdata/file2 bs=1M count=100
dd: error writing ‘/xfsdata/file2’: Disk quota exceeded9. Expand the LV to 1.5 GiB and grow the XFS filesystem
[root@localhost ~]# lvextend -L 1.5G /dev/xfsgroup00/xfsdata
Logical volume "xfsdata" successfully resized
[root@localhost ~]# xfs_growfs /dev/xfsgroup00/xfsdata -D 393216
data blocks changed from 262144 to 393216After expansion, the filesystem shows the new size:
# df -h | grep xfsdata
/dev/mapper/xfsgroup00-xfsdata 1.5G 153M 1.4G 10% /xfsdataThese steps demonstrate full lifecycle management of an XFS filesystem with LVM, quota configuration, and dynamic resizing.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
