I'm on a Macbook Pro running macOS 12.2.1 (so using the APFS filesystem.)
I noticed some strange behavior when creating a large "dummy file" using the mkfile
utility.
(/usr/sbin/mkfile
)
I created a 5 GB file with the command:
mkfile -n 5g test.txt
Then, to confirm it worked, I ran the du
command. (/usr/bin/du
).
du -hs ./test.txt
But I got an unexpected outcome:
4.0K ./test.txt
I went to the file in Finder and looked at the file info, and saw there were two different sizes.
After some further digging, I found this info on the mkfile
man page:
OPTIONS
-n Create an empty filename. The size is noted, but disk blocks aren't
allocated until data is written to them.
So I wanted to know, is there a command that will let me see the allocated file size?