COPYFILERANGE(1)

๐Ÿ“ฆ
version 2.42.4 ยท 4 versions
, in arch rolling

๐Ÿ’– COPYFILERANGE(1) โ€” user commands, but make it iconic ๐Ÿ’–

okay bestie, so we're doing copyfilerange(1) today and honestly? she's a baddie. let's get into it ๐Ÿซถ


โœจ NAME โœจ

copyfilerange โ€” copy range(s) from source to destination file ๐Ÿ’…


๐ŸŒธ SYNOPSIS ๐ŸŒธ

copyfilerange [options] source destination range...

๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

so copyfilerange copies byte ranges from a source file to a destination file. that's it, that's the girl. she's a wrapper around the copy_file_range(2) system call, meaning she's basically the system call's glamorous publicist ๐ŸŽ€

the way she's useful?? you can use this command to create files with unallocated gaps (aka sparse files) and/or with shared blocks between multiple files (aka reflinks). not me being obsessed with efficient storage ๐Ÿ’€

each range is shaped like this:

source_offset:destination_offset:length

and all those values are in bytes, no cap. if length is 0, then as much data as is available gets copied. you can also supply multiple ranges โ€” she's flexible like that โœจ

when one or both of the offsets are omitted, the operation uses the last-used file location, starting with 0. so she remembers where she left off, very main character of her ๐Ÿ’–


๐Ÿ’œ OPTIONS ๐Ÿ’œ

  • -r, --ranges file โ€” read range(s) separated by newlines from this file. yes, from a file, we're being organized ๐Ÿ—‚๏ธ
  • -v, --verbose โ€” verbose output of the copied ranges. she will narrate her own life โœจ
  • -h, --help โ€” display help text and exit. respect the classic ๐Ÿ“–
  • -V, --version โ€” display version and exit. she'll tell you who she is ๐Ÿ‘‘

๐ŸŒˆ EXIT STATUS ๐ŸŒˆ

  • 0 โ€” success ๐ŸŽ‰ (slay)
  • 1 โ€” unspecified failure ๐Ÿ˜ญ (not slay)

โš ๏ธ NOTES โš ๏ธ

okay so this is the part where we get serious for a sec because the copy_file_range(2) system call has some serious caveats and i'm not gonna lie to you bestie:

  • the source and destination files must use the same filesystem type ๐Ÿ”’
  • some virtual filesystems (like procfs) won't work. like, at all. don't try it ๐Ÿ™ˆ
  • copy_file_range(2) will use reflinks when the filesystem supports this ๐Ÿ‘‘
  • but to actually use reflinks, the file range most often needs to align with the filesystem block size on both the source and destination file ๐Ÿ“
fr fr, read those caveats twice. this is not a drill ๐Ÿšจ

๐Ÿ‘‘ AUTHORS ๐Ÿ‘‘

Dick Marinus <dick@mrns.nl>


๐ŸŽ€ EXAMPLES ๐ŸŽ€

here's the part you actually came for, and honestly? these examples ate ๐Ÿ’…

copyfilerange original-file reflink ::
copyfilerange original-file first-block ::4096
copyfilerange original-file even-blocks -r <(seq 0 8192 40960|awk '{print $1"::4096"}')
copyfilerange original-file sparse-file 0:1M:1
copyfilerange original-file split-first-mb ::1M
copyfilerange original-file split-remainder 1M::
copyfilerange split-first-mb join ::
copyfilerange split-remainder join :1M:

the way that <(...) process substitution is just sitting there in the middle of an example being all clever ๐Ÿงš lowkey iconic


๐Ÿ”ฅ SEE ALSO ๐Ÿ”ฅ

copy_file_range(2) โ€” the system call she's wrapping, iykyk


๐Ÿ’€ REPORTING BUGS ๐Ÿ’€

for bug reports, use the issue tracker:

https://github.com/util-linux/util-linux/issues

please be nice when you file them, the maintainers are people too ๐Ÿซถ


๐ŸŒŸ AVAILABILITY ๐ŸŒŸ

the copyfilerange command is part of the util-linux package, which can be downloaded from the Linux Kernel Archive:

https://www.kernel.org/pub/linux/utils/util-linux/

okay that's the whole page bestie, you're officially a copyfilerange girlie now ๐Ÿ’– go make some sparse files, go make some reflinks, go be the main character of your own filesystem โœจ

this has been util-linux 2.42.4, dated 2026-09-21, and yes i remembered the version and the date because that's what besties do ๐Ÿ’…๐Ÿฆ‹

๐Ÿ“ฆ where this page comes from
  • arch rolling: util-linux 2.42.4-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4-Clause-UC AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND ISC AND LGPL-2.1-or-later AND LicenseRef-PublicDomain
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms