table of contents
HARDLINK(1) | User Commands | HARDLINK(1) |
NAME¶
hardlink - link multiple copies of a file
SYNOPSIS¶
hardlink [options] [directory|file]...
DESCRIPTION¶
hardlink is a tool that replaces copies of a file with either hardlinks or copy-on-write clones, thus saving space.
hardlink first creates a binary tree of file sizes and then compares the content of files that have the same size. There are two basic content comparison methods. The memcmp method directly reads data blocks from files and compares them. The other method is based on checksums (like SHA256); in this case for each data block a checksum is calculated by the Linux kernel crypto API, and this checksum is stored in userspace and used for file comparisons.
For each file also an "intro" buffer (32 bytes) is cached. This buffer is used independently from the comparison method and requested cache-size and io-size. The "intro" buffer dramatically reduces operations with data content as files are very often different from the beginning.
OPTIONS¶
-h, --help
-V, --version
-c, --content
-b, --io-size size
-d, --respect-dir
-f, --respect-name
-i, --include regex
-m, --maximize
-M, --minimize
-n, --dry-run
-o, --ignore-owner
-O, --keep-oldest
-p, --ignore-mode
-q, --quiet
-r, --cache-size size
-s, --minimum-size size
-S, --maximum-size size
-t, --ignore-time
-v, --verbose
-x, --exclude regex
-X, --respect-xattrs
-y, --method name
--reflink[=when]
The optional argument when can be never, always, or auto. If the when argument is omitted, it defaults to auto, in this case, hardlink checks filesystem type and uses reflinks on BTRFS and XFS only, and fallback to hardlinks when creating reflink is impossible. The argument always disables filesystem type detection and fallback to hardlinks, in this case, only reflinks are allowed.
--skip-reflinks
ARGUMENTS¶
hardlink takes one or more directories which will be searched for files to be linked.
BUGS¶
The original hardlink implementation uses the option -f to force hardlinks creation between filesystem. This very rarely usable feature is no more supported by the current hardlink.
hardlink assumes that the trees it operates on do not change during operation. If a tree does change, the result is undefined and potentially dangerous. For example, if a regular file is replaced by a device, hardlink may start reading from the device. If a component of a path is replaced by a symbolic link or file permissions change, security may be compromised. Do not run hardlink on a changing tree or on a tree controlled by another user.
AUTHOR¶
There are multiple hardlink implementations. The very first implementation is from Jakub Jelinek for Fedora distribution, this implementation has been used in util-linux between versions v2.34 to v2.36. The current implementations is based on Debian version from Julian Andres Klode.
REPORTING BUGS¶
For bug reports, use the issue tracker at <https://github.com/util-linux/util-linux/issues>.
AVAILABILITY¶
The hardlink command is part of the util-linux package which can be downloaded from Linux Kernel Archive <https://www.kernel.org/pub/linux/utils/util-linux/>.
2024-07-04 | util-linux 2.40.2 |