`cp --sparse=always`にはどのような欠点がありますか?

`cp --sparse=always`にはどのような欠点がありますか?

理由がありますか?いいえ--sparse=alwaysすべての通貨に使用しますかcp

info cp説明する:

‘--sparse=WHEN’
     A “sparse file” contains “holes”—a sequence of zero bytes that does
     not occupy any physical disk blocks; the ‘read’ system call reads
     these as zeros.  This can both save considerable disk space and
     increase speed, since many binary files contain lots of consecutive
     zero bytes.  By default, ‘cp’ detects holes in input source files
     via a crude heuristic and makes the corresponding output file
     sparse as well.  Only regular files may be sparse.

    The WHEN value can be one of the following:

...

    ‘always’
          For each sufficiently long sequence of zero bytes in the input
          file, attempt to create a corresponding hole in the output
          file, even if the input file does not appear to be sparse.
          This is useful when the input file resides on a file system
          that does not support sparse files (for example, ‘efs’ file
          systems in SGI IRIX 5.3 and earlier), but the output file is
          on a type of file system that does support them.  Holes may be
          created only in regular files, so if the destination file is
          of some other type, ‘cp’ does not even try to make it sparse.

また、次のように言います。

[...] 次のエイリアスを使用すると、「cp」はファイルシステムでサポートされている最小スペースを使用します。

alias cp='cp --reflink=auto --sparse=always'

--sparse=alwaysなぜデフォルトではないのですか?

ベストアンサー1

これがデフォルトではない理由はいくつかあります。一つは、以前のバージョンとの互換性、パフォーマンス、そして最後に最小限の驚きの原則です。

私が理解しているように、このオプションを有効にするとCPUオーバーヘッドが発生します。これは必ずしも許可されておらず、以前のバージョンとの互換性が重要です。このcpコマンドはなくても安定して動作し、少しスペースを節約しますが、現時点では少なくともほとんどの場合、実際には無視できます。

あなたが受け取ったコメントは他の理由を強調したと思います。

最小の驚きの原則は、不必要に何かを変更しないことを意味します。cpこれは何十年も使用されており、基本的な動作を変更することは多くのベテランにとって不安になるでしょう。

おすすめ記事