The xfs_copy command is to copy an XFS file system with an internal log (XFS file systems with external log subvolumes cannot be copied with xfs_copy). One or more copies can be created on disk partitions, logical volumes, or files. Each copy has an unique file system identifier, which enables them to be run as separate file systems on the same system. (Programs that do block-by-block copying, such as dd, do not create unique file system identifiers.) Multiple copies are created in parallel.
Here is an example of the xfs_copy command:
# xfs_copy /dev/disk/by-vdisk/c5t7 /dev/disk/by-vdisk/c5t6 ... 10% ... 20% ... 30% ... 40% ... 50% ... 60% ... 70% ... 80% ... 90% ... 100% Done. All copies completed.
Copy XFS filesystem from a device to device
# xfs_copy /dev/disk/by-vdisk/c5t7 /dev/disk/by-vdisk/c5t6
Copy XFS filesystem from a device to a file image
The target can also be the name of a regular file, in which case an image of the source XFS filesystem is created in that file. If the file does not exist, xfs_copy creates the file. The length of the resulting file is equal to the size of the source filesystem.
However, if the file is created on an XFS filesystem, the file consumes roughly the amount of space actually used in the source filesystem by the filesystem and the XFS log. The space saving is because xfs_copy seeks over free blocks instead of copying them and the XFS filesystem supports sparse files efficiently.
# xfs_copy /dev/disk/by-vdisk/c5t7 /c5t6/c5t7xfsimage
Copy XFS filesystem to multiple targets
# xfs_copy [ -bd ] [ -L log ] source target1 [ target2 ... ]
xfs_copy copies an XFS filesystem to one or more targets in parallel. The first (source) argument must be the pathname of the device or file containing the XFS filesystem.
Duplicated a XFS filesystem
With -d option, xfs_copy create a duplicate (true clone) filesystem. This should be done only if the new filesystem will be used as a replacement for the original filesystem (such as in the case of disk replacement).
Disable direct i/o
with -b option, xfs_copy ensure direct IO is not attempted to any of the target files. This is useful when the filesystem holding the target file does not support direct IO.
Log file location
With -L option, xfs_copy specifies the location of the log if the default location of /var/tmp/xfs_copy.log.XXXXXX is not desired.
xfs_copy reports errors to both stderr and in more detailed form to a generated log file whose name is of the form /var/tmp/xfs_copy.log.XXXXXX or a log file specified by the -L option.
If xfs_copy detects a write error on a target, the copy of that one target is aborted and an error message is issued to both stderr and the log file, but the rest of the copies continue. When xfs_copy terminates, all aborted targets are reported to both stderr and the log file.
Check xfs_copy version
With -V option, xfs_copy prints the version number and exits.
If all targets abort or if there is an error reading the source filesystem, xfs_copy immediately aborts.
xfs_copy returns an exit code of 0 if all targets are successfully copied and an exit code of 1 if any target fails.
unmounted filesystem only
xfs_copy should only be used to copy unmounted filesystems, read-only mounted filesystems, or frozen filesystems (see xfs_freeze(8)). Otherwise, the generated filesystem(s) would be inconsistent or corruption
Not for reatime section, Not for external logs
xfs_copy does not copy XFS filesystems that have a real-time section or XFS filesystems with external logs. In both cases, xfs_copy aborts with an error message.
No change to source
xfs_copy does not alter the source filesystem in any way. Each new (target) filesystem is identical to the original filesystem except that new filesystems each have a new unique filesystem identifier (UUID). Therefore, if both the old and new filesystems will be used as separate distinct filesystems, xfs_copy or xfsdump(8)/xfsrestore(8) should be used to generate the new filesystem(s) instead of dd(1) or other programs that do block-by-block disk copying.
Multiple thread copy
xfs_copy uses pthreads(7) to perform simultaneous parallel writes. xfs_copy creates one additional thread for each target to be written. All threads die if xfs_copy terminates or aborts.
xfs_copy uses synchronous writes to ensure that write errors are detected.
Do not use it to copy a smaller filesystem to a bigger one
When moving filesystems from one disk to another, if the original filesystem is significantly smaller than the new filesystem, and will be made larger, we recommend that mkfs.xfs(8) and xfsdump(8)/xfsrestore(8) be used instead of using xfs_copy and xfs_growfs(8). The filesystem layout resulting from using xfs_copy/xfs_growfs is almost always worse than the result of using mkfs.xfs/xfsdump/xfsrestore but in the case of small filesystems, the differences can have a significant performance impact. This is due to the way xfs_growfs works, and not due to any shortcoming in xfs_copy itself.