• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

The Geek Diary

CONCEPTS | BASICS | HOWTO

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • Linux Services
    • VCS
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
    • Data Guard
  • DevOps
    • Docker
    • Shell Scripting
  • Interview Questions
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

Managing a GFS2 File System – Adding journals, extending and repairing GFS2

By admin

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
Note: The gfs2_tool command from earlier versions of the product is not supported in Red Hat Enterprise Linux 7.

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.

Notes

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.

Note: Before making any changes to a GFS2 superblock, make sure that the file system is not currently mounted on any node.

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 
Beginners Guide to Global File System 2 (GFS2)
How to Create a GFS2 Formatted Cluster File System
How to configure a GFS2 Pacemaker cluster resource

Filed Under: CentOS/RHEL 7, Linux

Some more articles you might also be interested in …

  1. Replacing a Failed Mirror Disk in a Software RAID Array (mdadm)
  2. How to Remove virbr0 and lxcbr0 Interfaces on CentOS/RHEL 6,7
  3. how to add a custom script to the systemd in CentOS/RHEL 7
  4. How to install and Configure VNC (TigerVNC) server in CentOS / RHEL 7
  5. What is the difference between & (ampersand) and && (double ampersand) while executing simultaneous commands on Linux
  6. How To Check Swap Usage of Each Processes in Linux
  7. Linux OS Service ‘avahi-daemon’
  8. How to Use Iperf to Test Network Performance in Linux
  9. How to copy directories recursively using rsync while excluding specific files
  10. CentOS / RHEL 7 : How to open the Firewall port for Samba server using FirewallD

You May Also Like

Primary Sidebar

Recent Posts

  • Failed to start LSB: Bring up/down networking – On restarting network service CentOS/RHEL (DHCP client)
  • How To Add Timestamps To dmesg Kernel Boot Log in CentOS/RHEL
  • How to disable ICMP redirects on CentOS/RHEL
  • What are Oracle Key Vault Roles
  • Archives
  • Contact Us
  • Copyright

© 2021 · The Geek Diary