I am trying to create a file with hole using the truncate command. I read up in some posts and one of the answers in this post says to use truncate command. Filesystem used is btrfs. This is the command
$: truncate -s 16K holes
$: du holes
$: 16 holes
$: stat holes
File: holes
Size: 16384 Blocks: 32 IO Block: 4096 regular file
As can be seen, its allocating 16 blocks...my understanding was that it will allocate 0 blocks as mentioned that answer as well. Did I make a mistake in understanding what truncate is doing?
mount |grep vda3
– Gerald Schneider Oct 05 '23 at 06:18truncate
to a smaller size and it will not become sparse. The method you used creates sparseness whentruncate
creates a new file (or extends an existing file). Are you sure yourtruncate
createdholes
from nothing? Try with a file that doesn't exist yet and confirm the issue. – Kamil Maciorowski Oct 05 '23 at 06:44crc32 holes
printab54d286
? What if you dofallocate -d holes
? Is the file sparse now? – Kamil Maciorowski Oct 05 '23 at 07:02