Skip to content
TopicTracker
From HackerNewsView original
TranslationTranslation

Show HN: A cp wrapper that appends –reflink=always if possible to speed it up

fastcp is a Rust/Bash wrapper for the cp command that checks whether the filesystem supports reflink and, if so, automatically adds the --reflink=always flag to speed up file copies.

Background

- **cp** is the standard Unix command for copying files; **reflink** (reference link, also called copy-on-write) is a filesystem feature that makes copies nearly instant by only creating a new pointer to the same data until either file is modified. - Not all filesystems support reflink — common ones that do include Btrfs, XFS (with reflink enabled), and ZFS; ext4 does not. - `--reflink=always` tells cp to use reflink if the filesystem supports it, and fail if it doesn't; the default is `--reflink=auto`, which falls back to a traditional (slow) full copy. - **fastcp** is a simple wrapper that checks whether the destination filesystem supports reflink; if yes, it runs cp with `--reflink=always` for a speed boost; if not, it runs normal cp. - This is useful because most people don't know their filesystem's capabilities, so they miss out on large speedups (e.g., copying huge files takes seconds instead of minutes).

Related stories