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_copyshould only be used on unmounted filesystems, read-only mounted filesystems, or frozen filesystems (seexfs_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โ tellsxfs_copywhere 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
- alpine 3.22: xfsprogs-doc 6.14.0-r0 ยท LGPL-2.1-or-later
- alpine 3.23: xfsprogs-doc 6.17.0-r0 ยท LGPL-2.1-or-later
- alpine 3.24: xfsprogs-doc 7.0.1-r0 ยท LGPL-2.1-or-later
- arch rolling: xfsprogs 7.2.0-1
- arch rolling: xfsprogs 7.2.1-1 ยท GPL-2.0-only AND LGPL-2.1-only
- centos-stream 10: xfsprogs 6.16.0-1.el10 ยท GPL-1.0-or-later AND LGPL-2.1-or-later
- centos-stream 9: xfsprogs 6.4.0-9.el9 ยท GPL+ and LGPLv2+
- centos-stream 9: xfsprogs 6.4.0-9.el9 ยท GPL+ and LGPLv2+
- debian bookworm: xfsprogs 6.1.0-1 ยท GPL-2.0-only
- debian trixie: xfsprogs 6.13.0-2+deb13u1 ยท GPL-2.0-only
- fedora 43: xfsprogs 6.15.0-3.fc43 ยท GPL-1.0-or-later AND LGPL-2.1-or-later
- fedora 43: xfsprogs 6.15.0-3.fc43 ยท GPL-1.0-or-later AND LGPL-2.1-or-later
- fedora 44: xfsprogs 6.18.0-2.fc44 ยท GPL-1.0-or-later AND LGPL-2.1-or-later
- fedora 44: xfsprogs 6.18.0-2.fc44 ยท GPL-1.0-or-later AND LGPL-2.1-or-later
- fedora 44: xfsprogs 7.1.1-1.fc44 ยท GPL-1.0-or-later AND LGPL-2.1-or-later
- fedora 44: xfsprogs 7.1.1-1.fc44 ยท GPL-1.0-or-later AND LGPL-2.1-or-later
- nixos 26.05: xfsprogs 6.19.0
- nixpkgs unstable: xfsprogs 7.2.1
- opensuse-leap 16.0: xfsprogs 6.19.0-160000.3.1 ยท GPL-2.0-or-later
- opensuse-leap 16.0: xfsprogs 6.19.0-160000.3.1 ยท GPL-2.0-or-later
- opensuse-leap 16.0: xfsprogs 6.19.0-160000.3.1 ยท GPL-2.0-or-later
- opensuse-leap 16.0: xfsprogs 6.19.0-160000.3.1 ยท GPL-2.0-or-later
- ubuntu jammy: xfsprogs 5.13.0-1ubuntu2 ยท GPL-2.0-only
- ubuntu jammy: xfsprogs 5.13.0-1ubuntu2.1 ยท GPL-2.0-only
- ubuntu noble: xfsprogs 6.6.0-1ubuntu2 ยท GPL-2.0-only
- ubuntu noble: xfsprogs 6.6.0-1ubuntu2.1 ยท GPL-2.0-only
- ubuntu questing: xfsprogs 6.13.0-2ubuntu2 ยท GPL-2.0-only
- ubuntu resolute: xfsprogs 6.18.0-3 ยท GPL-2.0-only
- ubuntu stonking: xfsprogs 6.19.0-1 ยท GPL-2.0-only
- ๐ girlified by anthropic/claude-haiku-5.5 on : a language model's rewrite of the original, under its terms