LinuxCommandLibrary

xfs_bmap

Show block mapping for a file

SYNOPSIS

xfs_bmap [-adlpstv] [-n num] [-o offset] file

PARAMETERS

-a
    Display attribute fork mapping.

-d
    Display data fork mapping (default).

-l
    Follow symbolic links.

-n num
    Display only the first num mappings.

-o offset
    Start display at offset (in bytes).

-p
    Print physical block numbers instead of logical block numbers.

-s
    Display summary information.

-t
    Terse output format.

-v
    Verbose output.

file
    The file to examine.

DESCRIPTION

The xfs_bmap command is a utility used to display the block map of a file within an XFS filesystem.
It provides detailed information about the file's extents, including their starting block numbers, lengths, and the type of allocation used (e.g., data, attribute, real-time).
This tool is invaluable for debugging filesystem issues, understanding file fragmentation, and analyzing storage utilization. It is mainly used by developers, system administrators, and storage engineers.
The output provides a granular view of how a file is physically laid out on the storage device.
The command can also provide information about the disk allocation of directories, symbolic links, and other filesystem objects, and can decode attribute forks as well as the data fork.
It is useful in conjunction with other XFS tools for filesystem maintenance, tuning, and recovery.
It does require root privileges to run and access raw disk data.

CAVEATS

Requires root privileges to operate. The output format may change between XFS versions.

OUTPUT INTERPRETATION

The output of xfs_bmap shows the file's extents. Each line usually represents an extent and includes information like starting block, length, and flags indicating the type of allocation. Understanding these flags is crucial for interpreting the output.

EXAMPLES

xfs_bmap mydata.txt: Displays the block map of the file 'mydata.txt'.
xfs_bmap -a mydata.txt: Displays the attribute fork block map of 'mydata.txt'.
xfs_bmap -n 5 mydata.txt: Displays the first 5 mappings of 'mydata.txt'.

SEE ALSO

xfs(5), xfs_db(8), xfs_info(8)

Copied to clipboard