Before you copy a tree onto XFS, xfs_estimate tells you how much room it will actually need there, which is rarely the same number as du gives you. This guide uses the installed xfsprogs 6.6.0 command to compare a normal estimate with block-size and log-size choices, without creating or changing a filesystem.
Allow about five minutes for a one-off estimate, plus time to inspect any large directory. You need the xfs_estimate program and read access to the paths you want to inspect. The examples use /tmp, so they do not require elevated privileges. Do not use sudo merely because the destination filesystem will eventually be mounted by root.
Confirm that the command is installed and record its version before putting an estimate in a capacity plan or script. The local package reports version 6.6.0 here.
xfs_estimate -V
dpkg-query -W -f='${Package} ${Version}\n' xfsprogs
Expected output includes:
xfs_estimate version 6.6.0
xfsprogs 6.6.0-1ubuntu2.1
Package revisions vary by distribution. Keep the version with your notes, because estimate details can change between releases.
Give the command one or more directory paths. It estimates each argument separately and does not cross mount points. It uses a 4096-byte filesystem block and a default log size of 1000 blocks unless you select different values.
xfs_estimate /path/to/directory
For a small test directory, output has this shape:
/tmp/xfs-estimate-example will take about 4.5 megabytes
That figure is an estimate of the copy on XFS, not the current du total and not a promise that a destination has enough free space. It reflects the simulated XFS layout from the selected block and log settings.
To compare several independent trees, list them in one invocation:
xfs_estimate /srv/project /srv/archive /var/lib/example
Each path gets its own line. A path that does not exist is not necessarily rejected by this utility, so check spelling and existence separately when the result matters:
test -d /path/to/directory && xfs_estimate /path/to/directory
The -v option shows the inputs used for the calculation: directory, block size, block count, estimated megabytes and log size. This is the useful form for a change record or a comparison.
xfs_estimate -v /path/to/directory
Typical output is tabular:
directory bsize blocks megabytes logsize
/tmp/xfs-estimate-example 4096 1144 4.5MB 4096000
bsize.There is no need to add -v to a script that only needs the human-readable sentence. Use verbose output when you need to see why two runs differ.
Use -b when the intended XFS filesystem has a known fundamental block size. The default is 4096 bytes. A trailing k multiplies the number by 1024, so 64k means 65536 bytes.
xfs_estimate -v -b 64k /path/to/directory
Check that the verbose row reports 65536 in the bsize column. Do not confuse this option with the host filesystem's current block size: it is a parameter to the estimate and does not reformat, mount or modify anything.
If you are comparing a planned destination with a current one, make the block-size assumption explicit in the record:
printf '%s\n' 'planned XFS block size: 64 KiB'
xfs_estimate -v -b 64k /path/to/directory
The log choice matters to the estimate. Use -i for an internal log and -e for an external log. Without either option, the command uses its default log size of 1000 blocks. A log size may have a trailing k for 1024-byte units or m for 1048576-byte units.
xfs_estimate -v -i 1m /path/to/directory
xfs_estimate -v -e 10m /path/to/directory
Use only the option that matches the filesystem design you are testing, since the two commands describe different layouts. In the second run, verify that the verbose logsize is 10485760, the byte value for 10 MiB.
An external log is not created by this command, and the command does not check that a future log device exists. Treat the result as planning data. Before provisioning, separately validate the proposed device, mount options and available capacity using your normal change process.
First repeat the same path with -v, then compare one input at a time. This keeps a changed block size from being mistaken for a changed directory.
xfs_estimate -v /path/to/directory
xfs_estimate -v -b 4096 /path/to/directory
xfs_estimate -v -b 64k /path/to/directory
For usage syntax, run xfs_estimate -h. For a version-only check, use xfs_estimate -V. Neither action changes filesystem state.
xfs_estimate version.-v when the block count or log assumption needs auditing.-b, -i or -e to the planned XFS layout.