A lot of programs implicitly create sparse files on Linux and while they will work fine under Linux some builtin Windows tools do not support such files at all.
Notable example where Windows does not allow sparse files are Disk Images (*.iso, *.vhd,.vhdx*). [1][2]
Adding option to every program that might write sparse file under Linux is impractical instead there should be a ntfs3g mount option that prevents new sparse files or adding new write holes to existing files.
Note: The Kernel NTFS3 driver already does not create sparse files by default and the following command creates a disk image that is usable on Windows (mounting or Hyper-V).
Running the same command on an NTFS3g mount creates a highly fragmented and sparse file that is not usable under Windows. Only the write holes cause Windows to reject the file.
Current workaround are copying the sparse file with cp --sparse=never or dd if=sparsefile of=sparsefile conv=notrunc bs=1M.
Running qemu-img convert with a preallocated destination file inflates the file to it's full size rendering subformat=dynamic useless.
The only workaround that does not required writing the file twice that I found is to use nbdcopy.
I also tried running ntfsfallocate on the sparse vhdx created with qemu-img convert but ntfsfallocate fails either with NO SPACE LEFT even though the NTFS partition should have enough space left (120GB/150GB) or it crashes corrupting the file system.
A lot of programs implicitly create sparse files on Linux and while they will work fine under Linux some builtin Windows tools do not support such files at all. Notable example where Windows does not allow sparse files are Disk Images (
*.iso
,*.vhd
,.vhdx*
). [1] [2]Adding option to every program that might write sparse file under Linux is impractical instead there should be a ntfs3g mount option that prevents new sparse files or adding new write holes to existing files.
Note: The Kernel NTFS3 driver already does not create sparse files by default and the following command creates a disk image that is usable on Windows (mounting or Hyper-V).
Running the same command on an NTFS3g mount creates a highly fragmented and sparse file that is not usable under Windows. Only the write holes cause Windows to reject the file.
Current workaround are copying the sparse file with
cp --sparse=never
ordd if=sparsefile of=sparsefile conv=notrunc bs=1M
. Runningqemu-img convert
with a preallocated destination file inflates the file to it's full size renderingsubformat=dynamic
useless. The only workaround that does not required writing the file twice that I found is to use nbdcopy.I also tried running
ntfsfallocate
on the sparse vhdx created withqemu-img convert
butntfsfallocate
fails either with NO SPACE LEFT even though the NTFS partition should have enough space left (120GB/150GB) or it crashes corrupting the file system.