Cari di RHE Linux 
    Red Hat Enterprise Linux Manual
Daftar Isi
(Sebelumnya) 5 : Chapter 2. GFS2 Configurat ...5 : Chapter 5. Diagnosing and ... (Berikutnya)

Global File System 2

Chapter 4. Managing GFS2

This chapter describes the tasks and commands for managing GFS2 and consists of the following sections:

4.1. Making a File System

You create a GFS2 file system with the mkfs.gfs2 command. You can also use the mkfs command with the -t gfs2 option specified. A file system is created on an activated LVM volume. The following information is required to run the mkfs.gfs2 command:
  • Lock protocol/module name (the lock protocol for a cluster is lock_dlm)
  • Cluster name (when running as part of a cluster configuration)
  • Number of journals (one journal required for each node that may be mounting the file system)
When creating a GFS2 file system, you can use the mkfs.gfs2 command directly, or you can use the mkfs command with the -t parameter specifying a file system of type gfs2, followed by the gfs2 file system options.

Note

Once you have created a GFS2 file system with the mkfs.gfs2 command, you cannot decrease the size of the file system. You can, however, increase the size of an existing file system with the gfs2_grow command, as described in Section 4.6, "Growing a File System".

Usage

When creating a clustered GFS2 file system, you can use either of the following formats:
mkfs.gfs2 -p LockProtoName -t LockTableName -j NumberJournals BlockDevice
mkfs -t gfs2 -p LockProtoName -t LockTableName -j NumberJournals BlockDevice
When creating a local GFS2 file system, you can use either of the following formats:

Note

For the Red Hat Enterprise Linux 6 release, Red Hat does not support the use of GFS2 as a single-node file system.
mkfs.gfs2 -p LockProtoName -j NumberJournals BlockDevice
mkfs -t gfs2 -p LockProtoName -j NumberJournals BlockDevice

Warning

Make sure that you are very familiar with using the LockProtoName and LockTableName parameters. Improper use of the LockProtoName and LockTableName parameters may cause file system or lock space corruption.
LockProtoName
Specifies the name of the locking protocol to use. The lock protocol for a cluster is lock_dlm.
LockTableName
This parameter is specified for GFS2 file system in a cluster configuration. It has two parts separated by a colon (no spaces) as follows: ClusterName:FSName
  • ClusterName, the name of the cluster for which the GFS2 file system is being created.
  • FSName, the file system name, can be 1 to 16 characters long. The name must be unique for all lock_dlm file systems over the cluster, and for all file systems (lock_dlm and lock_nolock) on each local node.
Number
Specifies the number of journals to be created by the mkfs.gfs2 command. One journal is required for each node that mounts the file system. For GFS2 file systems, more journals can be added later without growing the file system, as described in Section 4.7, "Adding Journals to a File System".
BlockDevice
Specifies a logical or physical volume.

Examples

In these example, lock_dlm is the locking protocol that the file system uses, since this is a clustered file system. The cluster name is alpha, and the file system name is mydata1. The file system contains eight journals and is created on /dev/vg01/lvol0.
mkfs.gfs2 -p lock_dlm -t alpha:mydata1 -j 8 /dev/vg01/lvol0
mkfs -t gfs2 -p lock_dlm -t alpha:mydata1 -j 8 /dev/vg01/lvol0
In these examples, a second lock_dlm file system is made, which can be used in cluster alpha. The file system name is mydata2. The file system contains eight journals and is created on /dev/vg01/lvol1.
mkfs.gfs2 -p lock_dlm -t alpha:mydata2 -j 8 /dev/vg01/lvol1
mkfs -t gfs2 -p lock_dlm -t alpha:mydata2 -j 8 /dev/vg01/lvol1

Complete Options

Table 4.1, "Command Options: mkfs.gfs2" describes the mkfs.gfs2 command options (flags and parameters).

Table 4.1. Command Options: mkfs.gfs2

FlagParameterDescription
-cMegabytesSets the initial size of each journal's quota change file to Megabytes.
-DEnables debugging output.
-hHelp. Displays available options.
-JMegaBytesSpecifies the size of the journal in megabytes. Default journal size is 128 megabytes. The minimum size is 8 megabytes. Larger journals improve performance, although they use more memory than smaller journals.
-jNumberSpecifies the number of journals to be created by the mkfs.gfs2 command. One journal is required for each node that mounts the file system. If this option is not specified, one journal will be created. For GFS2 file systems, you can add additional journals at a later time without growing the file system.
-OPrevents the mkfs.gfs2 command from asking for confirmation before writing the file system.
-pLockProtoName
Specifies the name of the locking protocol to use. Recognized locking protocols include:
lock_dlm - The standard locking module, required for a clustered file system.
lock_nolock - Used when GFS2 is acting as a local file system (one node only).
-qQuiet. Do not display anything.
-rMegaBytesSpecifies the size of the resource groups in megabytes. The minimum resource group size is 32 MB. The maximum resource group size is 2048 MB. A large resource group size may increase performance on very large file systems. If this is not specified, mkfs.gfs2 chooses the resource group size based on the size of the file system: average size file systems will have 256 MB resource groups, and bigger file systems will have bigger RGs for better performance.
-tLockTableName
A unique identifier that specifies the lock table field when you use the lock_dlm protocol; the lock_nolock protocol does not use this parameter.
This parameter has two parts separated by a colon (no spaces) as follows: ClusterName:FSName.
ClusterName is the name of the cluster for which the GFS2 file system is being created; only members of this cluster are permitted to use this file system. The cluster name is set in the /etc/cluster/cluster.conf file via the Cluster Configuration Tool and displayed at the Cluster Status Tool in the Red Hat Cluster Suite cluster management GUI.
FSName, the file system name, can be 1 to 16 characters in length, and the name must be unique among all file systems in the cluster.
-uMegaBytesSpecifies the initial size of each journal's unlinked tag file.
-VDisplays command version information.

4.2. Mounting a File System

Before you can mount a GFS2 file system, the file system must exist (refer to Section 4.1, "Making a File System"), the volume where the file system exists must be activated, and the supporting clustering and locking systems must be started (refer to Configuring and Managing a Red Hat Cluster). After those requirements have been met, you can mount the GFS2 file system as you would any Linux file system.

Note

Attempting to mount a GFS2 file system when the Cluster Manager (cman) has not been started produces the following error message:
[root@gfs-a24c-01 ~]# mount -t gfs2 -o noatime /dev/mapper/mpathap1 /mntgfs_controld join connect error: Connection refusederror mounting lockproto lock_dlm
To manipulate file ACLs, you must mount the file system with the -o acl mount option. If a file system is mounted without the -o acl mount option, users are allowed to view ACLs (with getfacl), but are not allowed to set them (with setfacl).

Usage

Mounting Without ACL Manipulation
mount BlockDevice MountPoint
Mounting With ACL Manipulation
mount -o acl BlockDevice MountPoint
-o acl
GFS2-specific option to allow manipulating file ACLs.
BlockDevice
Specifies the block device where the GFS2 file system resides.
MountPoint
Specifies the directory where the GFS2 file system should be mounted.

Example

In this example, the GFS2 file system on /dev/vg01/lvol0 is mounted on the /mygfs2 directory.
mount /dev/vg01/lvol0 /mygfs2

Complete Usage

mount BlockDevice MountPoint -o option
The -o option argument consists of GFS2-specific options (refer to Table 4.2, "GFS2-Specific Mount Options") or acceptable standard Linux mount -o options, or a combination of both. Multiple option parameters are separated by a comma and no spaces.

Note

The mount command is a Linux system command. In addition to using GFS2-specific options described in this section, you can use other, standard, mount command options (for example, -r). For information about other Linux mount command options, see the Linux mount man page.
Table 4.2, "GFS2-Specific Mount Options" describes the available GFS2-specific -o option values that can be passed to GFS2 at mount time.

Note

This table includes descriptions of options that are used with local file systems only. Note, however, that for the Red Hat Enterprise Linux 6 release, Red Hat does not support the use of GFS2 as a single-node file system. Red Hat will continue to support single-node GFS2 file systems for mounting snapshots of cluster file systems (for example, for backup purposes).

Table 4.2. GFS2-Specific Mount Options

OptionDescription
aclAllows manipulating file ACLs. If a file system is mounted without the acl mount option, users are allowed to view ACLs (with getfacl), but are not allowed to set them (with setfacl).
data=[ordered|writeback]When data=ordered is set, the user data modified by a transaction is flushed to the disk before the transaction is committed to disk. This should prevent the user from seeing uninitialized blocks in a file after a crash. When data=writeback mode is set, the user data is written to the disk at any time after it is dirtied; this does not provide the same consistency guarantee as ordered mode, but it should be slightly faster for some workloads. The default value is ordered mode.
ignore_local_fs
Caution: This option should not be used when GFS2 file systems are shared.
Forces GFS2 to treat the file system as a multihost file system. By default, using lock_nolock automatically turns on the localflocks flag.
localflocks
Caution: This option should not be used when GFS2 file systems are shared.
Tells GFS2 to let the VFS (virtual file system) layer do all flock and fcntl. The localflocks flag is automatically turned on by lock_nolock.
lockproto=LockModuleNameAllows the user to specify which locking protocol to use with the file system. If LockModuleName is not specified, the locking protocol name is read from the file system superblock.
locktable=LockTableNameAllows the user to specify which locking table to use with the file system.
quota=[off/account/on]Turns quotas on or off for a file system. Setting the quotas to be in the account state causes the per UID/GID usage statistics to be correctly maintained by the file system; limit and warn values are ignored. The default value is off.
errors=panic|withdrawWhen errors=panic is specified, file system errors will cause a kernel panic. The default behavior, which is the same as specifying errors=withdraw, is for the system to withdraw from the file system and make it inaccessible until the next reboot; in some cases the system may remain running. For information on the GFS2 withdraw function, see Section 4.14, "The GFS2 Withdraw Function".
discard/nodiscardCauses GFS2 to generate "discard" I/O requests for blocks that have been freed. These can be used by suitable hardware to implement thin provisioning and similar schemes.
barrier/nobarrierCauses GFS2 to send I/O barriers when flushing the journal. The default value is on. This option is automatically turned off if the underlying device does not support I/O barriers. Use of I/O barriers with GFS2 is highly recommended at all times unless the block device is designed so that it cannot lose its write cache content (for example, if it is on a UPS or it does not have a write cache).
quota_quantum=secsSets the number of seconds for which a change in the quota information may sit on one node before being written to the quota file. This is the preferred way to set this parameter. The value is an integer number of seconds greater than zero. The default is 60 seconds. Shorter settings result in faster updates of the lazy quota information and less likelihood of someone exceeding their quota. Longer settings make file system operations involving quotas faster and more efficient.
statfs_quantum=secsSetting statfs_quantum to 0 is the preferred way to set the slow version of statfs. The default value is 30 secs which sets the maximum time period before statfs changes will be synced to the master statfs file. This can be adjusted to allow for faster, less accurate statfs values or slower more accurate values. When this option is set to 0, statfs will always report the true values.
statfs_percent=valueProvides a bound on the maximum percentage change in the statfs information on a local basis before it is synced back to the master statfs file, even if the time period has not expired. If the setting of statfs_quantum is 0, then this setting is ignored.

4.3. Unmounting a File System

The GFS2 file system can be unmounted the same way as any Linux file system - by using the umount command.

Note

The umount command is a Linux system command. Information about this command can be found in the Linux umount command man pages.

Usage

umount MountPoint
MountPoint
Specifies the directory where the GFS2 file system is currently mounted.

4.4. Special Considerations when Mounting GFS2 File Systems

GFS2 file systems that have been mounted manually rather than automatically through an entry in the fstab file will not be known to the system when file systems are unmounted at system shutdown. As a result, the GFS2 script will not unmount the GFS2 file system. After the GFS2 shutdown script is run, the standard shutdown process kills off all remaining user processes, including the cluster infrastructure, and tries to unmount the file system. This unmount will fail without the cluster infrastructure and the system will hang.
To prevent the system from hanging when the GFS2 file systems are unmounted, you should do one of the following:
  • Always use an entry in the fstab file to mount the GFS2 file system.
  • If a GFS2 file system has been mounted manually with the mount command, be sure to unmount the file system manually with the umount command before rebooting or shutting down the system.
If your file system hangs while it is being unmounted during system shutdown under these circumstances, perform a hardware reboot. It is unlikely that any data will be lost since the file system is synced earlier in the shutdown process.

4.5. GFS2 Quota Management

File-system quotas are used to limit the amount of file system space a user or group can use. A user or group does not have a quota limit until one is set. When a GFS2 file system is mounted with the quota=on or quota=account option, GFS2 keeps track of the space used by each user and group even when there are no limits in place. GFS2 updates quota information in a transactional way so system crashes do not require quota usages to be reconstructed.
To prevent a performance slowdown, a GFS2 node synchronizes updates to the quota file only periodically. The fuzzy quota accounting can allow users or groups to slightly exceed the set limit. To minimize this, GFS2 dynamically reduces the synchronization period as a hard quota limit is approached.

Note

As of the Red Hat Enterprise Linux 6.1 release, GFS2 supports the standard Linux quota facilities. In order to use this you will need to install the quota RPM. This is the preferred way to administer quotas on GFS2 and should be used for all new deployments of GFS2 using quotas. This section documents GFS2 quota management using these facilities.
For earlier releases of Red Hat Enterprise Linux, GFS2 required the gfs2_quota command to manage quotas. For information on using the gfs2_quota command, see Appendix A, GFS2 Quota Management with the gfs2_quota Command.

4.5.1. Configuring Disk Quotas

To implement disk quotas, use the following steps:
  1. Set up quotas in enforcement or accounting mode.
  2. Initialize the quota database file with current block usage information.
  3. Assign quota policies. (In accounting mode, these policies are not enforced.)
Each of these steps is discussed in detail in the following sections.

4.5.1.1. Setting Up Quotas in Enforcement or Accounting Mode

In GFS2 file systems, quotas are disabled by default. To enable quotas for a file system, mount the file system with the quota=on option specified.
It is possible to keep track of disk usage and maintain quota accounting for every user and group without enforcing the limit and warn values. To do this, mount the file system with the quota=account option specified.

Usage

To mount a file system with quotas enabled, mount the file system with the quota=on option specified.
mount -o quota=on BlockDevice MountPoint
To mount a file system with quota accounting maintained, even though the quota limits are not enforced, mount the file system with the quota=account option specified.
mount -o quota=account BlockDevice MountPoint
To mount a file system with quotas disabled, mount the file system with the quota=off option specified. This is the default setting.
mount -o quota=off BlockDevice MountPoint
quota={on|off|account}
on - Specifies that quotas are enabled when the file system is mounted.
off - Specifies that quotas are disabled when the file system is mounted.
account - Specifies that user and group usage statistics are maintained by the file system, even though the quota limits are not enforced.
BlockDevice
Specifies the block device where the GFS2 file system resides.
MountPoint
Specifies the directory where the GFS2 file system should be mounted.

Examples

In this example, the GFS2 file system on /dev/vg01/lvol0 is mounted on the /mygfs2 directory with quotas enabled.
mount -o quota=on /dev/vg01/lvol0 /mygfs2
In this example, the GFS2 file system on /dev/vg01/lvol0 is mounted on the /mygfs2 directory with quota accounting maintained, but not enforced.
mount -o quota=account /dev/vg01/lvol0 /mygfs2

4.5.1.2. Creating the Quota Database Files

After each quota-enabled file system is mounted, the system is capable of working with disk quotas. However, the file system itself is not yet ready to support quotas. The next step is to run the quotacheck command.
The quotacheck command examines quota-enabled file systems and builds a table of the current disk usage per file system. The table is then used to update the operating system's copy of disk usage. In addition, the file system's disk quota files are updated.
To create the quota files on the file system, use the -u and the -g options of the quotacheck command; both of these options must be specified for user and group quotas to be initialized. For example, if quotas are enabled for the /home file system, create the files in the /home directory:
quotacheck -ug /home

4.5.1.3. Assigning Quotas per User

The last step is assigning the disk quotas with the edquota command. Note that if you have mounted your file system in accounting mode (with the quota=account option specified), the quotas are not enforced.
To configure the quota for a user, as root in a shell prompt, execute the command:
edquota username
Perform this step for each user who needs a quota. For example, if a quota is enabled in /etc/fstab for the /home partition (/dev/VolGroup00/LogVol02 in the example below) and the command edquota testuser is executed, the following is shown in the editor configured as the default for the system:
Disk quotas for user testuser (uid 501):   Filesystem blocks soft hard inodes   soft   hard/dev/VolGroup00/LogVol02  440436 0 0

Note

The text editor defined by the EDITOR environment variable is used by edquota. To change the editor, set the EDITOR environment variable in your ~/.bash_profile file to the full path of the editor of your choice.
The first column is the name of the file system that has a quota enabled for it. The second column shows how many blocks the user is currently using. The next two columns are used to set soft and hard block limits for the user on the file system.
The soft block limit defines the maximum amount of disk space that can be used.
The hard block limit is the absolute maximum amount of disk space that a user or group can use. Once this limit is reached, no further disk space can be used.
The GFS2 file system does not maintain quotas for inodes, so these columns do not apply to GFS2 file systems and will be blank.
If any of the values are set to 0, that limit is not set. In the text editor, change the desired limits. For example:
Disk quotas for user testuser (uid 501):   Filesystem blocks soft hard inodes   soft   hard/dev/VolGroup00/LogVol02  440436   500000   550000
To verify that the quota for the user has been set, use the command:
quota testuser

4.5.1.4. Assigning Quotas per Group

Quotas can also be assigned on a per-group basis. Note that if you have mounted your file system in accounting mode (with the account=on option specified), the quotas are not enforced.
To set a group quota for the devel group (the group must exist prior to setting the group quota), use the following command:
edquota -g devel
This command displays the existing quota for the group in the text editor:
Disk quotas for group devel (gid 505):   Filesystem blocks soft hard inodes   soft   hard/dev/VolGroup00/LogVol02  440400   0 0
The GFS2 file system does not maintain quotas for inodes, so these columns do not apply to GFS2 file systems and will be blank. Modify the limits, then save the file.
To verify that the group quota has been set, use the following command:
quota -g devel

4.5.2. Managing Disk Quotas

If quotas are implemented, they need some maintenance - mostly in the form of watching to see if the quotas are exceeded and making sure the quotas are accurate.
Of course, if users repeatedly exceed their quotas or consistently reach their soft limits, a system administrator has a few choices to make depending on what type of users they are and how much disk space impacts their work. The administrator can either help the user determine how to use less disk space or increase the user's disk quota.
You can create a disk usage report by running the repquota utility. For example, the command repquota /home produces this output:
*** Report for user quotas on device /dev/mapper/VolGroup00-LogVol02 Block grace time: 7days; Inode grace time: 7daysBlock limitsFile limitsUserusedsofthardgraceusedsofthardgrace ---------------------------------------------------------------------- root  --  36   0   0  4 0 0 kristin   -- 540   0   0 125 0 0 testuser  --  440400  500000  550000  37418 0 0
To view the disk usage report for all (option -a) quota-enabled file systems, use the command:
repquota -a
While the report is easy to read, a few points should be explained. The -- displayed after each user is a quick way to determine whether the block limits have been exceeded. If the block soft limit is exceeded, a + appears in place of the the first - in the output. The second - indicates the inode limit, but GFS2 file systems do not support inode limits so that character will remain as -. GFS2 file systems do not support a grace period, so the grace column will remain blank.
Note that the repquota command is not supported over NFS, irrespective of the underlying file system.

4.5.3. Keeping Quotas Accurate

If you enable quotas on your file system after a period of time when you have been running with quotas disabled, you should run the quotacheck command to create, check, and repair quota files. Additionally, you may want to run the quotacheck if you think your quota files may not be accurate, as may occur when a file system is not unmounted cleanly after a system crash.
For more information about the quotacheck command, see the quotacheck man page.

Note

Run quotacheck when the file system is relatively idle on all nodes because disk activity may affect the computed quota values.

4.5.4. Synchronizing Quotas with the quotasync Command

GFS2 stores all quota information in its own internal file on disk. A GFS2 node does not update this quota file for every file system write; rather, by default it updates the quota file once every 60 seconds. This is necessary to avoid contention among nodes writing to the quota file, which would cause a slowdown in performance.
As a user or group approaches their quota limit, GFS2 dynamically reduces the time between its quota-file updates to prevent the limit from being exceeded. The normal time period between quota synchronizations is a tunable parameter, quota_quantum. You can change this from its default value of 60 seconds using the quota_quantum= mount option, as described in Table 4.2, "GFS2-Specific Mount Options". The quota_quantum parameter must be set on each node and each time the file system is mounted. Changes to the quota_quantum parameter are not persistent across unmounts. You can update the quota_quantum value with the mount -o remount.
You can use the quotasync command to synchronize the quota information from a node to the on-disk quota file between the automatic updates performed by GFS2.

Usage

Synchronizing Quota Information
quotasync [-ug] -a|mntpnt...
u
Sync the user quota files.
g
Sync the group quota files
a
Sync all file systems that are currently quota-enabled and support sync. When -a is absent, a file system mountpoint should be specified.
mntpnt
Specifies the GFS2 file system to which the actions apply.
Tuning the Time Between Synchronizations
mount -o quota_quantum=secs,remount BlockDevice MountPoint
MountPoint
Specifies the GFS2 file system to which the actions apply.
secs
Specifies the new time period between regular quota-file synchronizations by GFS2. Smaller values may increase contention and slow down performance.

Examples

This example synchronizes all the cached dirty quotas from the node it is run on to the ondisk quota file for the file system /mnt/mygfs2.
# quotasync -ug /mnt/mygfs2
This example changes the default time period between regular quota-file updates to one hour (3600 seconds) for file system /mnt/mygfs2 when remounting that file system on logical volume /dev/volgroup/logical_volume.
# mount -o quota_quantum=3600,remount /dev/volgroup/logical_volume /mnt/mygfs2

4.5.5. References

For more information on disk quotas, refer to the man pages of the following commands:
  • quotacheck
  • edquota
  • repquota
  • quota

4.6. Growing a File System

The gfs2_grow command is used to expand a GFS2 file system after the device where the file system resides has been expanded. Running a gfs2_grow command on an existing GFS2 file system fills all spare space between the current end of the file system and the end of the device with a newly initialized GFS2 file system extension. When the fill operation is completed, the resource index for the file system is updated. All nodes in the cluster can then use the extra storage space that has been added.
The gfs2_grow command must be run on a mounted file system, but only needs to be run on one node in a cluster. All the other nodes sense that the expansion has occurred and automatically start using the new space.

Note

Once you have created a GFS2 file system with the mkfs.gfs2 command, you cannot decrease the size of the file system.

Usage

gfs2_grow MountPoint
MountPoint
Specifies the GFS2 file system to which the actions apply.

Comments

Before running the gfs2_grow command:
  • Back up important data on the file system.
  • Determine the volume that is used by the file system to be expanded by running a df MountPoint command.
  • Expand the underlying cluster volume with LVM. For information on administering LVM volumes, see Logical Volume Manager Administration.
After running the gfs2_grow command, run a df command to check that the new space is now available in the file system.

Examples

In this example, the file system on the /mygfs2fs directory is expanded.
[root@dash-01 ~]# gfs2_grow /mygfs2fsFS: Mount Point: /mygfs2fsFS: Device:  /dev/mapper/gfs2testvg-gfs2testlvFS: Size: 524288 (0x80000)FS: RG size: 65533 (0xfffd)DEV: Size:   655360 (0xa0000)The file system grew by 512MB.gfs2_grow complete.

Complete Usage

gfs2_grow [Options] {MountPoint | Device} [MountPoint | Device]
MountPoint
Specifies the directory where the GFS2 file system is mounted.
Device
Specifies the device node of the file system.
Table 4.3, "GFS2-specific Options Available While Expanding A File System" describes the GFS2-specific options that can be used while expanding a GFS2 file system.

Table 4.3. GFS2-specific Options Available While Expanding A File System

OptionDescription
-hHelp. Displays a short usage message.
-qQuiet. Turns down the verbosity level.
-r MegaBytesSpecifies the size of the new resource group. The default size is 256MB.
-TTest. Do all calculations, but do not write any data to the disk and do not expand the file system.
-VDisplays command version information.

4.7. Adding Journals to a File System

The gfs2_jadd command is used to add journals to a GFS2 file system. You can add journals to a GFS2 file system dynamically at any point without expanding the underlying logical volume. The gfs2_jadd command must be run on a mounted file system, but it needs to be run on only one node in the cluster. All the other nodes sense that the expansion has occurred.

Note

If a GFS2 file system is full, the gfs2_jadd will fail, even if the logical volume containing the file system has been extended and is larger than the file system. This is because in a GFS2 file system, journals are plain files rather than embedded metadata, so simply extending the underlying logical volume will not provide space for the journals.
Before adding journals to a GFS file system, you can use the journals option of the gfs2_tool to find out how many journals the GFS2 file system currently contains. The following example displays the number and size of the journals in the file system mounted at /mnt/gfs2.
[root@roth-01 ../cluster/gfs2]# gfs2_tool journals /mnt/gfs2journal2 - 128MBjournal1 - 128MBjournal0 - 128MB3 journal(s) found.

Usage

gfs2_jadd -j Number MountPoint
Number
Specifies the number of new journals to be added.
MountPoint
Specifies the directory where the GFS2 file system is mounted.

Examples

In this example, one journal is added to the file system on the /mygfs2 directory.
gfs2_jadd -j1 /mygfs2
In this example, two journals are added to the file system on the /mygfs2 directory.
gfs2_jadd -j2 /mygfs2

Complete Usage

gfs2_jadd [Options] {MountPoint | Device} [MountPoint | Device]
MountPoint
Specifies the directory where the GFS2 file system is mounted.
Device
Specifies the device node of the file system.
Table 4.4, "GFS2-specific Options Available When Adding Journals" describes the GFS2-specific options that can be used when adding journals to a GFS2 file system.

Table 4.4. GFS2-specific Options Available When Adding Journals

FlagParameterDescription
-hHelp. Displays short usage message.
-JMegaBytesSpecifies the size of the new journals in megabytes. Default journal size is 128 megabytes. The minimum size is 32 megabytes. To add journals of different sizes to the file system, the gfs2_jadd command must be run for each size journal. The size specified is rounded down so that it is a multiple of the journal-segment size that was specified when the file system was created.
-jNumberSpecifies the number of new journals to be added by the gfs2_jadd command. The default value is 1.
-qQuiet. Turns down the verbosity level.
-VDisplays command version information.

4.8. Data Journaling

Ordinarily, GFS2 writes only metadata to its journal. File contents are subsequently written to disk by the kernel's periodic sync that flushes file system buffers. An fsync() call on a file causes the file's data to be written to disk immediately. The call returns when the disk reports that all data is safely written.
Data journaling can result in a reduced fsync() time for very small files because the file data is written to the journal in addition to the metadata. This advantage rapidly reduces as the file size increases. Writing to medium and larger files will be much slower with data journaling turned on.
Applications that rely on fsync() to sync file data may see improved performance by using data journaling. Data journaling can be enabled automatically for any GFS2 files created in a flagged directory (and all its subdirectories). Existing files with zero length can also have data journaling turned on or off.
Enabling data journaling on a directory sets the directory to "inherit jdata", which indicates that all files and directories subsequently created in that directory are journaled. You can enable and disable data journaling on a file with the chattr command.
The following commands enable data journaling on the /mnt/gfs2/gfs2_dir/newfile file and then check whether the flag has been set properly.
[root@roth-01 ~]# chattr +j /mnt/gfs2/gfs2_dir/newfile[root@roth-01 ~]# lsattr /mnt/gfs2/gfs2_dir---------j--- /mnt/gfs2/gfs2_dir/newfile
The following commands disable data journaling on the /mnt/gfs2/gfs2_dir/newfile file and then check whether the flag has been set properly.
[root@roth-01 ~]# chattr -j /mnt/gfs2/gfs2_dir/newfile[root@roth-01 ~]# lsattr /mnt/gfs2/gfs2_dir------------- /mnt/gfs2/gfs2_dir/newfile
You can also use the chattr command to set the j flag on a directory. When you set this flag for a directory, all files and directories subsequently created in that directory are journaled. The following set of commands sets the j flag on the gfs2_dir directory, then checks whether the flag has been set properly. After this, the commands create a new file called newfile in the /mnt/gfs2/gfs2_dir directory and then check whether the j flag has been set for the file. Since the j flag is set for the directory, then newfile should also have journaling enabled.
[root@roth-01 ~]# chattr -j /mnt/gfs2/gfs2_dir[root@roth-01 ~]# lsattr /mnt/gfs2---------j--- /mnt/gfs2/gfs2_dir[root@roth-01 ~]# touch /mnt/gfs2/gfs2_dir/newfile[root@roth-01 ~]# lsattr /mnt/gfs2/gfs2_dir---------j--- /mnt/gfs2/gfs2_dir/newfile

4.9. Configuring atime Updates

Each file inode and directory inode has three time stamps associated with it:
  • ctime - The last time the inode status was changed
  • mtime - The last time the file (or directory) data was modified
  • atime - The last time the file (or directory) data was accessed
If atime updates are enabled as they are by default on GFS2 and other Linux file systems then every time a file is read, its inode needs to be updated.
Because few applications use the information provided by atime, those updates can require a significant amount of unnecessary write traffic and file locking traffic. That traffic can degrade performance; therefore, it may be preferable to turn off or reduce the frequency of atime updates.
Two methods of reducing the effects of atime updating are available:
  • Mount with relatime (relative atime), which updates the atime if the previous atime update is older than the mtime or ctime update.
  • Mount with noatime, which disables atime updates on that file system.

4.9.1. Mount with relatime

The relatime (relative atime) Linux mount option can be specified when the file system is mounted. This specifies that the atime is updated if the previous atime update is older than the mtime or ctime update.

Usage

mount  BlockDevice MountPoint -o relatime
BlockDevice
Specifies the block device where the GFS2 file system resides.
MountPoint
Specifies the directory where the GFS2 file system should be mounted.

Example

In this example, the GFS2 file system resides on the /dev/vg01/lvol0 and is mounted on directory /mygfs2. The atime updates take place only if the previous atime update is older than the mtime or ctime update.
mount /dev/vg01/lvol0 /mygfs2 -o relatime

4.9.2. Mount with noatime

The noatime Linux mount option can be specified when the file system is mounted, which disables atime updates on that file system.

Usage

mount BlockDevice MountPoint -o noatime
BlockDevice
Specifies the block device where the GFS2 file system resides.
MountPoint
Specifies the directory where the GFS2 file system should be mounted.

Example

In this example, the GFS2 file system resides on the /dev/vg01/lvol0 and is mounted on directory /mygfs2 with atime updates turned off.
mount /dev/vg01/lvol0 /mygfs2 -o noatime

4.10. Suspending Activity on a File System

You can suspend write activity to a file system by using the dmsetup suspend command. Suspending write activity allows hardware-based device snapshots to be used to capture the file system in a consistent state. The dmsetup resume command ends the suspension.

Usage

Start Suspension
dmsetup suspend MountPoint
End Suspension
dmsetup resume MountPoint
MountPoint
Specifies the file system.

Examples

This example suspends writes to file system /mygfs2.
# dmsetup suspend /mygfs2
This example ends suspension of writes to file system /mygfs2.
# dmsetup resume /mygfs2

4.11. Repairing a File System

When nodes fail with the file system mounted, file system journaling allows fast recovery. However, if a storage device loses power or is physically disconnected, file system corruption may occur. (Journaling cannot be used to recover from storage subsystem failures.) When that type of corruption occurs, you can recover the GFS2 file system by using the fsck.gfs2 command.

Important

The fsck.gfs2 command must be run only on a file system that is unmounted from all nodes.

Important

You should not check a GFS2 file system at boot time with the fsck.gfs2 command. The fsck.gfs2 command can not determine at boot time whether the file system is mounted by another node in the cluster. You should run the fsck.gfs2 command manually only after the system boots.
To ensure that the fsck.gfs2 command does not run on a GFS2 file system at boot time, modify the /etc/fstab file so that the final two columns for a GFS2 file system mount point show "0 0" rather than "1 1" (or any other numbers), as in the following example:
/dev/VG12/lv_svr_home   /svr_home   gfs2 defaults,noatime,nodiratime,noquota 0 0

Note

If you have previous experience using the gfs_fsck command on GFS file systems, note that the fsck.gfs2 command differs from some earlier releases of gfs_fsck in the in the following ways:
  • Pressing Ctrl+C while running the fsck.gfs2 interrupts processing and displays a prompt asking whether you would like to abort the command, skip the rest of the current pass, or continue processing.
  • You can increase the level of verbosity by using the -v flag. Adding a second -v flag increases the level again.
  • You can decrease the level of verbosity by using the -q flag. Adding a second -q flag 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.
Running the fsck.gfs2 command requires system memory above and beyond the memory used for the operating system and kernel. Each block of memory in the GFS2 file system itself requires approximately five bits of additional memory, or 5/8 of a byte. So to estimate how many bytes of memory you will need to run the fsck.gfs2 command on your file system, determine how many blocks the file system contains and multiply that number by 5/8.
For example, to determine approximately how much memory is required to run the fsck.gfs2 command on a GFS2 file system that is 16TB with a block size of 4K, first determine how many blocks of memory the file system contains by dividing 16Tb by 4K:
 17592186044416 / 4096 = 4294967296
Since this file system contains 4294967296 blocks, multiply that number by 5/8 to determine how many bytes of memory are required:
4294967296 * 5/8 = 2684354560
This file system requires approximately 2.6GB of free memory to run the fsck.gfs2 command. Note that if the block size was 1K, running the fsck.gfs2 command would require four times the memory, or approximately 11GB.

Usage

fsck.gfs2 -y BlockDevice
-y
The -y flag causes all questions to be answered with yes. With the -y flag specified, the fsck.gfs2 command does not prompt you for an answer before making changes.
BlockDevice
Specifies the block device where the GFS2 file system resides.

Example

In this example, the GFS2 file system residing on block device /dev/testvol/testlv is repaired. All queries to repair are automatically answered with yes.
[root@dash-01 ~]# fsck.gfs2 -y /dev/testvg/testlvInitializing fsckValidating Resource Group index.Level 1 RG check.(level 1 passed)Clearing journals (this may take a while)...Journals cleared.Starting pass1Pass1 completeStarting pass1bPass1b completeStarting pass1cPass1c completeStarting pass2Pass2 completeStarting pass3Pass3 completeStarting pass4Pass4 completeStarting pass5Pass5 completeWriting changes to diskfsck.gfs2 complete

4.12. Bind Mounts and Context-Dependent Path Names

GFS2 file systems do not provide support for Context-Dependent Path Names (CDPNs), which allow you to create symbolic links that point to variable destination files or directories. For this functionality in GFS2, you can use the bind option of the mount command.
The bind option of the mount command allows you to remount part of a file hierarchy at a different location while it is still available at the original location. The format of this command is as follows.
mount --bind olddir newdir
After executing this command, the contents of the olddir directory are available at two locations: olddir and newdir. You can also use this option to make an individual file available at two locations.
For example, after executing the following commands the contents of /root/tmp will be identical to the contents of the previously mounted /var/log directory.
[root@menscryfa ~]# cd ~root[root@menscryfa ~]# mkdir ./tmp[root@menscryfa ~]# mount --bind /var/log /root/tmp
Alternately, you can use an entry in the /etc/fstab file to achieve the same results at mount time. The following /etc/fstab entry will result in the contents of /root/tmp being identical to the contents of the /var/log directory.
/var/log /root/tmp   none bind 0 0
After you have mounted the file system, you can use the mount command to see that the file system has been mounted, as in the following example.
[root@menscryfa ~]# mount | grep /tmp/var/log on /root/tmp type none (rw,bind)
With a file system that supports Context-Dependent Path Names, you might have defined the /bin directory as a Context-Dependent Path Name that would resolve to one of the following paths, depending on the system architecture.
/usr/i386-bin/usr/x86_64-bin/usr/ppc64-bin
You can achieve this same functionality by creating an empty /bin directory. Then, using a script or an entry in the /etc/fstab file, you can mount each of the individual architecture directories onto the /bin directory with a mount -bind command. For example, you can use the following command as a line in a script.
mount --bind /usr/i386-bin /bin
Alternately, you can use the following entry in the /etc/fstab file.
/usr/1386-bin /bin   none bind 0 0
A bind mount can provide greater flexibility than a Context-Dependent Path Name, since you can use this feature to mount different directories according to any criteria you define (such as the value of %fill for the file system). Context-Dependent Path Names are more limited in what they can encompass. Note, however, that you will need to write your own script to mount according to a criteria such as the value of %fill.

Warning

When you mount a file system with the bind option and the original file system was mounted rw, the new file system will also be mounted rw even if you use the ro flag; the ro flag is silently ignored. In this case, the new file system might be marked as ro in the /proc/mounts directory, which may be misleading.

4.13. Bind Mounts and File System Mount Order

When you use the bind option of the mount command, you must be sure that the file systems are mounted in the correct order. In the following example, the /var/log directory must be mounted before executing the bind mount on the /tmp directory:
# mount --bind /var/log /tmp
The ordering of file system mounts is determined as follows:
  • In general, file system mount order is determined by the order in which the file systems appear in the fstab file. The exceptions to this ordering are file systems mounted with the _netdev flag or file systems that have their own init scripts.
  • A file system with its own init script is mounted later in the initialization process, after the file systems in the fstab file.
  • File systems mounted with the _netdev flag are mounted when the network has been enabled on the system.
If your configuration requires that you create a bind mount on which to mount a GFS2 file system, you can order your fstab file as follows:
  1. Mount local file systems that are required for the bind mount.
  2. Bind mount the directory on which to mount the GFS2 file system.
  3. Mount the GFS2 file system.
If your configuration requires that you bind mount a local directory or file system onto a GFS2 file system, listing the file systems in the correct order in the fstab file will not mount the file systems correctly since the GFS2 file system will not be mounted until the GFS2 init script is run. In this case, you should write an init script to execute the bind mount so that the bind mount will not take place until after the GFS2 file system is mounted.
The following script is an example of a custom init script. This script performs a bind mount of two directories onto two directories of a GFS2 file system. In this example, there is an existing GFS2 mount point at /mnt/gfs2a, which is mounted when the GFS2 init script runs, after cluster startup.
In this example script, the values of the chkconfig statement indicate the following:
  • 345 indicates the run levels that the script will be started in
  • 29 is the start priority, which in this case indicates that the script will run at startup time after the GFS2 init script, which has a start priority of 26
  • 73 is the stop priority, which in this case indicates that the script will be stopped during shutdown before the GFS2 script, which has a stop priority of 74
The start and stop values indicate that you can manually perform the indicated action by executing a service start and a service stop command. For example, if the script is named fredwilma, then you can execute service fredwilma start.
This script should be put in the /etc/init.d directory with the same permissions as the other scripts in that directory. You can then execute a chkconfig on command to link the script to the indicated run levels. For example, if the script is named fredwilma, then you can execute chkconfig fredwilma on.
#!/bin/bash## chkconfig: 345 29 73# description: mount/unmount my custom bind mounts onto a gfs2 subdirectory##### BEGIN INIT INFO# Provides: ### END INIT INFO. /etc/init.d/functionscase "$1" in  start)# In this example, fred and wilma want their home directories# bind-mounted over the gfs2 directory /mnt/gfs2a, which has# been mounted as /mnt/gfs2amkdir -p /mnt/gfs2a/home/fred &> /dev/nullmkdir -p /mnt/gfs2a/home/wilma &> /dev/null/bin/mount --bind /mnt/gfs2a/home/fred /home/fred/bin/mount --bind /mnt/gfs2a/home/wilma /home/wilma ;  stop)/bin/umount /mnt/gfs2a/home/fred/bin/umount /mnt/gfs2a/home/wilma ;  status) ;  restart) $0 stop $0 start ;  reload) $0 start ;  *) echo $"Usage: $0 {start|stop|restart|reload|status}" exit 1esacexit 0

4.14. The GFS2 Withdraw Function

The GFS2 withdraw function is a data integrity feature of GFS2 file systems in a cluster. If the GFS2 kernel module detects an inconsistency in a GFS2 file system following an I/O operation, the file system becomes unavailable to the cluster. The I/O operation stops and the system waits for further I/O operations to stop with an error, preventing further damage. When this occurs, you can stop any other services or applications manually, after which you can reboot and remount the GFS2 file system to replay the journals. If the problem persists, you can unmount the file system from all nodes in the cluster and perform file system recovery with the fsck.gfs2 command. The GFS withdraw function is less severe than a kernel panic, which would cause another node to fence the node.
If your system is configured with the gfs2 startup script enabled and the GFS2 file system is included in the /etc/fstab file, the GFS2 file system will be remounted when you reboot. If the GFS2 file system withdrew because of perceived file system corruption, it is recommended that you run the fsck.gfs2 command before remounting the file system. In this case, in order to prevent your file system from remounting at boot time, you can perform the following procedure:
  1. Temporarily disable the startup script on the affected node with the following command:
    # chkconfig gfs2 off
  2. Reboot the affected node, starting the cluster software. The GFS2 file system will not be mounted.
  3. Unmount the file system from every node in the cluster.
  4. Run the fsck.gfs2 on the file system from one node only to ensure there is no file system corruption.
  5. Re-enable the startup script on the affected node by running the following command:
    # chkconfig gfs2 on
  6. Remount the GFS2 file system from all nodes in the cluster.
An example of an inconsistency that would yield a GFS2 withdraw is an incorrect block count. When the GFS kernel deletes a file from a file system, it systematically removes all the data and metadata blocks associated with that file. When it is done, it checks the block count. If the block count is not one (meaning all that is left is the disk inode itself), that indicates a file system inconsistency since the block count did not match the list of blocks found.
You can override the GFS2 withdraw function by mounting the file system with the -o errors=panic option specified. When this option is specified, any errors that would normally cause the system to withdraw cause the system to panic instead. This stops the node's cluster communications, which causes the node to be fenced.
Internally, the GFS2 withdraw function works by having the kernel send a message to the gfs_controld daemon requesting withdraw. The gfs_controld daemon runs the dmsetup program to place the device mapper error target underneath the file system preventing further access to the block device. It then tells the kernel that this has been completed. This is the reason for the GFS2 support requirement to always use a CLVM device under GFS2, since otherwise it is not possible to insert a device mapper target.
The purpose of the device mapper error target is to ensure that all future I/O operations will result in an I/O error that will allow the file system to be unmounted in an orderly fashion. As a result, when the withdraw occurs, it is normal to see a number of I/O errors from the device mapper device reported in the system logs.
Occasionally, the withdraw may fail if it is not possible for the dmsetup program to insert the error target as requested. This can happen if there is a shortage of memory at the point of the withdraw and memory cannot be reclaimed due to the problem that triggered the withdraw in the first place.
A withdraw does not always mean that there is an error in GFS2. Sometimes the withdraw function can be triggered by device I/O errors relating to the underlying block device. It is highly recommended to check the logs to see if that is the case if a withdraw occurs.
(Sebelumnya) 5 : Chapter 2. GFS2 Configurat ...5 : Chapter 5. Diagnosing and ... (Berikutnya)