$ ( dd if=/dev/zero count=100; dd if=/dev/urandom count=100; dd if=/dev/zero 
count=100 ) > unsparse

$ cp --sparse=always unsparse sparse

$ ls -ls *
 52 -rw-r--r--. 1 root root 153600 Apr 14 22:55 sparse
152 -rw-r--r--. 1 root root 153600 Apr 14 22:54 unsparse

Great, the file was sparse-ified. On tmpfs.

## now on XFS with reflink support
$ cp --debug --sparse=always unsparse sparse
'unsparse' -> 'sparse'
copy offload: unknown, reflink: yes, sparse detection: unknown
$ ls -ls *
152 -rw-r--r--. 1 root root 153600 Apr 14 22:58 sparse
152 -rw-r--r--. 1 root root 153600 Apr 14 22:54 unsparse

The implicit --reflink=auto has won out over the explicit --sparse=always, but 
at some point prior to coreutils 7.5, --sparse=always would have worked.

NEWS for 9.4 included
  'cp --sparse=never' will avoid copy-on-write (reflinking) and copy offloading,
  to ensure no holes present in the destination copy.
  [bug introduced in coreutils-9.0]

but we lack the opposite. I couldn't spot the discussion, if any, around the 
patch
https://lists.gnu.org/archive/html/coreutils/2023-08/msg00052.html

I'm using coreutils 9.5 on Fedora 41.


Cheers,
Phil

Reply via email to