When you want to copy some data to an XFS File System, you may wondering how much space XFS will take. xfs_estimate is the right cmd you are looking for:

The xfs_estimate utility is used to estimate the amount of space that a xfs file system will take.

Here are some xfs_estimate examples:

Suppose I have a directory /home/java, ext4 file system, here is the space usage:

du -k /home/java
131388    /home/java

To estimate how much xfs will take, run

$xfs_estimate /home/java
/home/java will take about 132.8 megabytes

So, this means if copy /home/java to an XFS File System, it will take XFS 132.8 megabytes.

To have more detailed estimate:

$xfs_estimate -v /home/java
directory                               bsize   blocks    megabytes    logsize
/home/java                               4096    33985      132.8MB    4096000

To estimate how much xfs will take with specified block size

This is an interesting option, you can chose the best block size for an to be migrated existing file system

$xfs_estimate -b 512  -v /home/java
directory                               bsize   blocks    megabytes    logsize
/home/java                                512   263910      128.9MB     512000

See the different when using block size 4096

$xfs_estimate -b 4096 -v /home/java
directory                               bsize   blocks    megabytes    logsize
/home/java                               4096    33985      132.8MB    4096000

Similarily, we can also specify logsize to estimate how much an XFS File System will take

To estimate how much xfs will take with specified internal log size

$xfs_estimate -b 4096 -i 512 -v /home/java
directory                               bsize   blocks    megabytes    logsize
/home/java                               4096    32985      128.8MB        512

To estimate how much xfs will take with specified external log size

$xfs_estimate -b 4096 -e 512 -v /home/java
directory                               bsize   blocks    megabytes    logsize
/home/java                               4096    32985      128.8MB        512

Note: blocksize may have 'k' appended to indicate x1024 logsize may also have 'm' appended to indicate (1024 x 1024)