Estimate XFS Space Before You Copy a Directory
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.
The route
Jump straight to the step you need, or tick off Done means at the end.
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.
1. Check the installed command
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.
2. Run a baseline estimate
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
3. Turn on verbose output when the number needs explaining
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
- blocks is the estimated count at the displayed
bsize. - logsize is shown in bytes here, even though the default is described as 1000 blocks. Compare like with like: changing a block size or log choice changes the model.
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.
4. Model the destination block size
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
5. Model an internal or external log
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.
6. Investigate a surprising result safely
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
- No mount crossings. The command estimates a copy to XFS and does not cross mount points.
- Read-only. It reads directory content but does not copy, delete, resize or mount anything.
- Settings change the answer. Different block and log settings produce different estimates, so record them with the result.
- Check paths separately. Use a path check when a typo would make a planning decision unsafe.
For usage syntax, run xfs_estimate -h. For a version-only check, use xfs_estimate -V. Neither action changes filesystem state.
Done means
- Version recorded. You noted the installed
xfs_estimateversion. - Path confirmed. You ran the estimate against the intended directory and checked the path spelling.
- Verbose used when needed. You used
-vwhen the block count or log assumption needs auditing. - Layout matched. You matched
-b,-ior-eto the planned XFS layout. - Model treated as a model. You treated the output as an estimate, then checked real destination capacity separately.