отлаживать файловую систему XFS (debug an XFS filesystem)
Команды (Commands)
Many commands have extensive online help. Use the help
command
for more details on any command.
a
See the addr
command.
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_remove [-r|-u|-s] [-n]
name
Remove the specified extended attribute from the current
file.
-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.
-n
Do not enable 'noattr2' mode on V4 filesystems.
attr_set [-r|-u|-s] [-n] [-R|-C] [-v
namelen]
name
Sets an extended attribute on the current file with the
given name.
-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.
-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
Set the attribute value to a string of this length
containing the letter 'v'.
b
See the back
command.
back
Move to the previous location in the position ring.
blockfree
Free block usage information collected by the last
execution of the blockget
command. This must be done
before another blockget
command can be given, presumably
with different arguments than the previous one.
blockget [-npvs] [-b
bno] ... [-i
ino] ...
Get block usage and check filesystem consistency. The
information is saved for use by a subsequent blockuse
,
ncheck
, or blocktrash
command.
-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 the xfs_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 of xfs_db
are 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 [-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 the chosen
blocks. This command is available only in debugging
versions of xfs_db
. It is useful for testing
xfs_repair(8).
-0
| -1
| -2
| -3
These are used to set the operating mode for
blocktrash
. Only one can be used: -0
changed bits
are cleared; -1
changed bits are set; -2
changed
bits are inverted; -3
changed bits are randomized.
-n
supplies the count of block-trashings to perform
(default 1).
-o
supplies the bit offset at which to start trashing
the block. If the value is preceded by a '+', the
trashing will start at a randomly chosen offset
that is larger than the value supplied. The
default is to randomly choose an offset anywhere in
the block.
-s
supplies a seed to the random processing.
-t
gives a type of blocks to be selected for trashing.
Multiple -t
options may be given. If no -t
options
are given then all metadata types can be trashed.
-x
sets the minimum size of bit range to be trashed.
The default value is 1.
-y
sets the maximum size of bit range to be trashed.
The default value is 1024.
-z
trashes the block at the top of the stack. It is
not necessary to run blockget
if this option is
supplied.
blockuse [-n] [-c
count]
Print usage for current filesystem block(s). For each
block, the type and (if any) inode are printed.
-c
specifies a count of blocks to process. The default
value is 1 (the current block only).
-n
specifies that file names should be printed. The
prior blockget
command must have also specified the
-n
option.
bmap [-a] [-d] [
block [
len]]
Show the block map for the current inode. The map display
can be restricted to an area of the file with the block
and len arguments. If block is given and len is omitted
then 1 is assumed for len.
The -a
and -d
options are used to select the attribute or
data area of the inode, if neither option is given then
both areas are shown.
btdump [-a] [-i]
If the cursor points to a btree node, dump the btree from
that block downward. If instead the cursor points to an
inode, dump the data fork block mapping btree if there is
one. If the cursor points to a directory or extended
attribute btree node, dump that. By default, only records
stored in the btree are dumped.
-a
If the cursor points at an inode, dump the extended
attribute block mapping btree, if present.
-i
Dump all keys and pointers in intermediate btree
nodes, and all records in leaf btree nodes.
btheight [-b
blksz] [-n
recs] [-w
max|-w
min] btree types...
For a given number of btree records and a btree type,
report the number of records and blocks for each level of
the btree, and the total number of blocks. The btree type
must be given after the options.
A raw btree geometry can be provided 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, and rmapbt.
Options are as follows:
-b
is used to override the btree block size. The
default is the filesystem block size.
-n
is used to specify the number of records to store.
This argument is required.
-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.
check
See the blockget
command.
convert
type number [
type number] ...
type
Convert from one address form to another. The known
types, with alternate names, are:
agblock
or agbno
(filesystem block within an allocation
group)
agino
or aginode
(inode number within an allocation
group)
agnumber
or agno
(allocation group number)
bboff
or daddroff
(byte offset in a daddr
)
blkoff
or fsboff or agboff
(byte offset in a agblock
or
fsblock
)
byte
or fsbyte
(byte address in filesystem)
daddr
or bb
(disk address, 512-byte blocks)
fsblock
or fsb
or fsbno
(filesystem block, see the
fsblock
command)
ino
or inode
(inode number)
inoidx
or offset
(index of inode in filesystem block)
inooff
or inodeoff
(byte offset in inode)
Only conversions that "make sense" are allowed. The
compound form (with more than three arguments) is useful
for conversions such as convert agno
ag agbno
agb fsblock
.
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. Each 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 [
d]
Set current address to the daddr (512 byte block) given by
d. If no value for d is given, the current address is
printed, expressed as a daddr. The type is set to data
(uninterpreted).
dblock
filoff
Set current address to the offset filoff (a filesystem
block number) in the data area of the current inode.
debug [
flagbits]
Set debug option bits. These are used for debugging
xfs_db
. If no value is given for flagbits, print the
current debug option bits. These are for the use of the
implementor.
dquot [
-g|
-p|
-u]
id
Set current address to a group, project or user quota
block for the given ID. Defaults to user quota.
echo [
arg] ...
Echo the arguments to the output.
f
See the forward
command.
forward
Move forward to the next entry in the position ring.
frag [-adflqRrv]
Get file fragmentation data. This prints information about
fragmentation of file data in the filesystem (as opposed
to fragmentation of freespace, for which see the freesp
command). Every file in the filesystem is examined to see
how far from ideal its extent mappings are. 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 are examined. If no options are given
then all are assumed set, otherwise just those
given 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 [-bcds] [-A
alignment] [-a
ag] ... [-e
i] [-h
h1] ... [-m
m]
Summarize free space for the filesystem. The free blocks
are examined and totalled, and displayed in the form of 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 no -a
options are given then all
allocation groups are processed.
-b
specifies that the histogram buckets are binary-
sized, with the starting sizes being the powers of
2.
-c
specifies that freesp
will search the by-size (cnt)
space Btree instead of the default by-block (bno)
space Btree.
-d
specifies that every free extent will be displayed.
-e
specifies that the histogram buckets are equal-
sized, with the size specified as i.
-h
specifies a starting block number for a histogram
bucket as h1. Multiple -h
's are given to specify
the complete set of buckets.
-m
specifies that the histogram starting block numbers
are powers of m. This is the general case of -b
.
-s
specifies that a final summary of total free
extents, free blocks, and the average free extent
size is printed.
fsb
See the fsblock
command.
fsblock [
fsb]
Set current address to the fsblock value given by fsb. If
no value for fsb is given the current address is printed,
expressed as an fsb. The type is set to data
(uninterpreted). XFS filesystem block numbers are computed
((agno << agshift) | agblock) where agshift depends on the
size of an allocation group. Use the convert
command to
convert to and from this form. Block numbers given for
file blocks (for instance from the bmap
command) are in
this form.
fsmap [
start ] [
end ]
Prints the mapping of disk blocks used by an XFS
filesystem. The map lists each extent used by files,
allocation group metadata, journalling logs, and static
filesystem metadata, as well as any regions that are
unused. All blocks, offsets, and lengths are specified in
units of 512-byte blocks, no matter what the filesystem's
block size is. The optional
start and
end arguments can
be used to constrain
the output to a particular range of
disk blocks.
fuzz [-c] [-d]
field action
Write 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.
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
Skip write verifiers and CRC recalculation; allows
invalid data to be written to disk.
-d
Skip write verifiers but perform CRC recalculation;
allows invalid data to be written to disk to test
detection of invalid data.
hash
string
Prints the hash value of string using the hash function of
the XFS directory and attribute implementation.
help [
command]
Print help for one or all commands.
info
Displays selected geometry information about the
filesystem. The output will have the same format that
mkfs.xfs(8) prints when creating a filesystem or
xfs_info(8) prints when querying a filesystem.
inode [
inode#]
Set the current inode number. If no inode# is given, print
the current inode number.
label [
label]
Set 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 - use of a
longer label will result in truncation and a warning will
be issued. If no label is given, the current filesystem
label is printed.
log [stop | start
filename]
Start logging output to filename, stop logging, or print
the current logging status.
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 is not specified, the log
is reformatted to the current cycle. If the log stripe
unit is not 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 will help when diagnosing
minimum log size calculation errors.
ls [-i] [
paths]...
List 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.
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 -i
options are given then all inodes are printed.
-s
specifies that only setuid and setgid files are
printed.
p
See the print
command.
path
dir_path
Walk the directory tree to an inode using the supplied
path. Absolute and relative paths are supported.
pop
Pop location from the stack.
print [
field-expression] ...
Print field values. If no argument is given, print all
fields in the current structure.
push [
command]
Push location to the stack. If command is supplied, set
the current location to the results of command after
pushing the old location.
q
See the quit
command.
quit
Exit xfs_db
.
ring [
index]
Show position ring (if no index argument is given), or
move to a specific entry in the position ring given by
index.
sb [
agno]
Set current address to SB header in allocation group agno.
If no agno is given, use the current allocation group
number.
source
source-file
Process commands from source-file. source
commands can be
nested.
stack
View the location stack.
type [
type]
Set the current data type to type. If no argument is
given, show 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
and
text
. See the TYPES section below for more information on
these data types.
timelimit [
OPTIONS]
Print the minimum and maximum supported values for inode
timestamps, quota expiration timers, and quota grace
periods supported by this filesystem. 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 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.
uuid [
uuid |
generate |
rewrite |
restore]
Set the filesystem universally unique identifier (UUID).
The filesystem UUID can be used by mount(8) instead of
using a device special file. The uuid can be set directly
to the desired UUID, or it can be automatically generated
using the generate
option. These options will both write
the UUID into every copy of the superblock in the
filesystem. On a CRC-enabled filesystem, this will set an
incompatible superblock flag, and the filesystem will not
be mountable with older kernels. This can be reverted
with the restore
option, which will copy the original UUID
back into place and clear the incompatible flag as needed.
rewrite
copies the current UUID from the primary
superblock to all secondary copies of the superblock. If
no argument is given, the current filesystem UUID is
printed.
version [
feature |
versionnum features2]
Enable selected features for a filesystem (certain
features can be enabled on an unmounted filesystem, after
mkfs.xfs(8) has created the filesystem). Support for
unwritten extents can be enabled using the extflg
option.
Support for version 2 log format can be enabled using the
log2
option. Support for extended attributes can be
enabled using the attr1
or attr2
option. Once enabled,
extended attributes cannot be disabled, but the user may
toggle between attr1
and attr2
at will (older kernels may
not support the newer version).
If no argument is given, the current version and feature
bits are printed. With one argument, this command will
write the updated version number into every copy of the
superblock in the filesystem. If two arguments are given,
they will be used as numeric values for the versionnum and
features2 bits respectively, and their string equivalent
reported (but no modifications are made).
write [-c|-d] [
field value] ...
Write a value to disk. Specific fields can be set in
structures (struct mode), or a block can be set to data
values (data mode), or a block can be set to string values
(string mode, for symlink blocks). The operation happens
immediately: there is no buffering.
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
this 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 write
with
no arguments gives more information on the allowed
commands.
-c
Skip write verifiers and CRC recalculation; allows
invalid data to be written to disk.
-d
Skip write verifiers but perform CRC recalculation.
This allows invalid data to be written to disk to
test detection of invalid data. (This is not
possible for some types.)