How do I grow or extend a GFS2 file-system on RHEL?
Environment
- Red Hat Enterprise Linux Server 5 (with Clustering and Cluster Storage)
- Red Hat Enterprise Linux Server 6, 7, 8 (with the High Availability Add On and Resilient Storage Add Ons)
- A Global Filesystem 2(
gfs2)
Issue
- How can I safely grow or extend a GFS2 file-system online?
Resolution
-
Make sure that underlying storage is seen by all the cluster nodes:
-
Then extend the volume group if the volume group will be grown. Then extend the logical volume. On RHEL 5, 6, and 7 the cluster nodes should be notified when the metadata has been changed on the vg or lv when extending them. On RHEL 8 all the cluster nodes need to manually refresh the LVM metadata to see the changes made by extending the vg or lv with command 'pvscan && vgscan && lvscan'. For more information see the articles below:
- RHEL 5, 6, 7: How to extend a logical volume and its filesystem online in Red Hat Enterprise Linux for RHEL 5, 6, 7? - Ignore
resize2fscommand from this article as it is for extX filesystem. - RHEL 8: GFS2 file systems | 3.5. Growing a GFS2 file system
- RHEL 5, 6, 7: How to extend a logical volume and its filesystem online in Red Hat Enterprise Linux for RHEL 5, 6, 7? - Ignore
-
Before beginning the grow operation on the GFS2 file-system ensure that there is at least 500MB of free space available on the GFS2 file-system that the operation can use. This is a generous amount of space and can be reduced for smaller file-systems if needed. The
gfs2_growneeds to add additional resource groups to manage the new space.gfs2_growdoes this by writing to the rindex file. If there are no free blocks available in the filesystem at its current size, and the last block of the rindex file is too full to add another resource group entry,gfs2_growwill be unable to write out the necessary information for gfs2 to be able to use the new space. When this happens,gfs2_growis unable to grow the filesystem and can damage the filesystem. -
Once the storage stack has been extended(or if there was already enough space) to accommodate the growing of the GFS2 file-system then run the following command:
# gfs2_grow /path/to/mount/point -
After the grow has completed use the following command to verify that the new space is available:
# df /path/to/mount/point -
Example:
# df -h /mnt/test Filesystem Size Used Avail Use% Mounted on /dev/mapper/testvg-testlv 9.0G 67M 9.0G 1% /mnt/test # gfs2_grow -v /dev/mapper/testvg-testlv Trying to get admin lock...locked. Gathering resource group information for /dev/mapper/testvg-testlv FS: Mount point: /mnt/test FS: Device: /dev/mapper/testvg-testlv FS: Size: 2358269 (0x23fbfd) # Filesystem size in pages ( 4 kb per page ) DEV: Length: 2620416 (0x27fc00) # Device size in pages ( 4 kb per page ) The file system will grow by 1024MB. 1 new rindex entries. gfs2_grow complete. # df -h /mnt/test Filesystem Size Used Avail Use% Mounted on /dev/mapper/testvg-testlv 10G 67M 10G 1% /mnt/test
Related Articles
- Growing a gfs2 filesystem with
gfs2_growcaused a kernel panic to occur when there is no free space - How to extend GFS2 file system when multipathing is used and in case it is possible to grow physical volume on SAN side?
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.