xfs_db(8)
okay bestie, meet xfs_db(8) from the System Manager's Manual โ the XFS filesystem debugger that's about to explain itself. ๐ฆ
โจ NAME โจ
xfs_dbโ debug an XFS filesystem ๐
๐ธ SYNOPSIS ๐ธ
xfs_db [ -c cmd ] ... [ -i|r|x|F ] [ -f ] [ -l logdev ] [ -R rtdev ] [
-p progname ] device
xfs_db -V
๐ DESCRIPTION ๐
xfs_db is used to examine an XFS filesystem. Under rare circumstances it can also be used to modify an XFS filesystem, but that task is normally left to xfs_repair(8) or to scripts such as xfs_admin(8) that run xfs_db. No cap. ๐
โจ OPTIONS โจ
-c cmdโxfs_dbcommands may be run interactively (the default) or as arguments on the command line. Multiple-carguments may be given. The commands are run in the sequence given, then the program exits. ๐-fโ Specifies that the filesystem image to be processed is stored in a regular file at device (see themkfs.xfs(8)-d fileoption). This might happen if an image copy of a filesystem has been made into an ordinary file withxfs_copy(8). ๐-Fโ Specifies that we want to continue even if the superblock magic is not correct. For use inxfs_metadump. ๐ซถ-iโ Allows execution on a mounted filesystem, provided it is mounted read-only. Useful for shell scripts which must only operate on filesystems in a guaranteed consistent state (either unmounted or mounted read-only). These semantics are slightly different to that of the-roption. iykyk ๐-l logdevโ Specifies the device where the filesystems external log resides. Only for those filesystems which use an external log. See themkfs.xfs(8)-loption, and refer toxfs(5)for a detailed description of the XFS log. ๐ฅ-p prognameโ Set the program name to progname for prompts and some error messages, the default value isxfs_db. โจ-R rtdevโ Specifies the device where the realtime data resides. This is only relevant for filesystems that have a realtime section. See themkfs.xfs(8)-roption, and refer toxfs(5)for a detailed description of the XFS realtime section. ๐-rโ Open device or filename read-only. This option is required if the filesystem is mounted. It is only necessary to omit this flag if a command that changes data (write,blocktrash,crc) is to be used. ๐-xโ Specifies expert mode. This enables the (write,blocktrash,crc invalidate/revalidate) commands. expert mode, bestie ๐-Vโ Prints the version number and exits. ๐ฆ
๐ง CONCEPTS ๐ง
So like, xfs_db commands split into two classes, bestie. Most commands are for the navigation and display of data structures in the filesystem. Other commands are for scanning the filesystem in some way. Both are iconic in their own lane. ๐
Commands which are used to navigate the filesystem structure take arguments which reflect the names of filesystem structure fields. There can be multiple field names separated by dots when the underlying structures are nested, as in C. The field names can be indexed (as an array index) if the underlying field is an array. The array indices can be specified as a range, two numbers separated by a dash. ๐
xfs_db maintains a current address in the filesystem. The granularity of the address is a filesystem structure. This can be a filesystem block, an inode or quota (smaller than a filesystem block), or a directory block (could be larger than a filesystem block). There are a variety of commands to set the current address. Associated with the current address is the current data type, which is the structural type of this data. Commands which follow the structure of the filesystem always set the type as well as the address. Commands which examine pieces of an individual file (inode) need the current inode to be set, this is done with the inode command. ๐ง
The current address/type information is actually maintained in a stack that can be explicitly manipulated with the push, pop, and stack commands. This allows for easy examination of a nested filesystem structure. Also, the last several locations visited are stored in a ring buffer which can be manipulated with the forward, back, and ring commands. โญ
XFS filesystems are divided into a small number of allocation groups. xfs_db maintains a notion of the current allocation group which is manipulated by some commands. The initial allocation group is 0. ๐
๐ COMMANDS ๐
Many commands have extensive online help. Use the help command for more details on any command. ๐ซถ
aโ See theaddrcommand.ablock filoffโ Set current address to the offset filoff (a filesystem block number) in the attribute area of the current inode. ๐addr [field-expression]โ Set current address to the value of the field-expression. This is used to "follow" a reference in one structure to the object being referred to. If no argument is given, the current address is printed. ๐ฅagf [agno]โ Set current address to the AGF block for allocation group agno. If no argument is given, use the current allocation group. ๐agfl [agno]โ Set current address to the AGFL block for allocation group agno. If no argument is given, use the current allocation group. ๐agi [agno]โ Set current address to the AGI block for allocation group agno. If no argument is given, use the current allocation group. ๐agresv [agno]โ Displays the length, free block count, per-AG reservation size, and per-AG reservation usage for a given AG. If no argument is given, display information for all AGs. ๐attr_get [-p|-r|-u|-s|-Z] [-N namefile|name]โ Print the value of the specified extended attribute from the current file.-pโ Sets the attribute in the parent namespace. Only one namespace option can be specified.-rโ Sets the attribute in the root namespace. Only one namespace option can be specified.-uโ Sets the attribute in the user namespace. Only one namespace option can be specified.-sโ Sets the attribute in the secure namespace. Only one namespace option can be specified.-Zโ Sets a filesystem property in the root namespace. Only one namespace option can be specified.-Nโ Read the name from this file.
attr_list [-p|-r|-u|-s|-Z] [-v]โ Lists the extended attributes of the current file.-pโ Sets the attribute in the parent namespace. Only one namespace option can be specified.-rโ Sets the attribute in the root namespace. Only one namespace option can be specified.-uโ Sets the attribute in the user namespace. Only one namespace option can be specified.-sโ Sets the attribute in the secure namespace. Only one namespace option can be specified.-Zโ Sets a filesystem property in the root namespace. Only one namespace option can be specified.-vโ Print the extended attribute values too.
attr_remove [-p|-r|-u|-s|-Z] [-n] [-N namefile|name]โ Remove the specified extended attribute from the current file.-pโ Sets the attribute in the parent namespace. Only one namespace option can be specified.-rโ Sets the attribute in the root namespace. Only one namespace option can be specified.-uโ Sets the attribute in the user namespace. Only one namespace option can be specified.-sโ Sets the attribute in the secure namespace. Only one namespace option can be specified.-Zโ Sets a filesystem property in the root namespace. Only one namespace option can be specified.-Nโ Read the name from this file.-nโ Do not enable'noattr2'mode on V4 filesystems.
attr_set [-p-r|-u|-s|-Z] [-n] [-R|-C] [-v valuelen|-V valuefile] [-N namefile|name] [value]โ Sets an extended attribute on the current file with the given name.-pโ Sets the attribute in the parent namespace. Only one namespace option can be specified.-rโ Sets the attribute in the root namespace. Only one namespace option can be specified.-uโ Sets the attribute in the user namespace. Only one namespace option can be specified.-sโ Sets the attribute in the secure namespace. Only one namespace option can be specified.-Zโ Sets a filesystem property in the root namespace. Only one namespace option can be specified.-Nโ Read the name from this file.-nโ Do not enable'noattr2'mode on V4 filesystems.-Rโ Replace the attribute. The command will fail if the attribute does not already exist.-Cโ Create the attribute. The command will fail if the attribute already exists.-Vโ Read the value from this file.-vโ Set the attribute value to a string of this length containing the letter'v'.
bโ See thebackcommand.backโ Move to the previous location in the position ring. ๐blockfreeโ Free block usage information collected by the last execution of theblockgetcommand. This must be done before anotherblockgetcommand can be given, presumably with different arguments than the previous one. ๐งนblockget [-npvs] [-b bno] ... [-i ino] ...โ Get block usage. The information is saved for use by a subsequentblockuse,ncheck, orblocktrashcommand.-bโ is used to specify filesystem block numbers about which verbose information should be printed.-iโ is used to specify inode numbers about which verbose information should be printed.-nโ is used to save pathnames for inodes visited, this is used to support thexfs_ncheck(8)command. It also means that pathnames will be printed for inodes that have problems. This option uses a lot of memory so is not enabled by default.-pโ causes error messages to be prefixed with the filesystem name being processed. This is useful if several copies ofxfs_dbare run in parallel.-sโ restricts output to severe errors only. This is useful if the output is too long otherwise.-vโ enables verbose output. Messages will be printed for every block and inode processed.
๐ blocktrash โ the chaos gremlin command ๐
blocktrash [-z] [-o offset] [-n count] [-x min] [-y max] [-s seed]
[-0|1|2|3] [-t type] ...
okay so this one trashes randomly picked filesystem metadata blocks โ like, it goes in and flips random bits inside the blocks it chose. no cap. bestie, this is only available in debugging versions of xfs_db, and its whole personality is "let's break stuff so we can test xfs_repair(8)" ๐ซถ
-0|-1|-2|-3โ these set the operating mode forblocktrash, and you can only pick one of them:-0โ changed bits get cleared-1โ changed bits get set-2โ changed bits get inverted-3โ changed bits get randomized โจ
-nโ how many block-trashings to do. default is1.-oโ the bit offset where the trashing starts in the block. if you put a+in front of the value, the trashing starts at a randomly chosen offset that's larger than the value you gave. default is to just randomly pick an offset anywhere in the block.-sโ a seed for the random processing ๐ฑ-tโ the type of blocks to select for trashing. you can give multiple-toptions. if you give no-toptions at all, then all metadata types can be trashed.-xโ the minimum size of the bit range to trash. default value is1.-yโ the maximum size of the bit range to trash. default value is1024.-zโ trashes the block at the top of the stack. if you use this option, you do not need to runblockgetfirst.
๐งฎ blockuse
blockuse [-n] [-c count]
prints usage info for the current filesystem block(s). for every block it prints the type and, if there is one, the inode. very "who is this block and why are they here" energy ๐
-cโ a count of blocks to process. default is1(so, just the current block).-nโ print file names. heads up: the earlierblockgetcommand must also have been given the-noption for this to work.
๐บ๏ธ bmap
bmap [-a] [-d] [block [len]]
shows the block map for the current inode ๐
you can narrow the map display down to just part of the file using the block and len arguments. if you give block but leave out len, then len is assumed to be 1.
the -a and -d options pick the attribute or data area of the inode. if you give neither, both areas get shown. inclusive queen ๐ธ
๐ bmapinflate โ expert mode only, proceed with caution ๐ญ
bmapinflate [-d dirty_bytes] [-e] [-n nr]
duplicates the first data fork mapping this many times, as if the mapping had been repeatedly reflinked. this is an expert-mode command for exercising high-refcount filesystems only. existing data fork mappings will be forgotten and the refcount btree will not be updated.
โ ๏ธ bestie this command leaves at least the refcount btree and the inode inconsistent. you must run xfs_repair afterwards. like, that's not optional. periodt.
-dโ constrain the memory consumption of new dirty btree blocks to this quantity. defaults to60MiB.-eโ estimate the number of blocks and height of the new data fork mapping structure, then exit without changing anything. the "look but don't touch" option, iconic ๐-nโ create this many copies of the first mapping.
๐ณ btdump
btdump [-a] [-i]
if the cursor points to a btree node, it dumps the btree from that block downward โฌ๏ธ if instead the cursor points to an inode, it dumps the data fork block mapping btree if there is one. and if the cursor points to a directory or extended attribute btree node, it dumps that. by default, only records stored in the btree get dumped.
-aโ if the cursor points at an inode, dump the extended attribute block mapping btree, if it's present.-iโ dump all keys and pointers in intermediate btree nodes, plus all records in leaf btree nodes. the full tea โ
๐ btheight
btheight [-b blksz] [-n recs] [-w max|min|absmax|avg] btree types...
for a given number of btree records and a btree type, this reports the number of records and blocks for each level of the btree, plus the total number of blocks. the btree type has to come after the options, okay?
you can also hand it a raw btree geometry in the format "record_bytes:key_bytes:ptr_bytes:header_type", where header_type is one of "short", "long", "shortcrc", or "longcrc".
the supported btree types are: bnobt, cntbt, inobt, finobt, bmapbt, refcountbt, rmapbt, rtrefcountbt, and rtrmapbt. the magic value all can be used to walk through all btree types ๐
options are as follows:
-bโ override the btree block size. default is the filesystem block size.-nโ specify the number of records to store. this argument is required. no skipping it bestie.-w absmaxโ shows the maximum possible height for the given btree types.-w maxโ shows only the best case scenario, which is when the btree blocks are maximally loaded โจ-w minโ shows only the worst case scenario, which is when the btree blocks are half full ๐ญ-w avgโ shows only the average case scenario, which is when the btree blocks are three quarters full.
๐ convert
convert type number [type number] ... type
converts from one address form to another. the known types, with their alternate names, are:
agblockoragbno(filesystem block within an allocation group)aginooraginode(inode number within an allocation group)agnumberoragno(allocation group number)bboffordaddroff(byte offset in a daddr)blkofforfsbofforagboff(byte offset in a agblock or fsblock)byteorfsbyte(byte address in filesystem)daddrorbb(disk address, 512-byte blocks)fsblockorfsborfsbno(filesystem block, see thefsblockcommand)inoorinode(inode number)inoidxoroffset(index of inode in filesystem block)inoofforinodeoff(byte offset in inode)
only conversions that "make sense" are allowed, so don't get creative ๐ the compound form (with more than three arguments) is useful for conversions such as convert agno ag agbno agb fsblock.
โ
crc
crc [-i|-r|-v]
invalidates, revalidates, or validates the CRC (checksum) field of the current structure, if it has one. this command is available only on CRC-enabled filesystems. with no argument, validation is performed. every version of the command will display the resulting CRC value and state.
-iโ invalidate the structure's CRC value (incrementing it by one), and write it to disk.-rโ recalculate the current structure's correct CRC value, and write it to disk.-vโ validate and display the current value and state of the structure's CRC.
๐พ daddr
daddr [-r] [d]
sets the current address to the daddr (512 byte block) given by d. if you don't give a value for d, the current address is printed, expressed as a daddr. the type gets set to data (uninterpreted).
if an address and the -l option are specified, the current address is set to the external log device. if an address and the -r option are specified, the current address is set to the realtime device.
๐ dblock
dblock filoff
sets the current address to the offset filoff (a filesystem block number) in the data area of the current inode.
๐ debug
debug [flagbits]
sets debug option bits. these are used for debugging xfs_db itself. if you don't give a value for flagbits, it prints the current debug option bits. heads up: these are for the use of the implementor, so it's giving "you had to be there" ๐ซ
๐ฅ dquot
dquot [-g|-p|-u] id
sets the current address to a group, project or user quota block for the given ID. defaults to user quota.
๐ชฃ dump_iunlinked
dump_iunlinked [-a agno ] [-b bucket ] [-q] [-v]
dumps the contents of unlinked buckets. options include:
-aโ print only this AG's unlinked buckets.-bโ print only this bucket within each AGI.-qโ only print the essentials. the tl;dr setting ๐-vโ print resource usage of each file on the unlinked lists.
๐ข echo
echo [arg] ...
echoes the arguments to the output. that's it. that's the command. lowkey iconic โจ
โฉ f
see the forward command.
โฉ forward
moves forward to the next entry in the position ring ๐
๐งฉ frag
frag [-adflqRrv]
gets file fragmentation data ๐ this prints info about fragmentation of file data in the filesystem (as opposed to fragmentation of freespace โ for that, see the freesp command). every file in the filesystem gets examined to see how far from ideal its extent mappings are, and then a summary is printed giving the totals.
-vโ sets verbosity; every inode has information printed for it. the remaining options select which inodes and extents get examined. if you give no options, then all are assumed set โ otherwise just the ones you gave are enabled.-aโ enables processing of attribute data.-dโ enables processing of directory data.-fโ enables processing of regular file data.-lโ enables processing of symbolic link data.-qโ enables processing of quota file data.-Rโ enables processing of realtime control file data.-rโ enables processing of realtime file data.
๐ freesp
freesp [-bcds] [-A alignment] [-a ag] ... [-e i] [-h h1] ... [-m m]
summarizes free space for the filesystem ๐ธ the free blocks get examined and totalled, then displayed as a histogram, with a count of extents in each range of free extent sizes.
-Aโ reports only free extents with starting blocks aligned to alignment blocks.-aโ adds ag to the list of allocation groups to be processed. if you give no-aoptions, then all allocation groups get processed.-bโ the histogram buckets are binary-sized, with the starting sizes being the powers of 2.-cโfreespwill search the by-size (cnt) space Btree instead of the default by-block (bno) space Btree.-dโ every free extent will be displayed.-eโ the histogram buckets are equal-sized, with the size specified as i.-hโ says "this is where a histogram bucket starts", as h1. Stack up multiple-h's to lay out the entire set of buckets. ๐ชฃ-mโ says the histogram starting block numbers are powers of m. This is the glow-up general case of-b. โจ-sโ says to print a final summary of total free extents, free blocks, and the average free extent size at the end.
fsb
See the fsblock command. ๐
fsblock [fsb]
Sets the current address to the fsblock value you hand it in fsb. If you don't give a fsb value, it prints the current address, expressed as an fsb. The type gets set to data (uninterpreted, no thoughts, just vibes).
XFS filesystem block numbers are computed like this:
((agno << agshift) | agblock)
where agshift depends on the size of an allocation group. Use the convert command to go to and from this form. Block numbers given for file blocks (say, from the bmap command) are in this form. ๐
fsmap [-r] [start [end]]
Prints the mapping of disk blocks used by an XFS filesystem. The map lists every extent used by files, allocation group metadata, journalling logs, and static filesystem metadata, plus any regions that are just sitting there unused. All blocks, offsets, and lengths are in units of 512-byte blocks, no matter what the filesystem's block size is. ๐บ๏ธ
The optional start and end arguments constrain the output to a particular range of disk blocks.
When the -r option is given, it prints the reverse mapping for the real-time device instead of the data device.
fuzz [-c] [-d] field action
Writes garbage into a specific structure field on disk. โ ๏ธ Expert mode must be enabled to use this command. The operation happens immediately; there is no buffering, it's giving instant gratification.
The fuzz command can take the following actions against a field:
zeroesโ clears all bits in the field.onesโ sets all bits in the field.firstbitโ flips the first bit in the field. For a scalar value, this is the highest bit.middlebitโ flips the middle bit in the field.lastbitโ flips the last bit in the field. For a scalar value, this is the lowest bit.addโ adds a small value to a scalar field.subโ subtracts a small value from a scalar field.randomโ randomizes the contents of the field.
The following switches affect the write behavior:
-cโ skips write verifiers and CRC recalculation; this allows invalid data to be written to disk.-dโ skips write verifiers but does perform CRC recalculation; this allows invalid data to be written to disk so you can test detection of invalid data.
hash[-d|-pparent_ino]"strings
Prints the hash value of string using the hash function of the XFS directory and attribute implementation. ๐งฎ
If the -d option is specified, the directory-specific hash function is used. This only makes a difference on filesystems with ascii case-insensitive lookups enabled.
If the -p option is specified, the parent pointer-specific hash function is used. The parent directory inumber must be specified as an argument. This only makes a difference on filesystems with ascii case-insensitive lookups enabled.
hashcoll [-a] [-s seed] [-n nr] [-p path] -i | names...
Creates directory entries or extended attributes names that all have the same hash value. The metadump name obfuscation algorithm is used here. Names are written to standard output, with a NULL between each name so it plays nice with xargs -0.
-aโ create extended attribute names.-iโ read the first name to create from standard input. Up to 255 bytes are read. If this option isn't specified, first names are taken from the command line.-n nrโ create this many duplicated names. The default is to create one name.-p pathโ create directory entries or extended attributes in this file instead of writing the names to standard output.-s seedโ seed the random number generator with this value.
help [command]
Print help for one or all commands. Bestie behavior fr fr. ๐ซถ
makecfg [path]
Writes a configuration file to the given path that can be re-read by mkfs.xfs for a future filesystem format attempt. This file will contain only user-visible features. Filesystem geometry information is not written to the configuration file. If no path is given, the configuration will be printed on standard output. ๐
info
Displays selected geometry information about the filesystem. The output has the same format that mkfs.xfs(8) prints when creating a filesystem, or that xfs_info(8) prints when querying a filesystem. ๐ธ
inode [inode#]
Sets the current inode number. If no inode# is given, prints the current inode number.
iunlink [-n nr ]
Allocates inodes and puts them on the unlinked list. ๐๏ธ
Options include:
-nโ create this number of unlinked inodes. If not specified, 1 inode will be created.
label [label]
Sets the filesystem label. The filesystem label can be used by mount(8) instead of using a device special file. The maximum length of an XFS label is 12 characters โ using a longer label will result in truncation, and a warning will be issued. If no label is given, the current filesystem label is printed. ๐ท๏ธ
link [-i ino] [-m] [-p path] [-t ftype] name
In the current directory, creates a directory entry with the given name pointing to a file. The file must be specified either as a directory tree path as given by the path option, or directly as an inode number as given by the ino option. The file type in the directory entry will be determined from the mode of the child file unless the ftype option is given. The -m option specifies that the path lookup should be done in the metadata directory tree. The file being targetted must not be on the iunlink list. ๐
log [stop | start filename]
Starts logging output to filename, stops logging, or prints the current logging status. ๐ชต
logblock [logbno]
Sets the current address to the log block value given by logbno. If no value for logbno is given, the current address is printed, expressed as an fsb. The type is set to data (uninterpreted). If the filesystem has an external log, then the address will be within the log device. If the filesystem has an internal log, then the address will be within the internal log.
logformat [-c cycle] [-s sunit]
Reformats the log to the specified log cycle and log stripe unit. ๐ This has the effect of clearing the log destructively. If the log cycle isn't specified, the log is reformatted to the current cycle. If the log stripe unit isn't specified, the stripe unit from the filesystem superblock is used.
logres
Print transaction reservation size information for each transaction type. This makes it easier to find discrepancies in the reservation calculations between xfsprogs and the kernel, which helps when diagnosing minimum log size calculation errors. ๐
ls [-im] [paths]...
Lists the contents of a directory. If a path resolves to a directory, the directory will be listed. If no paths are supplied and the IO cursor points at a directory inode, the contents of that directory will be listed. ๐
The output format is: directory cookie, inode number, file type, hash, name length, name.
-iโ resolve each of the given paths to an inode number and print that number. If no paths are given and the IO cursor points to an inode, print the inode number.-mโ absolute paths should be walked from the root of the metadata directory tree.
metadump [-egow] filename
Dumps metadata to a file. See xfs_metadump(8) for more information. ๐ซ
ncheck [-s] [-i ino] ...
Print name-inode pairs. A blockget -n command must be run first to gather the information.
-iโ specifies an inode number to be printed. If no-ioptions are given, then all inodes are printed.-sโ specifies that only setuid and setgid files are printed.
p
See the print command. ๐
parent [-m] [paths]...
Lists the parents of a file. If a path resolves to a file, the parents of that file will be listed. If no paths are supplied and the IO cursor points at an inode, the parents of that file will be listed. The -m option causes absolute paths to be walked from the root of the metadata directory tree. ๐จโ๐ฉโ๐ง
The output format is: inode number, inode generation, ondisk namehash, namehash, name length, name.
path [-m] dir_path
Walks the directory tree to an inode using the supplied path. Absolute and relative paths are supported. The -m option causes absolute paths to be walked from the root of the metadata directory tree. ๐ถโโ๏ธ
pop
Pops location from the stack.
print [field-expression] ...
Prints field values. If no argument is given, prints all fields in the current structure. ๐จ๏ธ
push [command]
Pushes location to the stack. If command is supplied, sets the current location to the results of command after pushing the old location.
q
See the quit command. ๐
quit
Exits xfs_db. ๐
rdump [-s] [paths...] destination_dir
Recovers the files given by the path arguments by copying them off the filesystem into the directory specified in destination_dir. ๐
If the -s option is specified, errors are fatal. By default, read errors are ignored in favor of recovering as much data from the filesystem as possible.
If zero paths are specified, the entire filesystem is dumped. If only one path is specified and it's a directory, the children of that directory will be copied directly to the destination. If multiple paths are specified, each file is copied into the directory as a new child.
If possible, sparse holes, xfs file attributes, and extended attributes will be preserved. ๐ (that's the tail end of the previous command, bestie โ no cap, it really does try to keep all that stuff intact)
rgresv [rgno]โ shows the per-rtgroup reservation size, plus the per-rtgroup reservation usage for whichever realtime allocation group you point at. Give it no argument and it just dumps the info for all the rtgroups, like a little group-chat roster ๐ซถrtblock [rtbno]โ moves the current address to the spot on the realtime device that rtbno says. This value must be a realtime block number, okay? No fudging. If you don't hand over an rtbno, it just prints the current address, expressed as an rtbno. Type gets set todata(uninterpreted, i.e. raw, no vibes applied) โจrtextent [rtxno]โ same energy, but the address is given by rtextent: a linear address measured in units of realtime extents. No rtextent argument? Then it prints the current address expressed as an rtextent. Type is set todata(uninterpreted). ๐ring [index]โ shows the position ring (if you don't pass an index), or teleports you to the specific entry in the position ring given by index. It's giving "scroll to message" energy. ๐rtconvert type number [type number] ... typeโ converts one address form into another for realtime section addresses. The known types, with their alternate names, are:rgblockorrgbno(realtime block within a realtime group)rgnumberorrgno(realtime group number)bboffordaddroff(byte offset in a daddr)blkofforfsbofforrtboff(byte offset in a rtblock or rtextent)byteorfsbyte(byte address in filesystem)daddrorbb(disk address, 512-byte blocks)rtblockorrtborrtbno(realtime filesystem block, see thefsblockcommand)rtxorrtextent(realtime extent)rbmblockorrbmb(realtime bitmap block)rbmwordorrbmw(32-bit word within a realtime bitmap block)rsumblockorrsmb(realtime summary file block)rsuminfoorrsmi(32-bit counter within a realtime summary block)rsumlogorrsml(log2len parameter used for summary file offset computations)
Only conversions that "make sense" are allowed, bestie. The compound form โ more than three arguments โ is so useful for stuff like convert rgno rg rgbno rgb rtblock. ๐
Realtime summary file location conversions follow these rules: each info word in the rt summary file counts the number of free extents of a given log2(length) that start in a given rt bitmap block. ๐ง
To compute summary file location info for a given rt bitmap block, you have to specify a log2(extent length) as the last type/number pair before the conversion type, and the type must be rsumlog.
For example, these commands tell us where to look in the rt summary file for the number of free rtextents of length 2^21 starting in rt bitmap block 30:
rtconvert rbmblock 30 rsumlog 21 rsumblock
rtconvert rbmblock 30 rsumlog 21 rsuminfo
To go the other way โ computing the rt bitmap block from a summary file location โ the type/number pairs must be specified exactly in the order rsumlog, rsuminfo, rsumblock. Order matters, no skipping, periodt.
For example, this command tells us which block in the rt bitmap file is summarized by info word 809 in rt summary block 10, assuming the max free extent length is 2^21 rtextents:
rtconvert rsumlog 21 rsuminfo 809 rsumblock 10 rbmblock
rtsbโ sets the current address to the superblock header at the very start of the realtime volume. Iconic little landmark. ๐sb [agno]โ sets the current address to the SB header in allocation group agno. No agno? Then it uses the current allocation group number. ๐source source-fileโ processes commands from source-file. And yes,sourcecommands can be nested. Inception but make it Unix. ๐stackโ view the location stack. That's it, that's the whole thing. Short and powerful. ๐ซtype [type]โ sets the current data type to type. No argument? It shows the current data type. The possible data types are:agf,agfl,agi,attr,bmapbta,bmapbtd,bnobt,cntbt,data,dir,dir2,dqblk,inobt,inode,log,refcntbt,rmapbt,rtbitmap,rtsummary,sb,symlink,rtrmapbt,rtrefcbt, andtext. Peep the TYPES section below for the whole breakdown on these. ๐timelimit [OPTIONS]โ prints the minimum and maximum supported values for inode timestamps, quota expiration timers, and quota grace periods that this filesystem can handle. Options include:--bigtimeโ print the time limits of an XFS filesystem with the bigtime feature enabled.--classicโ print the time limits of a classic XFS filesystem.--compactโ print all limits as raw values, all on a single line.--prettyโ print the timestamps in the current locale's date and time format instead of raw seconds since the Unix epoch. ๐ฐ๏ธ
unlink nameโ in the current directory, removes a directory entry with the given name. Heads up: the file being targetted will not be put on the iunlink list. ๐untorn_write_max [-b blockcount|-l logres]โ with-l, compute the maximum (in fsblocks) untorn write we can emulate with copy on write, given a log reservation size (in bytes). With-b, compute the log reservation size that would be needed to emulate an untorn write of the given number of fsblocks. Two-way street, pick your lane. ๐ฃ๏ธuuid [uuid | generate | rewrite | restore]โ sets the filesystem universally unique identifier (UUID). The filesystem UUID can be used bymount(8)instead of using a device special file. You can set the uuid directly to the UUID you want, or auto-generate it with thegenerateoption. Both of those options write the UUID into every copy of the superblock in the filesystem. On a CRC-enabled filesystem, this sets an incompatible superblock flag, and the filesystem will not be mountable with older kernels โ fr fr, read that twice. You can revert it with therestoreoption, which copies the original UUID back into place and clears the incompatible flag as needed.rewritecopies the current UUID from the primary superblock to all the secondary copies of the superblock. And if you give no argument at all? It just prints the current filesystem UUID. ๐version [feature | versionnum features2]โ enables selected features for a filesystem (certain features can be enabled on an unmounted filesystem, aftermkfs.xfs(8)has created it). Support for unwritten extents can be enabled with theextflgoption. Support for version 2 log format can be enabled with thelog2option. Support for extended attributes can be enabled with theattr1orattr2option. Once enabled, extended attributes cannot be disabled โ but you may toggle betweenattr1andattr2at will (though older kernels might not support the newer version, so, y'know, vibe check your kernel first).
No argument? Then the current version and feature bits get printed. With one argument, this command writes the updated version number into every copy of the superblock in the filesystem. With two arguments, they're used as numeric values for the versionnum and features2 bits respectively, and their string equivalent is reported โ but no modifications are made. ๐
write [-c|-d] [field value] ...โ writes a value to disk. You can set specific fields in structures (struct mode), or set a whole block to data values (data mode), or set a block to string values (string mode, for symlink blocks). The operation happens immediately โ there is no buffering, bestie. No undo. ๐
Struct mode is in effect when the current type is structural, i.e. not data. For struct mode, the syntax is write field value.
Data mode is in effect when the current type is data. In that case the contents of the block can be shifted or rotated left or right, or filled with a sequence, a constant value, or a random value. In this mode, running write with no arguments gives you more info on the allowed commands. ๐
-cโ skip write verifiers and CRC recalculation; allows invalid data to be written to disk.-dโ skip write verifiers but do perform CRC recalculation. This allows invalid data to be written to disk to test detection of invalid data. (Not possible for some types.)
๐ฆ TYPES ๐ฆ
This section gives the fields in each structure type and their meanings. Note that some types of block cover multiple actual structures โ directory blocks, for instance. So one "type" can be a whole little ensemble cast. ๐
agf
The AGF block is the header for block allocation information; it lives in the second 512-byte block of each allocation group. The following fields are defined:
magicnumโ AGF block magic number,0x58414746('XAGF').versionnumโ version number, currently1.seqnoโ sequence number starting from0.lengthโ size in filesystem blocks of the allocation group. All allocation groups except the last one of the filesystem have the superblock'sagblocksvalue here.bnorootโ block number of the root of the Btree holding free space information sorted by block number.cntrootโ block number of the root of the Btree holding free space information sorted by block count.bnolevelโ number of levels in the by-block-number Btree.cntlevelโ number of levels in the by-block-count Btree.flfirstโ index into the AGFL block of the first active entry.fllastโ index into the AGFL block of the last active entry.flcountโ count of active entries in the AGFL block.freeblksโ count of blocks represented in the freespace Btrees.longestโ longest free space represented in the freespace Btrees.btreeblksโ number of blocks held in the AGF Btrees.agflโ okay so the AGFL block is literally the block allocator's little emergency stash of block numbers ๐. It lives in the fourth512-byte block of each allocation group. Every entry in the active list is a block number within the allocation group that can be used for any purpose if space runs low. Which entries are active rn? The AGF block's fieldsflfirst,fllast, andflcountare the ones that designate that ๐ . Entry space gets allocated in a circular manner within the AGFL block, periodt. Fields defined:bnoโ array of all block numbers. Even those which are not active are printed, so yeah, you get the whole roster bestie ๐.
agiโ the AGI block is the header for inode allocation information, and it sits in the third512-byte block of each allocation group ๐ง. Fields defined:magicnumโ AGI block magic number,0x58414749('XAGI').versionnumโ version number, currently1.seqnoโ sequence number starting from0.lengthโ size in filesystem blocks of the allocation group.countโ count of inodes allocated.rootโ block number of the root of the Btree holding inode allocation information.levelโ number of levels in the inode allocation Btree.freecountโ count of allocated inodes that are not in use.newinoโ last inode number allocated.dirinoโ unused. (ngl, it's just sitting there ๐ช)unlinkedโ an array of inode numbers within the allocation group. The entries in the AGI block are the heads of lists which run through the inodenext_unlinkedfield. These inodes are to be unlinked the next time the filesystem is mounted ๐.
attrโ an attribute fork is organized as a Btree with the actual data embedded in the leaf blocks ๐. The root of the Btree is found in block0of the fork. The index (sort order) of the Btree is the hash value of the attribute name. All the blocks contain ablkinfostructure at the beginning โ see typedirfor a description. Nonleaf blocks are identical in format to those for version 1 and version 2 directories, see typedirfor a description again, iykyk. Leaf blocks can refer to "local" or "remote" attribute values. Local values are stored directly in the leaf block. Leaf blocks contain the following fields:hdrโ header containing ablkinfostructure info (magic number0xfbee), a count of active entries,usedbytestotal bytes of names and values, thefirstusedbyte in the name area,holesset if the block needs compaction, and arrayfreemapas fordirleaf blocks.entriesโ array of structures containing ahashval,nameidx(index into the block of the name), and flagsincomplete,root, andlocal.nvlistโ array of structures describing the attribute names and values. Fields always present:valuelen(length of value in bytes),namelen, andname. Fields present for local values:value(value string). Fields present for remote values:valueblk(fork block number of containing the value).
Remote values are stored in an independent block in the attribute fork ๐ฆ. Prior to v5, value blocks had no structure, but in v5 they acquired a header structure with the following fields:
magicโ attr3 remote block magic number,0x5841524d('XARM').offsetโ Byte offset of this data block within the overall attribute value.bytesโ Number of bytes stored in this block.crcโ Checksum of the attribute block contents.uuidโ Filesystem UUID.ownerโ Inode that owns this attribute value.bnoโ Block offset of this block within the inode's attribute fork.lsnโ Log serial number of the last time this block was logged.dataโ The attribute value data.
bmapbtโ files with many extents in their data or attribute fork will have the extents described by the contents of a Btree for that fork, instead of being stored directly in the inode ๐. Each bmap Btree starts with a root block contained within the inode. The other levels of the Btree are stored in filesystem blocks. The blocks are linked to sibling left and right blocks at each level, as well as by pointers from parent to child blocks. Each block contains the following fields:magicโ bmap Btree block magic number,0x424d4150('BMAP').levelโ level of this block above the leaf level.numrecsโ number of records or keys in the block.leftsibโ left (logically lower) sibling block,0if none.rightsibโ right (logically higher) sibling block,0if none.recsโ [leaf blocks only] array of extent records. Each record containsstartoff,startblock,blockcount, andextentflag(1if the extent is unwritten).keysโ [non-leaf blocks only] array of key records. These are the first key value of each block in the level below this one. Each record containsstartoff.ptrsโ [non-leaf blocks only] array of child block pointers. Each pointer is a filesystem block number to the next level in the Btree.
bnobtโ there is one set of filesystem blocks forming the by-block-number allocation Btree for each allocation group ๐. The root block of this Btree is designated by thebnorootfield in the corresponding AGF block. The blocks are linked to sibling left and right blocks at each level, as well as by pointers from parent to child blocks. Each block has the following fields:magicโ BNOBT block magic number,0x41425442('ABTB').levelโ level number of this block,0is a leaf.numrecsโ number of data entries in the block.leftsibโ left (logically lower) sibling block,0if none.rightsibโ right (logically higher) sibling block,0if none.recsโ [leaf blocks only] array of freespace records. Each record containsstartblockandblockcount.keysโ [non-leaf blocks only] array of key records. These are the first value of each block in the level below this one. Each record containsstartblockandblockcount.ptrsโ [non-leaf blocks only] array of child block pointers. Each pointer is a block number within the allocation group to the next level in the Btree.
cntbtโ there is one set of filesystem blocks forming the by-block-count allocation Btree for each allocation group โจ. The root block of this Btree is designated by thecntrootfield in the corresponding AGF block. The blocks are linked to sibling left and right blocks at each level, as well as by pointers from parent to child blocks. Each block has the following fields:magicโ CNTBT block magic number,0x41425443('ABTC').levelโ level number of this block,0is a leaf.numrecsโ number of data entries in the block.leftsibโ left (logically lower) sibling block,0if none.rightsibโ right (logically higher) sibling block,0if none.recsโ [leaf blocks only] array of freespace records. Each record containsstartblockandblockcount.keysโ [non-leaf blocks only] array of key records. These are the first value of each block in the level below this one. Each record containsblockcountandstartblock. (yes bestie, the order flips here โ that's on purpose ๐)ptrsโ [non-leaf blocks only] array of child block pointers. Each pointer is a block number within the allocation group to the next level in the Btree.
dataโ user file blocks, and other blocks whose type is unknown, have this type for display purposes inxfs_db๐. The block data is displayed in hexadecimal format.
dir ๐
okay so a version 1 directory is literally a Btree situation where the directory data is justโฆ embedded in the leaf blocks. no big deal. the root of the Btree lives in block 0 of the file. the index (aka the sort order) is the hash value of the entry name. every block starts with a blkinfo structure that has these fields:
forwโ next sibling block, bestie.backโ previous sibling block.magicโ magic number for this block type.
the non-leaf (node) blocks are giving:
hdrโ header containing ablkinfostructure info (magic number0xfebe), the count of active entries, and the level of this block above the leaves.btreeโ array of entries containinghashvalandbeforefields. thebeforevalue is a block number within the directory file to the child block, and thehashvalis the last hash value in that block.
and the leaf blocks? they're serving:
hdrโ header containing ablkinfostructure info (magic number0xfeeb), the count of active entries,namebytes(total name string bytes),holesflag (block needs compaction), andfreemap(array ofbase,sizeentries for free regions).entriesโ array of structures containinghashval,nameidx(byte index into the block of the name string), andnamelen.namelistโ array of structures containinginumberandname.
dir2 โจ
a version 2 directory has four kinds of blocks, periodt. data blocks start at offset 0 in the file. there are two kinds of data blocks: single-block directories have the leaf information embedded at the end of the block, but data blocks in multi-block directories do not. node and leaf blocks start at offset 32GiB (with either a single leaf block or the root node block). freespace blocks start at offset 64GiB. the node and leaf blocks form a Btree, with references to the data in the data blocks. the freespace blocks form an index of longest free spaces within the data blocks.
a single-block directory block contains these fields:
bhdrโ header containing magic number0x58443242('XD2B') and an arraybestfreeof the longest3free spaces in the block (offset, length).buโ array of union structures. each element is either an entry or a freespace. for entries, there are these fields:inumber,namelen,name, andtag. for freespace, there are these fields:freetag(0xffff),length, andtag. thetagvalue is the byte offset in the block of the start of the entry it is contained in.bleafโ array of leaf entries containinghashvalandaddress. theaddressis a 64-bit word offset into the file.btailโ tail structure containing the total count of leaf entries andstalecount of unused leaf entries.
a data block contains:
dhdrโ header containing magic number0x58443244('XD2D') and an arraybestfreeof the longest3free spaces in the block (offset, length).duโ array of union structures as forbu.
leaf blocks have two possible forms. if the Btree consists of a single leaf then the freespace information is in the leaf block, otherwise it is in separate blocks and the root of the Btree is a node block. a leaf block contains:
lhdrโ header containing ablkinfostructure info (magic number0xd2f1for the single leaf case,0xd2fffor the true Btree case), the total count of leaf entries, andstalecount of unused leaf entries.lentsโ leaf entries, as forbleaf.lbestsโ [single leaf only] array of values which represent the longest freespace in each data block in the directory.ltailโ [single leaf only] tail structure containingbestcountcount oflbests.
a node block is identical to that for types attr and dir.
a freespace block contains:
fhdrโ header containing magic number0x58443246('XD2F'),firstdbfirst data block number covered by this freespace block,nvalidnumber of valid entries, andnusednumber of entries representing real data blocks.fbestsโ array of values as forlbests.
dqblk ๐
the quota information is stored in files referred to by the superblock uquotino and pquotino fields. each filesystem block in a quota file contains a constant number of quota entries. the quota entry size is currently 136 bytes, so with a 4KiB filesystem block size there are 30 quota entries per block. the dquot command is used to locate these entries in the filesystem. the file entries are indexed by the user or project identifier to determine the block and offset. each quota entry has these fields:
magicโ magic number,0x4451('DQ').versionโ version number, currently1.flagsโ flags, values include0x01for user quota,0x02for project quota.idโ user or project identifier.blk_hardlimitโ absolute limit on blocks in use.blk_softlimitโ preferred limit on blocks in use.ino_hardlimitโ absolute limit on inodes in use.ino_softlimitโ preferred limit on inodes in use.bcountโ blocks actually in use.icountโ inodes actually in use.itimerโ time when service will be refused if soft limit is violated for inodes.btimerโ time when service will be refused if soft limit is violated for blocks.iwarnsโ number of warnings issued about inode limit violations.bwarnsโ number of warnings issued about block limit violations.rtb_hardlimitโ absolute limit on realtime blocks in use.rtb_softlimitโ preferred limit on realtime blocks in use.rtbcountโ realtime blocks actually in use.rtbtimerโ time when service will be refused if soft limit is violated for realtime blocks.rtbwarnsโ number of warnings issued about realtime block limit violations.
inobt ๐ฆ
there is one set of filesystem blocks forming the inode allocation Btree for each allocation group. the root block of this Btree is designated by the root field in the corresponding AGI block. the blocks are linked to sibling left and right blocks at each level, as well as by pointers from parent to child blocks. each block has these fields:
magicโ INOBT block magic number,0x49414254('IABT').levelโ level number of this block,0is a leaf.numrecsโ number of data entries in the block.leftsibโ left (logically lower) sibling block,0if none.rightsibโ right (logically higher) sibling block,0if none.recsโ [leaf blocks only] array of inode records. each record containsstartinoallocation-group relative inode number,freecountcount of free inodes in this chunk, andfreebitmap, LSB corresponds to inode0.keysโ [non-leaf blocks only] array of key records. these are the first value of each block in the level below this one. each record containsstartino.ptrsโ [non-leaf blocks only] array of child block pointers. each pointer is a block number within the allocation group to the next level in the Btree.
inode ๐ธ
inodes are allocated in "chunks" of 64 inodes each. usually a chunk is multiple filesystem blocks, although there are cases with large filesystem blocks where a chunk is less than one block. the inode Btree (see inobt above) refers to the inode numbers per allocation group. the inode numbers directly reflect the location of the inode block on disk. use the inode command to point xfs_db to a specific inode. each inode contains four regions: core, next_unlinked, u, and a.
coreโ contains the fixed information.next_unlinkedโ is separated from the core due to journaling considerations, see typeagifieldunlinked.uโ is a union structure that is different in size and format depending on the type and representation of the file data ("data fork").aโ is an optional union structure to describe attribute data, that is different in size, format, and location depending on the presence and representation of attribute data, and the size of theudata ("attribute fork").
xfs_db automatically selects the proper union members based on information in the inode. ๐
okay bestie, the inode core is packed and we're going field by field, no skipping, periodt ๐
magicโ the inode magic number, and it's literally0x494e('IN'). iconic.modeโ the mode and type of the file, exactly as spelled out inchmod(2),mknod(2)andstat(2).versionโ inode version, so1or2.formatโ what flavour theuunion data is:0=xfs_dev_t,1= local file (in-inode directory or symlink),2= extent list,3= Btree root,4= unique id [unused].nlinkv1โ number of links to the file, but for a version 1 inode.nlinkv2โ number of links to the file, for a version 2 inode.projid_loโ the owner's project id (low word; version 2 inode only).projid_hiโ the owner's project id (high word; version 2 inode only).uidโ the owner's user id.gidโ the owner's group id.atimeโ time last accessed (seconds and nanoseconds, fancy).mtimeโ time last modified.ctimeโ time created, or the inode was last modified.sizeโ number of bytes in the file.nblocksโ total number of blocks in the file, indirect and attribute included.extsizeโ the basic/minimum extent size for the file.nextentsโ number of extents in the data fork.naextentsโ number of extents in the attribute fork.forkoffโ attribute fork offset in the inode, measured in 64-bit words from the start ofu.aformatโ format of the attribute data:1= local attribute data,2= extent list,3= Btree root.dmevmaskโ DMAPI event mask.dmstateโ DMAPI state info.newrtbmโ the file is the realtime bitmap and it's in "new" format.preallocโ the file has preallocated data space after EOF.realtimeโ the file's data lives in the realtime subvolume.genโ inode generation number.
and now the u data fork union, which is giving "choose your own adventure" โจ
bmbtโ bmap Btree root. It looks like abmapbtdblock with the redundant info removed.bmxโ array of extent descriptors.devโdev_tfor the block or character device.sfdirโ shortform (in-inode) version 1 directory. It's ahdrholding the parent inode number and a count of active entries in the directory, then an array list ofhdr.countentries. Each entry hasinumber,namelen, and a name string.sfdir2โ shortform (in-inode) version 2 directory. This one's ahdrwith a count of active entries, ani8countof entries whose inumbers don't fit in a 32-bit value, plus the parent inode number โ then an array list ofhdr.countentries. Each entry hasnamelen, a saved offset used when the directory gets converted to a larger form, a name string, and theinumber.symlinkโ symbolic link string value. cute.
and if the attribute fork exists, the a union has these ๐
bmbtโ bmap Btree root, same as above.bmxโ array of extent descriptors.sfattrโ shortform (in-inode) attribute values. It's ahdrwith atotsize(total size in bytes) and a count of active entries, followed by an array list ofhdr.countentries. Each entry hasnamelen,valuelen, root flag, name, and value.
๐ชต log โ bestie, just don't
Log blocks contain the journal entries for XFS. And honestly? It is not useful to poke at these with xfs_db, so use xfs_logprint(8) instead. trust. ๐
refcntbt โ the reference count Btree, per allocation group
There's one set of filesystem blocks forming the reference count Btree for each allocation group. The root block of this Btree is designated by the refcntroot field in the corresponding AGF block. The blocks are linked to sibling left and right blocks at each level, plus by pointers from parent to child blocks. Every block has these fields:
magicโ REFC block magic number,0x52334643('R3FC').levelโ level number of this block;0is a leaf.numrecsโ number of data entries in the block.leftsibโ left (logically lower) sibling block, or0if there isn't one.rightsibโ right (logically higher) sibling block, or0if there isn't one.recsโ [leaf blocks only] array of reference count records. Each record containsstartblock,blockcount, andrefcount.keysโ [non-leaf blocks only] array of key records. These are the first value of each block in the level below this one. Each record containsstartblock.ptrsโ [non-leaf blocks only] array of child block pointers. Each pointer is a block number within the allocation group pointing to the next level in the Btree.
rtrefcbt โ the realtime reference count Btree
There's one reference count Btree for the entire realtime device. Heads up: the startblock and blockcount fields are 32 bits wide and record block counts within a realtime group. The root of this Btree is the realtime refcount inode, which is recorded in the metadata directory. Blocks are linked to sibling left and right blocks at each level, plus by pointers from parent to child blocks. Each block has these fields:
magicโ RTREFC block magic number,0x52434e54('RCNT').levelโ level number of this block;0is a leaf.numrecsโ number of data entries in the block.leftsibโ left (logically lower) sibling block,0if none.rightsibโ right (logically higher) sibling block,0if none.recsโ [leaf blocks only] array of reference count records. Each record containsstartblock,blockcount, andrefcount.keysโ [non-leaf blocks only] array of key records. These are the first value of each block in the level below this one. Each record containsstartblock.ptrsโ [non-leaf blocks only] array of child block pointers. Each pointer is a block number within the allocation group pointing to the next level in the Btree.
rmapbt โ the reverse mapping Btree, per allocation group
There's one set of filesystem blocks forming the reverse mapping Btree for each allocation group. The root block of this Btree is designated by the rmaproot field in the corresponding AGF block. Blocks are linked to sibling left and right blocks at each level, plus by pointers from parent to child blocks. Each block has these fields:
magicโ RMAP block magic number,0x524d4233('RMB3').levelโ level number of this block;0is a leaf.numrecsโ number of data entries in the block.leftsibโ left (logically lower) sibling block,0if none.rightsibโ right (logically higher) sibling block,0if none.recsโ [leaf blocks only] array of reference count records. Each record containsstartblock,blockcount,owner,offset,attr_fork,bmbt_block, andunwritten.keysโ [non-leaf blocks only] array of double-key records. The first ("low") key contains the first value of each block in the level below this one. The second ("high") key contains the largest key that can be used to identify any record in the subtree. Each record containsstartblock,owner,offset,attr_fork, andbmbt_block.ptrsโ [non-leaf blocks only] array of child block pointers. Each pointer is a block number within the allocation group pointing to the next level in the Btree.
rtrmapbt ๐
so there's literally one reverse mapping Btree for each realtime group, bestie. the startblock and blockcount fields are 32 bits wide and they record blocks within a realtime group. the root of this Btree is the reverse-mapping inode, which lives in the metadata directory. blocks get linked to their sibling left and right blocks at every level, plus by pointers from parent to child blocks. each block has these fields:
magicโ RTRMAP block magic number,0x4d415052('MAPR').levelโ level number of this block,0is a leaf.numrecsโ number of data entries in the block.leftsibโ left (logically lower) sibling block,0if none.rightsibโ right (logically higher) sibling block,0if none.recsโ [leaf blocks only] array of reference count records. each record containsstartblock,blockcount,owner,offset,attr_fork,bmbt_block, andunwritten.keysโ [non-leaf blocks only] array of double-key records. the first ("low") key contains the first value of each block in the level below this one. the second ("high") key contains the largest key that can be used to identify any record in the subtree. each record containsstartblock,owner,offset,attr_fork, andbmbt_block.ptrsโ [non-leaf blocks only] array of child block pointers. each pointer is a block number within the allocation group to the next level in the Btree.
rtbitmap ๐
if the filesystem has a realtime subvolume, then the rbmino field in the superblock points at a file that contains the realtime bitmap. every single bit in that bitmap file controls the allocation of one realtime extent, and it's set == free. the bitmap is processed in 32-bit words, and the LSB of a word is used for the first extent controlled by that bitmap word. also the atime field of the realtime bitmap inode holds a counter that controls where the next new realtime file will start. slay.
rtsummary ๐ธ
if the filesystem has a realtime subvolume, then the rsumino field in the superblock points at a file that contains the realtime summary data. the summary file is a two-dimensional array of 16-bit values. each value counts the number of free extent runs (that's consecutive free realtime extents) of a given range of sizes that starts in a given bitmap block. the size ranges are binary buckets, where the low size in the bucket is a power of 2. there are as many size ranges as are necessary given the size of the realtime subvolume. first dimension is the size range, second dimension is the starting bitmap block number (adjacent entries are for the same size, adjacent bitmap blocks).
sb ๐
there is one sb (superblock) structure per allocation group, and it's the first disk block in the allocation group. only the first one (block 0 of the filesystem) is actually used โ the other blocks are redundant information for xfs_repair(8) to use if the first superblock is damaged. fields defined:
magicnumโ superblock magic number,0x58465342('XFSB').blocksizeโ filesystem block size in bytes.dblocksโ number of filesystem blocks present in the data subvolume.rblocksโ number of filesystem blocks present in the realtime subvolume.rextentsโ number of realtime extents thatrblockscontain.uuidโ unique identifier of the filesystem.logstartโ starting filesystem block number of the log (journal). if this value is0the log is"external".rootinoโ root inode number.rbminoโ realtime bitmap inode number.rsuminoโ realtime summary data inode number.rextsizeโ realtime extent size in filesystem blocks.agblocksโ size of an allocation group in filesystem blocks.agcountโ number of allocation groups.rbmblocksโ number of realtime bitmap blocks.logblocksโ number of log blocks (filesystem blocks).versionnumโ filesystem version information. this value is currently1,2,3, or4in the low 4 bits. if the low bits are4then the other bits have additional meanings.1is the original value.2means that attributes were used.3means that version 2 inodes (large link counts) were used.4is the bitmask version of the version number. in this case, the other bits are used as flags (0x0010: attributes were used,0x0020: version 2 inodes were used,0x0040: quotas were used,0x0080: inode cluster alignment is in force,0x0100: data stripe alignment is in force,0x0200: theshared_vnfield is used,0x1000: unwritten extent tracking is on,0x2000: version 2 directories are in use).sectsizeโ sector size in bytes, currently always512. this is the size of the superblock and the other header blocks.inodesizeโ inode size in bytes.inopblockโ number of inodes per filesystem block.fnameโ obsolete, filesystem name.fpackโ obsolete, filesystem pack name.blocklogโ log2 ofblocksize.sectlogโ log2 ofsectsize.inodelogโ log2 ofinodesize.inopblogโ log2 ofinopblock.agblklogโ log2 ofagblocks(rounded up).rextslogโ log2 ofrextents.inprogressโmkfs.xfs(8)orxfs_copy(8)aborted before completing this filesystem.imax_pctโ maximum percentage of filesystem space used for inode blocks.icountโ number of allocated inodes.ifreeโ number of allocated inodes that are not in use.fdblocksโ number of free data blocks.frextentsโ number of free realtime extents.uquotinoโ user quota inode number.pquotinoโ project quota inode number; this is currently unused.qflagsโ quota status flags (0x01: user quota accounting is on,0x02: user quota limits are enforced,0x04: quotacheck has been run on user quotas,0x08: project quota accounting is on,0x10: project quota limits are enforced,0x20: quotacheck has been run on project quotas).flagsโ random flags.0x01: only read-only mounts are allowed.shared_vnโ shared version number (shared readonly filesystems).inoalignmtโ inode chunk alignment in filesystem blocks.unitโ stripe or RAID unit.widthโ stripe or RAID width.dirblklogโ log2 of directory block size (filesystem blocks).
symlink ๐ฆ
symbolic link blocks are used only when the symbolic link value doesn't fit inside the inode. the block content is just the string value, periodt. bytes past the logical end of the symbolic link value have arbitrary values, so don't come for them.
text ๐
user file blocks, and other blocks whose type is unknown, get this type for display purposes in xfs_db. the block data is displayed in two columns: Hexadecimal format and printable ASCII chars. iconic honestly.
๐ DIAGNOSTICS ๐
so many messages can come from the blockget command, bestie. if the filesystem is completely corrupt, a core dump might be produced instead of the message
device is not a valid filesystem
if the filesystem is very large (has many files) then blockget might run out of memory. in this case the message
out of memory
is printed. ๐ญ
the following is a description of the most likely problems and the associated messages. most of the diagnostics produced are only meaningful with an understanding of the structure of the filesystem โ iykyk.
agf_freeblks n, counted m in ag a
the freeblocks count in the allocation group header for allocation group a doesn't match the number of blocks counted free.
agf_longest n, counted m in ag a
the longest free extent in the allocation group header for allocation group a doesn't match the longest free extent found in the allocation group.
agi_count n, counted m in ag a
the allocated inode count in the allocation group header for allocation group a doesn't match the number of inodes counted in the allocation group.
agi_freecount n, counted m in ag a
the free inode count in the allocation group header for allocation group a doesn't match the number of inodes counted free in the allocation group.
block a/b expected inum 0 got i
the block number is specified as a pair (allocation group number, block in the allocation group). the block is used multiple times (shared), between multiple inodes. this message usually follows a message of the next type.
block a/b expected type unknown got y
the block is used multiple times (shared).
block a/b type unknown not expected
โจ SEE ALSO โจ
bestie if you wanna go deeper (and you KNOW you do ๐ ) here's the whole friend group:
mkfs.xfs(8)โ makes the filesystem in the first place, the origin story ๐ฑxfs_admin(8)โ tweaks the label and UUID and stuff ๐ท๏ธxfs_copy(8)โ copies an XFS filesystem, whole thing, no cap ๐xfs_logprint(8)โ prints the log, for when you need to snoop on the journal ๐xfs_metadump(8)โ dumps the metadata so you can ship it off to someone smarter ๐xfs_ncheck(8)โ checks inode numbers against the filesystem, very detective-core ๐ต๏ธxfs_repair(8)โ the one you call when things are lowkey falling apart ๐mount(8)โ mounts the thing, obviously, the whole point ๐๏ธchmod(2)โ the syscall for changing file modes ๐mknod(2)โ the syscall for making device nodes and stuff ๐งฑstat(2)โ the syscall for asking a file how it's doing ๐xfs(5)โ the XFS filesystem format deep dive, for the lore girlies ๐
and that's the whole page, bestie, we made it to the end ๐ this one came from the xfs(8) family of man pages โ source and version info live in that footer line at the bottom of the original, dated the usual manpage date spot. now go run it responsibly, back up your metadata first, and don't poke a live filesystem with a debugger unless you're ready for main character energy in the worst way ๐ญ๐ slay, and see you in the next manpage ๐ฆ
๐ฆ where this page comes from
- arch rolling: xfsprogs 7.2.0-1
- arch rolling: xfsprogs 7.2.1-1 ยท GPL-2.0-only AND LGPL-2.1-only
- nixpkgs unstable: xfsprogs 7.2.1
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms