xfs_copy(8)

๐ŸŽ€ NAME ๐ŸŽ€

okay so the manual page is xfs_copy(8) and it's all about this: xfs_copy - copy the contents of an XFS filesystem ๐Ÿ’–

๐Ÿงš SYNOPSIS ๐Ÿงš

xfs_copy [ -bd ] [ -L log ] source target1 [ target2 ... ]
xfs_copy -V

โœจ DESCRIPTION โœจ

okay so xfs_copy copies an XFS filesystem to one or more targets in parallel ๐Ÿ”ฅ (see xfs(5)). The first one, the source argument, has to be the pathname of the device or file that holds the XFS filesystem. Everything after that is one or more target devices or file names. If your targets are devices, you get a copy of the source XFS filesystem on each one ๐Ÿ’…. A target can also be a regular file, and then you get an image of the source filesystem saved inside that file ๐Ÿฆ‹. If the file doesn't exist yet, xfs_copy makes it for you ๐Ÿซถ.

The file ends up the same size as the source filesystem, but here's the lowkey magic ๐Ÿช„: if the file lives on an XFS filesystem, it only eats roughly the space the source filesystem and its XFS log actually use. Why? xfs_copy seeks over the free blocks instead of copying them, and XFS handles sparse files really efficiently. It's giving space saver energy ๐ŸŒˆ.

โš ๏ธ bestie, only copy the right kinds of filesystems! xfs_copy should only be used on unmounted filesystems, read-only mounted filesystems, or frozen filesystems (see xfs_freeze(8)). Otherwise the copies come out inconsistent or corrupt ๐Ÿ’€.

xfs_copy never touches the source filesystem, not even a little ๐Ÿ™ˆ. Every new target is identical to the original except that each one gets a brand new unique filesystem identifier (UUID). So if the old and new filesystems are going to be used as separate, distinct filesystems, you should make the copies with xfs_copy or xfsdump(8)/xfsrestore(8) instead of dd(1) or other block-by-block disk copying programs ๐Ÿ‘‘.

xfs_copy uses synchronous writes so write errors actually get caught ๐Ÿ”.

It also uses pthreads(7) for simultaneous parallel writes ๐Ÿงต. It spins up one extra thread for each target it's writing to, and all of those threads die if xfs_copy terminates or aborts ๐Ÿ’œ.

๐Ÿ’… OPTIONS ๐Ÿ’…

  • -d โ€” makes a duplicate, true clone filesystem ๐Ÿ‘ฏ. Only do this if the new filesystem is going to replace the original, like when you're swapping out a disk ๐Ÿ”„.
  • -b โ€” the buffered option ๐Ÿงธ. It makes sure direct IO isn't attempted on any of the target files, which is clutch when the filesystem holding the target doesn't support direct IO.
  • -L log โ€” tells xfs_copy where to put its log file, if you don't want the default /var/tmp/xfs_copy.log.XXXXXX ๐Ÿ“.
  • -V โ€” prints the version number and then bounces ๐Ÿ‘‹.

๐Ÿ”ฎ DIAGNOSTICS ๐Ÿ”ฎ

xfs_copy reports errors to both stderr and a more detailed log file ๐Ÿ“œ. That log is named like /var/tmp/xfs_copy.log.XXXXXX, or it's whatever you picked with the -L option.

If xfs_copy hits a write error on a target, that one copy gets aborted ๐Ÿ™…โ€โ™€๏ธ. An error message goes to both stderr and the log file, but the rest of the copies keep going, no drama ๐ŸŒธ. When xfs_copy finally terminates, it reports all the aborted targets to both stderr and the log file again ๐Ÿ“ฃ.

If all targets abort, or if there's an error reading the source filesystem, xfs_copy immediately aborts ๐Ÿ˜ญ.

The exit code is 0 if every target copied successfully, and 1 if any target failed ๐Ÿฅน.

๐Ÿ“ NOTES ๐Ÿ“

ngl this one is important ๐Ÿซ . When you're moving a filesystem from one disk to another, and the original is way smaller than the new disk so you're going to grow it, we recommend using mkfs.xfs(8) and xfsdump(8)/xfsrestore(8) instead of xfs_copy and xfs_growfs(8) ๐Ÿ™. The layout you get from xfs_copy/xfs_growfs is almost always worse than what mkfs.xfs/xfsdump/xfsrestore gives you. For small filesystems, that difference can really hurt performance ๐ŸŒ. This comes from the way xfs_growfs(8) works, not from any shortcoming in xfs_copy itself ๐Ÿ’โ€โ™€๏ธ.

๐Ÿšซ CAVEATS ๐Ÿšซ

xfs_copy can't copy XFS filesystems that have a real-time section, or XFS filesystems with external logs ๐Ÿ™…. In both cases it aborts with an error message, so don't be surprised ๐Ÿ˜ค.

๐Ÿฆ‹ SEE ALSO ๐Ÿฆ‹

mkfs.xfs(8), xfsdump(8), xfsrestore(8), xfs_freeze(8), xfs_growfs(8), xfs(5). go read those, they're iconic ๐Ÿ’–


ok that's the whole xfs_copy(8) page, from the System Manager's Manual, all tea spilled ๐Ÿซถโœจ periodt ๐Ÿ’…๐ŸŒˆ

๐Ÿ“ฆ where this page comes from