gfs2(5)
gfs2 π
okay bestie, welcome to the GFS2 reference guide β that's the gfs2(5) page, we're in the File Formats Manual, and this is your group chat briefing on the whole clustered-filesystem situation β¨
π¦ SYNOPSIS π¦
A whole entire overview of the GFS2 filesystem, no cap. That's it, that's the synopsis π
β¨ DESCRIPTION β¨
So GFS2 is a clustered filesystem β meaning it's literally designed for sharing data between multiple nodes that are all plugged into one common shared storage device π«Ά like, everyone's holding hands around the same disk, iconic behavior.
It can also be used as a local filesystem on a single node, but hear me out β because the whole design is aimed at clusters, doing that will usually result in lower performance than just using a filesystem designed specifically for single-node use. So like, technically valid, lowkey not the vibe. π
GFS2 is a journaling filesystem, and one journal is required for each node that will mount the filesystem. Periodt, one journal per mounting node, no exceptionsβ¦ well, almost π
The one exception? Spectator mounts. These are equivalent to mounting a read-only block device, and as such they can neither recover a journal nor write to the filesystem β so they do not require a journal assigned to them. Slay, a loophole π
πΈ The GFS2 docs are split into a bunch of sections, bestie πΈ
mkfs.gfs2(8)β Create a GFS2 filesystem β¨fsck.gfs2(8)β The GFS2 filesystem checker πgfs2_grow(8)β Growing a GFS2 filesystem π±gfs2_jadd(8)β Adding a journal to a GFS2 filesystem πtunegfs2(8)β Tool to manipulate GFS2 superblocks π οΈgfs2_edit(8)β A GFS2 debug tool (use with caution) β οΈ
ok real talk, that last one says use with caution and I am not being dramatic, that's just what it says, take the hint π
more parts incoming, don't go anywhere bestie π
π MOUNT OPTIONS π
okay bestie, this is the main event, the part everyone actually opens the man page for. every single one of these goes in your mount command or your /etc/fstab and they all hit different. let's get into it β¨
lockproto=LockProtoNameβ this one picks which inter-node lock protocol the GFS2 filesystem uses for this mount, and it straight-up overrides the default lock protocol name sitting in the filesystem's on-disk superblock.
LockProtoName has to be one of the supported locking protocols, and rn those are lock_nolock and lock_dlm. that's it, that's the list.
the default lock protocol name gets written to disk when you first create the filesystem with mkfs.gfs2(8), -p option. you can change it on-disk later with the tunegfs2(8) command.
the lockproto mount option is for special circumstances only, like when you wanna temporarily run a different lock protocol without touching the on-disk default. and fr fr, using the wrong lock protocol on a cluster filesystem mounted from more than one node will almost certainly result in filesystem corruption. do not play with this. π
locktable=LockTableNameβ this sets the identity of the cluster and the filesystem for this mount, overriding the default cluster/filesystem identity stored in the on-disk superblock. that cluster/filesystem name is recognized globally across the whole cluster and it establishes a unique namespace for the inter-node locking system, which is what lets you mount multiple GFS2 filesystems. slay.
the format of LockTableName is lock-module-specific. for lock_dlm, the format is clustername:fsname. for lock_nolock, the field is just ignored, no thoughts, head empty.
the default cluster/filesystem name gets written to disk when you first create the filesystem with mkfs.gfs2(8), -t option, and you can change it on-disk with tunegfs2(8).
same energy aslockproto: only use thelocktablemount option in special circumstances, like mounting the filesystem in a different cluster or under a different filesystem name without changing the on-disk default.
localflocksβ this flag tells GFS2 "bestie you're a local (not clustered) filesystem now" so it can let the kernel VFS layer handle all the flock and fcntl file locking. when you're running in cluster mode, those file locks need inter-node locks and they need GFS2's support. when you're running locally, you get better performance by letting VFS do the whole job. iconic delegation tbh.
this one gets turned on automatically by the lock_nolock module. she does it herself. π
errors=[panic|withdraw]β settingerrors=panicmakes GFS2 oops when it hits an error that would otherwise make the mount withdraw or print an assertion warning. the default setting iserrors=withdraw.
do not use this on a production system. it replaces the earlierdebugoption on kernel versions2.6.31and above.
aclβ enables POSIX Access Control Listacl(5)support inside GFS2. πspectatorβ mounts this filesystem using a special form of read-only mount. the mount does not use one of the filesystem's journals, and the node is unable to recover journals for other nodes. so like, you're just watching, not participating. main character behavior is off the table.norecoveryβ a synonym forspectator. same vibe, different name. π¦suiddirβ sets the owner of any newly created file or directory to be that of the parent directory, if the parent directory has theS_ISUIDpermission attribute bit set. it setsS_ISUIDin any new directory, if its parent directory'sS_ISUIDis set. it strips all execution bits on a new file, if the parent directory owner is different from the owner of the process creating the file.
only set this option if you actually know why you're setting it. no vibes-based filesystem config, please. π
quota=[off/account/quiet/on]β turns quotas on or off for a filesystem. putting quotas in theaccountstate makes the per UID/GID usage statistics get correctly maintained by the filesystem, and the limit and warn values are ignored. thequietstate is equivalent toon, except it doesn't write warnings about soft and hard quota limits to the system log. the default value isoff.discardβ makes GFS2 generatediscardI/O requests for blocks that have been freed. suitable hardware can use those to implement thin-provisioning and similar schemes. supported in kernel version2.6.30and above. β¨barrierβ this option, which defaults to on, makes GFS2 send I/O barriers when flushing the journal. it gets automatically turned off if the underlying device doesn't support I/O barriers.
we highly recommend using I/O barriers with GFS2 at all times, unless the block device is designed so it cannot lose its write cache content (e.g. it's on a UPS, or it doesn't have a write cache).
commit=secsβ similar to the ext3commit=option, in that it sets the maximum number of seconds between journal commits if there's dirty data in the journal. the default is60seconds. this option is only provided in kernel versions2.6.31and above.data=[ordered|writeback]β whendata=orderedis set, the user data modified by a transaction gets flushed to disk before the transaction is committed to disk. this should prevent you from seeing uninitialized blocks in a file after a crash.data=writebackmode writes the user data to disk at any time after it's dirtied β it doesn't give you the same consistency guarantee as ordered mode, but it should be slightly faster for some workloads. the default is ordered mode.metaβ this option selects the meta filesystem root instead of the normal filesystem root. it's normally only used by the GFS2 utility functions.
altering any file on the GFS2 meta filesystem may render the filesystem unusable, so only experts in the GFS2 on-disk layout should use this option. π₯
quota_quantum=secsβ sets the number of seconds a change in the quota information can 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, and the default is60seconds. shorter settings mean faster updates of the lazy quota information and less likelihood of someone exceeding their quota. longer settings make filesystem operations involving quotas faster and more efficient.statfs_quantum=secsβ settingstatfs_quantumto0is the preferred way to set the slow version of statfs. the default value is30secs, which sets the maximum time period before statfs changes get synced to the master statfs file. you can adjust this to allow faster but less accurate statfs values, or slower but more accurate ones. when it's set to0, statfs always reports the true values.statfs_percent=valueβ this gives you a bound on the maximum percentage change in the statfs information on a local basis before it gets synced back to the master statfs file, even if the time period hasn't expired. ifstatfs_quantumis set to0, then this setting is ignored.rgrplvbβ this flag tells gfs2 to look for information about a resource group's free space and unlinked inodes in its glock lock value block. that keeps gfs2 from having to read the resource group data in from disk, which speeds up allocations in some cases. this option was added in the3.6Linux kernel. before that kernel, no information was saved to the resource group lvb.
note: to safely turn this on, all nodes mounting the filesystem must be running at least a 3.6 Linux kernel. if any nodes previously mounted the filesystem using older kernels, the filesystem must be unmounted on all nodes before it can be mounted with this option enabled. this option doesn't need to be enabled on all nodes using a filesystem.
loccookieβ this flag tells gfs2 to use location based readdir cookies instead of its usual filename hash readdir cookies. the filename hash cookies aren't guaranteed to be unique, and as the number of files in a directory increases, so does the likelihood of a collision. NFS requires readdir cookies to be unique, which can cause problems with very large directories (over100,000files). with this flag set, gfs2 will try to give out location based cookies. since the cookie is31bits, gfs2 will eventually run out of unique cookies and will fail back to using hash cookies. the maximum number of files that could have unique location cookies β assuming perfectly even hashing and names of8or fewer characters β is1,073,741,824. an average directory should be able to give out well over half a billion location based cookies. this option was added in the4.5Linux kernel. before that kernel, gfs2 didn't add directory entries in a way that allowed it to use location based readdir cookies.
note: to safely turn this on, all nodes mounting the filesystem must be running at least a 4.5 Linux kernel. if this option is only enabled on some of the nodes mounting a filesystem, the cookies returned by nodes using this option won't be valid on nodes that aren't using it, and vice versa. and finally, when you first enable this option on a filesystem that had been previously mounted without it, you must make sure there are no outstanding cookies being cached by other software, such as NFS. π
that's the whole mount options buffet bestie, every single flag accounted for, no skips, no cuts π
π οΈ SETUP π οΈ
Okay bestie, here's the tea β β GFS2 clustering does not run itself. It's driven by the dlm, and the dlm depends on dlm_controld to bring clustering in from userspace. And dlm_controld's clustering? Built on corosync cluster/group membership and messaging. It's a whole ecosystem, fr fr. π¦
GFS2 also needs clustered lvm, which comes from lvmlockd or, back in the day, clvmd. So go read the docs for every single one of these components and make sure they're configured before you even think about setting up a GFS2 filesystem. Also check your distribution's documentation for any special support requirements it has, because distros love having β¨opinionsβ¨.
π Make sure gfs2-utils is installed on every node that mounts the filesystem β it ships the scripts needed for correct withdraw event response. Skip it and you're on your own, no cap.
1οΈβ£ Create the gfs2 filesystem
mkfs.gfs2 -p lock_dlm -t cluster_name:fs_name -j num /path/to/storage
Breaking it down for you, queen π:
- The
cluster_namehas to match the name configured in corosync (and therefore in dlm). No matching, no vibes. - The
fs_namemust be a unique name for the filesystem inside the cluster. - The
-joption is the number of journals to create β and there must be one for each node that will mount the filesystem. Count your nodes, bestie. Count them twice. π₯
2οΈβ£ Mount the gfs2 filesystem
If you're using a clustered resource manager, go read its documentation for how to enable a gfs2 filesystem resource. If not, just run:
mount /path/to/storage /mountpoint
Then run dlm_tool ls to verify the nodes that have each fs mounted. Vibe check your cluster before you trust it π
3οΈβ£ Shut down
Using a clustered resource manager? Again, its documentation is the one holding the instructions for disabling a gfs2 filesystem resource. Otherwise, run:
umount -a -t gfs2
And that's a wrap, we love a clean exit π
π SEE ALSO π
mount(8)andumount(8)for general mount informationchmod(1)andchmod(2)for access permission flagsacl(5)for access control listslvm(8)for volume managementdlm_controld(8),dlm_tool(8),dlm.conf(5)corosync(8),corosync.conf(5)
And that's the whole page, bestie π«Ά this was the gfs2(5) man page from the gfs2-utils package, dated back in the day β go mount something iconic and stay clustered. periodt. πβ¨
π¦ where this page comes from
- debian trixie: gfs2-utils 3.6.1-1 Β· GPL-2.0-or-later
- fedora 43: gfs2-utils 3.6.1-2.fc43 Β· GPL-2.0-or-later AND LGPL-2.1-or-later
- fedora 44: gfs2-utils 3.6.1-3.fc44 Β· GPL-2.0-or-later AND LGPL-2.1-or-later
- nixpkgs unstable: gfs2-utils 3.6.1
- ubuntu questing: gfs2-utils 3.6.1-1
- ubuntu resolute: gfs2-utils 3.6.1-1build1 Β· GPL-2.0-or-later
- ubuntu stonking: gfs2-utils 3.6.1-2ubuntu1 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms