Linux "xfs_db" Command Line Options and Examples
debug an XFS filesystem

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..


Usage:

xfs_db [ -c cmd ] ... [ -i|r|x|F ] [ -f ] [ -l logdev ] [ -p progname ] device
    xfs_db -V






Command Line Options:

-l
Specifies the device where the filesystems external log resides. Only for those filesystems which usean external log. See the mkfs.xfs(8) -l option, and refer to xfs(5) for a detailed description of theXFS log.
xfs_db -l ...
-p
Set the program name to progname for prompts and some error messages, the default value is xfs_db.
xfs_db -p ...
-x
Specifies expert mode. This enables the (write, blocktrash, crc invalidate/revalidate) commands.
xfs_db -x ...
-V
CONCEPTSxfs_db commands can be broken up into two classes. Most commands are for the navigation and display of datastructures in the filesystem. Other commands are for scanning the filesystem in some way.Commands which are used to navigate the filesystem structure take arguments which reflect the names offilesystem structure fields. There can be multiple field names separated by dots when the underlying struc‐tures are nested, as in C. The field names can be indexed (as an array index) if the underlying field is anarray. 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 struc‐ture. This can be a filesystem block, an inode or quota (smaller than a filesystem block), or a directoryblock (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. Com‐mands which follow the structure of the filesystem always set the type as well as the address. Commands whichexamine pieces of an individual file (inode) need the current inode to be set, this is done with the inodecommand.The current address/type information is actually maintained in a stack that can be explicitly manipulated withthe 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 cur‐rent allocation group which is manipulated by some commands. The initial allocation group is 0.COMMANDSMany commands have extensive online help. Use the help command for more details on any command.a See the addr command.ablock filoffSet current address to the offset filoff (a filesystem block number) in the attribute area of the cur‐rent inode.addr [field-expression]Set current address to the value of the field-expression. This is used to "follow" a reference in onestructure 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 cur‐rent allocation group.agfl [agno]Set current address to the AGFL block for allocation group agno. If no argument is given, use the cur‐rent allocation group.agi [agno]Set current address to the AGI block for allocation group agno. If no argument is given, use the cur‐rent allocation group.b See the back command.back Move to the previous location in the position ring.blockfreeFree block usage information collected by the last execution of the blockget command. This must be donebefore another blockget command can be given, presumably with different arguments than the previousone.blockget [-npvs] [-b bno] ... [-i ino] ...Get block usage and check filesystem consistency. The information is saved for use by a subsequentblockuse, ncheck, or blocktrash command.
xfs_db -V ...
-b
is used to specify filesystem block numbers about which verbose information should be printed.
xfs_db -b ...
-i
is used to specify inode numbers about which verbose information should be printed.
xfs_db -i ...
-s
restricts output to severe errors only. This is useful if the output is too long otherwise.
xfs_db -s ...
-v
blocktrash [-z] [-o offset] [-n count] [-x min] [-y max] [-s seed] [-0|1|2|3] [-t type] ...Trash randomly selected filesystem metadata blocks. Trashing occurs to randomly selected bits in thechosen blocks. This command is available only in debugging versions of xfs_db. It is useful for test‐ing xfs_repair(8).
xfs_db -v ...
-0
These are used to set the operating mode for blocktrash. Only one can be used: -0 changed bitsare cleared; -1 changed bits are set; -2 changed bits are inverted; -3 changed bits are random‐ized.
xfs_db -0 ...
-n
supplies the count of block-trashings to perform (default 1).
xfs_db -n ...
-y
sets the maximum size of bit range to be trashed. The default value is 1024.
xfs_db -y ...
-c
specifies a count of blocks to process. The default value is 1 (the current block only).
xfs_db -c ...
-r
Recalculate the current structure's correct CRC value, and write it to disk.
xfs_db -r ...
-a
enables processing of attribute data.
xfs_db -a ...
-d
enables processing of directory data.
xfs_db -d ...
-f
enables processing of regular file data.
xfs_db -f ...
-q
enables processing of quota file data.
xfs_db -q ...
-R
enables processing of realtime control file data.
xfs_db -R ...
-e
specifies that the histogram buckets are equal-sized, with the size specified as i.
xfs_db -e ...