Global File System 2 (GFS2)
Global File System 2 (GFS2) is a cluster file system interfacing directly with the kernel VFS layer. This means that the same file system can be mounted and used by multiple cluster nodes simultaneously, while still providing a full regular file system, including features such as support for POSIX ACLs, extended attributes, and quotas.
To accomplish this, every node accessing a GFS2 file system uses the cluster infrastructure provided by Corosync and Pacemaker to provide services such as fencing and locking. Each cluster node mounting a GFS2 file system will use a separate journal. If a node fails, one of the other nodes in the cluster will replay the journal for the failed node after the failed node has been fenced. To prevent race conditions between two nodes when accessing the file system, GFS2 uses the Distributed Lock Manager (DLM) to coordinate locks on files and directories.
Adding journals to a GFS2 file system
When trying to mount a GFS2 file system from more nodes than the file system has journals, the error Too many nodes mounting file system, no free journals will occur. To find out how many journals a GFS2 file system has, use the following command:
# gfs2_edit -p jindex /dev/mapper/cluster_vg-gfsdata | grep journal 3/3 [fc7745eb] 1/20 (0x1/0x14): File journal0 4/4 (8b70757d] 2/32859 (0x2/0x805b): File journall
To add more journals, use the gfs2_jadd command. This command takes two options, -j [new_journals] and -J [journalsize_in_MiB], and one argument: a block device containing a GFS2 file system or the mount point of a mounted GFS2 file system.
If no journal size is specified, the default size of 128 MiB will be used. Journals are created by converting free file system space into a journal, so make sure that the file system has enough free space to accommodate the new journals you wish to create.
In the next example, two 64 MiB journals will be added to the GFS2 file system mounted at /gfs:
# gfs2_jadd -j 2 -J 64 /gfs Filesystem: /gfs Old Journals: 3 New Journals: 5
Growing a GFS2 file system
A GFS2 file system can be grown to take advantage of any extra space that might have been added to the clustered logical volume on which the file system lives. Growing a GFS2 file system can be done online, although it is recommended to perform a test run first. To grow a GFS2 file system, use the command gfs2_grow [mountpoint | device_node]. Adding the -T option will enable test mode. Test mode does everything a normal grow operation would, except actually committing changes to disk.
As an example, assume that there is a GFS2 file system on the clustered logical volume /dev/cluster_vg/cluster_lv, mounted on /gfs. The logical volume will first be grown by 10 GiB, and then grow the GFS2 file system to use the newly available space.
# lvextend -L +10G /dev/cluster_vg/cluster_lv
# gfs2_grow -T /gfs (Test mode--File system will not be changed) ... The file system grew by 10 GB. gfs2_grow complete.
# gfs2_grow /gfs
Repairing a GFS2 file system
Under normal circumstances, a GFSZ file system should not require manual repair. When a node fails, the journal for that node will be replaced by another node after the failed node has been fenced, thus ensuring file system integrity.
If for some reason the system is left with a dirty or corrupted GFSZ file system, a normal fsck command can be run on it. The fsck command will recognize the file system as being a GFSZ file system, and call out to the fsck.gfs2 command to do the actual checking. The fsck.gfs2 command can be run directly as well.
The fsck.gfs2 command must be run only on a file system that is unmounted from all nodes. When the file system is being managed as a Pc1cemaker cluster resource, disable the file system resource, which unmounts the file system. After running the fsck.gfs2 command, enable the file system resource again. The timeout value specified with the –wait option of the pcs resource disable command indicates a value in seconds. To ensure that the fsck.gfs2 command does not run on a GfS2 file system at boot time, set the run_fsck parameter of the options argument when creating the GfS2 file system resource in a cluster. Specifying run_fsck=no will indicate that the node should not run the fsck command on resource activation.
Note that the fsck.gfs2 command differs from some earlier releases of gfs2_fsck in the following ways: Pressing Ct rl+C while running the fsck. gfs2 command interrupts processing and displays a prompt asking whether to abort the command, skip the rest of the current pass, or continue processing. Increase the level of verbosity by using the -v option. Adding a second -v option increases the verbosity level again. Decrease the level of verbosity by using the -q option. Adding a second -q option decreases the level again. The -n option opens a file system as read-only and answers no to any queries automatically. The option provides a way of trying the command to reveal errors without actually allowing the fsck.gfs2 command to take effect. Refer to the fsck.gfs2 man page for additional information about other command options.
# man fsck.gfs2
Making superblock changes
If moving a GfS2 file system to a different cluster is desired, or renaming the cluster is needed, the locking table name in your GFS2 superblock will need to be updated.
To request information from a GFS2 superblock, use the command tunegfs2 -l [devicenode]. The command tunegfs2 can be used to modify the locking table and locking protocol as well.
To change one of these options use the following command:
# tunegfs2 -o locktable=[filesystem name] [device]
For example, to change the cluster name for a GFS2 file system called examplegfs that lives on the clustered logical volume /dev/cluster_vg/cluster_lv to newcluster, call this command like this:
# tunegfs2 -o locktable=clustere0:newcluster /dev/cluster_vg/cluster_lv; tune2gfs -l /dev/cluster_vg/cluster_lv tunegfs2 (Jan 16 2015 10:53:28) File system volume name: cluster0:testgfs2 File system UUID: c8fd0a3c-1ad8-bc36-fca0-29eb1c7f2c28 File system magic number: 0x1161970 Block size: 4096 Block Shift: 12 Root inode: 99316 M:aster inode: 32854 Lock protocol: lock_dlm Lock table: cluster0:testgfs2
How to Create a GFS2 Formatted Cluster File System
How to configure a GFS2 Pacemaker cluster resource