XFS is the default filesystem in the Red hat Enterprise Linux 7 (RHEL 7) with many advantages and in this tutorial you will learn to how to extend or grow XFS filesystem online in RHEL 7 without causing any damage. It is somewhat similar to EXT4 filesystem only there is a command difference.
There are many scenarios and situation where you have to extend your filesystem. This can be due to exhausted space in the filesystem or its going to be exhausted, or space is needed for copying new files and directories or anything like that. So, the task of a system administrator is to meet that request.
For this tutorial, we already assume that you already have created and mounted your XFS filesystem on your server and you are ready to extend it. And if you haven’t created till now follow this tutorial on how to create an XFS filesystem on RHEL 7.
Steps to Extend / Grow XFS Filesystem in RHEL 7 or CentOS
1. Login to your RHEL 7 server or workstation as root. You can also login as normal user and then sudo to root.
2. Check if space is available in volume group (VG) having that logical volume which you want to grow. If space is not available then you can first add storage to your server and then can use “lvextend” and “xfs_growfs” commands.
In below example, we have increased only 100mb on “/data/db” filesystem for demonstration. You can see earlier filesystem was 87% utilized, but after increasing it becomes 72% utilized.
[root@rhel7 data]# df -hP /data/db Filesystem Size Used Avail Use% Mounted on /dev/mapper/datavg-databaselv 493M 425M 68M 87% /data/db [root@rhel7 data]# lvextend -L +100M /dev/mapper/datavg-databaselv Extending logical volume databaselv to 596.00 MiB Logical volume databaselv successfully resized [root@rhel7 data]# xfs_growfs /dev/mapper/datavg-databaselv meta-data=/dev/mapper/datavg-databaselv isize=256 agcount=4, agsize=31744 blks = sectsz=512 attr=2, projid32bit=1 = crc=0 data = bsize=4096 blocks=126976, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=0 log =internal bsize=4096 blocks=853, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 data blocks changed from 126976 to 152576
Note: If storage is not available on your server, then check if your server is physical or virtual. If your server is physical ask your storage team to give you desired size LUN and if the server is virtual then ask your VM team or if you have access then add yourself the VM disk of desired size or increase the size of existing disk attached to a virtual server.
If you have added a new disk to a server, please first create new “PV” and then extend the “VG” and then follow above steps.
To summarize, commands can be written as below.
pvcreate /dev/sdX vgextend VG_Name /dev/sdX lvextend -L +Size LV_name xfs_growfs LV_name
3. Once your XFS filesystem has been expanded, just verify using “df” command like below.
[root@rhel7 data]# df -hP /data/db Filesystem Size Used Avail Use% Mounted on /dev/mapper/datavg-databaselv 593M 425M 168M 72% /data/db [root@client10 data]#
This is how you can easily grow XFS filesystem online in Red hat Enterprise Linux 7 (RHEL 7) or CentOS 7.
This was a simple beginner tutorial for the growing XFS filesystem on RHEL 7 servers and, if you have a problem in any step, please let us know. If you like this tutorial do not forget to share it with your friends and social groups. If you need any other tutorial, please mail us or comment below.