I am trying to test a disk space monitor we have setup.
For that purpose, I ran truncate -s 125G /publish/data/bigFile
which should claim enough space for the alert to be triggered.
However, df -h shows for that partition:/dev/vdb1 196G 66G 121G 36% /publish/data
(which is to say, free space has not changed after running the truncate command.)
ls -lh
on the file shows:-rw-r--r-- 1 username users 126G Aug 7 11:27 /publish/data/bigFile
mount output for /publish/data:/dev/vdb1 on /publish/data type ext4 (rw,relatime,data=ordered)
Edit: I also just realize, the numbers do not make sense:
196-66=130gb, so why df says 121gb free in the first place?
Answer
Can't see any documentation that supports it, but truncate
must be creating a sparse file:
TESTtruncate -s 10G testfile
du testfile
# shows the occupied size
0 testfile
du -h --apparent-size
# shows apparent size
10G testfile
From the du man page:
--apparent-size
print apparent sizes, rather than disk usage;
although the apparent size is usually smaller, it
may be larger due to holes in ('sparse') files,
internal fragmentation, indirect blocks, and the
like
fallocate
Try using fallocate
, it's very quick and does not create sparse files.
fallocate -l 125G filename
No comments:
Post a Comment