8年間で多くの変化がありました。
ファロケート
fallocate -d
filename
既存のファイルに穴を開けるために使用できます。fallocate(1)
マニュアルページから:
-d, --dig-holes
Detect and dig holes. This makes the file sparse in-place,
without using extra disk space. The minimum size of the hole
depends on filesystem I/O block size (usually 4096 bytes).
Also, when using this option, --keep-size is implied. If no
range is specified by --offset and --length, then the entire
file is analyzed for holes.
You can think of this option as doing a "cp --sparse" and then
renaming the destination file to the original, without the
need for extra disk space.
See --punch-hole for a list of supported filesystems.
(そのリスト:)
Supported for XFS (since Linux 2.6.38), ext4 (since Linux
3.0), Btrfs (since Linux 3.7) and tmpfs (since Linux 3.5).
そのリストにあるtmpfsは、私が最も興味深いと思うものです。ファイルシステム自体は、コンテンツを格納するために必要な量のRAMのみを消費するのに十分な効率ですが、コンテンツをスパースにすることで、その効率をさらに高めることができます。
GNUcp
さらに、途中のどこかで、GNUcp
はスパースファイルを理解しました。デフォルトモードに関するcp(1)
マニュアルページの引用--sparse=auto
:
スパースソースファイルは大まかなヒューリスティックによって検出され、対応するDESTファイルもスパースになります。
ただし、インプレースで--sparse=always
実行するのと同等のファイルコピーをアクティブ化するもあります。fallocate -d
--sparse=always
SOURCEファイルにゼロバイトの十分な長さのシーケンスが含まれている場合は常に、スパースDESTファイルを作成するように指定します。
私はついにtar cpSf - SOURCE | (cd DESTDIR && tar xpSf -)
ワンライナーを引退させることができました。これは、20年間、スパースファイルをスパース性を維持したままコピーする私の灰色のひげの方法でした。