Background: We have a computer cluster and on node allocation a job gets its own tmp directory of requested size. I noticed however I could send two jobs to the same machine with total requested disk space greater than what was available. I tracked the bug down to fallocate
and mkfs.ext4
.
On a test node/computer with 1.1T disk space available I create virtual disks to mount tmp directories to. Using fallocate
and mkfs.ext4
:
# fallocate -l 900G /tmp/disk-test1
# /sbin/mkfs.ext4 -F /tmp/disk-test1
# fallocate -l 900G /tmp/disk-test2
# /sbin/mkfs.ext4 -F /tmp/disk-test2
creates two files both (seemingly) of size 900G
# ll --block-size=G /tmp/
...
-rw-r--r--. 1 root root 900G Jul 4 14:03 disk-test1
-rw-r--r--. 1 root root 900G Jul 4 14:03 disk-test2
...
and looking at available disk space
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg.01-lv_root 1.1T 8.6G 1.1T 1% /
...
The /tmp dir:
# df -h /tmp
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg.01-lv_root 1.1T 8.6G 1.1T 1% /
I don't want this to happen. The virtual disks must not be created if there is not enough space left and once mounted writing to them should be limited by their size.
What is going on here?
filefrag
to get info about how it is allocated. Alsomkfs
might discard / TRIM the file. – frostschutz Jul 05 '18 at 10:06discard
mount option orfstrim
. Depending on your distrofstrim
might be done by a system-wide cron job or service. Since you're using LVM anyway, why not create LV of desired size rather than disk images inside LV? – frostschutz Jul 05 '18 at 10:16filefrag disk-test1
outputs "485 extents found". Regarding LV, I will try that. – Kisi Jul 05 '18 at 10:24