linuxgnulssparse-file

How to create sparse file on Macos


I'm trying to understand the difference between the sparse file and no-sparse using the following article http://extrabright.com/blog/2010/03/30/how-to-know-if-a-file-on-linux-is-sparse/

I also created the sparse file http://prefetch.net/blog/index.php/2009/07/05/creating-sparse-files-on-linux-hosts-with-dd/ as mention over here.

But every time I create a file I see the block size to be equal to the actual size of the file (of the above sparse file create)

dd if=/dev/zero of=xen-guest.img bs=1 count=0 seek=1G

then using ls command to verify if the file is sparse file

ls -alshk
1.0G -rw-r--r--  1 ratatouille staff 1.0G Apr 17 08:48 xen-guest.img

Can someone explain me what I'm missing over here.

Note: the OS is MAC-OS 10.12.3 and the above stuff works properly in Ubuntu.


Solution

  • macOS with the HFS+ file system does not support sparse files. See also https://stackoverflow.com/a/186098