Calculate maximum disk size in Linux
The number of bytes written is not necessarily the peak in disk usage.
There are several ways to do this.
1) df
or du
will give you the option to use the disk during this time. If you are doing df
every second it can give you enough information. The process is assumed to take long enough to obtain multiple samples. If it works for you, this is probably the easiest way.
2) If you know which directories or files are being used or created, you can improve on the previous way of using df
or du
by concatenating with inotifywait
instead of hibernating a fixed interval:
while inotifywait -q -e modify filename >/dev/null; do
df >> df-log-file
done
For details see man inotify
.
3) If you run the program in VirtualBox, create a virtual disk that will be dynamically allocated. The actual file for this VDI will grow when the room is needed. Therefore, the VDI size should be the starting size plus the maximum size of temporary files. I don't know how accurate the result will be.
There must be many other ways to do this.
source to share