Sim, eu posso reproduzir isso:
# df -h .
Filesystem Size Used Avail Use% Mounted on
/dev/root 30G 14G 14G 51% /
# fallocate -l 8G test1.disk
# df -h .
Filesystem Size Used Avail Use% Mounted on
/dev/root 30G 22G 5.8G 80% /
# mkfs -text4 test1.disk
mke2fs 1.43.4 (31-Jan-2017)
Discarding device blocks: done
Creating filesystem with 2097152 4k blocks and 524288 inodes
...
# df -h .
Filesystem Size Used Avail Use% Mounted on
/dev/root 30G 14G 14G 51% /
O uso do disco sobe quando o arquivo é fallocate
d, mas recua depois de mkfs
. Observe o "Descartando blocos do dispositivo: concluído" na saída de mke2fs
. ( frostschutz mencionou isso no comentários .)
A página man diz sobre -E discard
:
discard
Attempt to discard blocks at mkfs time (discarding blocks initially is useful on solid state devices and sparse / thin-provisioned storage). ... This is set as default.
Há nodiscard
para fazer o oposto, então vamos tentar:
# df -h .; fallocate -l 8G test2.disk; mkfs -text4 -Enodiscard test2.disk; df -h .
Filesystem Size Used Avail Use% Mounted on
/dev/root 30G 14G 14G 51% /
mke2fs 1.43.4 (31-Jan-2017)
Creating filesystem with 2097152 4k blocks and 524288 inodes
...
Filesystem Size Used Avail Use% Mounted on
/dev/root 30G 22G 5.9G 79% /
Agora, outro fallocate -l 8G
falha.