My program creates many small short-lived files. They are typically deleted within a second after creation. The files are in an ext4 file system backed by a real hard disk. I know that Linux periodically flushes (pdflush
) dirty pages to disk. Since my files are short-lived, most likely they are not cached by pdflush
. My question is, does my program cause a lot of disk writes? My concern is my hard disk's life.
Since the files are small, let's assume the sum of their size is smaller than dirty_bytes
and dirty_background_bytes
.
Ext4 has default journal turned on, i.e. metadata journal. I also want to know whether the metadata or the data is written to disk.
Best Answer
A simple experiment using ext4:
Create a 100MB image...
Make it a loop device...
Make filesystem and mount...
Make some kind of run with short lived files. (Change this to any method you prefer.)
Umount, sync, unloop.
Check the image contents.
In my case it listed all the file names, but none of the file contents. So only the contents were not written.