On a Linux FS such as ext4, would temporary files such as logs and other /var
stuff tend to end up on the same physical blocks over time? For example, with log rotation, would new logs tend to end up on the same blocks where previous (now deleted) log or other temporary files used to be?
(The focus of this question is primarily Linux/ext4, but insights re other filesystems and OSes are also welcome.)
Ignore anything that's mounted to tmpfs or to its own partition. I'm talking only about the stuff directly in the root partition. And assume that /var
as a whole is not on a separate partition.
I'm only mention /var
because I'm assuming the main thing that accumulates changes over time is the various stuff in /tmp
, /var
, and /run
. The rest is mostly installed packages and configuration, which change much less often. Of those 3, /tmp
and /run
are often mounted to tmpfs, so we can ignore those. That leaves only /var
. But the path really doesn't matter. The question is about allocation behavior of short-lived files anywhere (and also longer-lived ones that are modified often).
IOW, how much do such files move around on the disk?
Context: (can ignore)
The context is an LVM2 snapshot of a root filesystem. I'm assuming the main thing that accumulates changes over time is the various stuff in /tmp
, /var
, and /run
, and that most of that are temporary files of various lifetimes. Then:
- If these files tend to end up on the same limited set of blocks, the snapshot will only need to back up those relatively few blocks.
- OTOH, if these files end up on different blocks every time, then eventually many of the unused blocks will get written to (with other blocks becoming unused in their place). In this case, the snapshot will have to back up a much larger set of blocks, and will grow to a larger size.
I'm aware of other questions regarding selecting an LVM snapshot size, size recommendations, etc. But I'm more interested in the more general file allocation angle. So you may ignore the LVM context.
/var/run
is likely to be a symbolic link to/run
, which is likely to be the mount point for a tmpfs (and not ext4). tmpfs utilizes RAM and swap space, so your question really does not make sense, i.e. it's based on a faulty premise./var/run
is only one subfolder. There are other things in/var
that aren't mounted to tmpfs. Assuming/var
itself isn't a separate partition, some of these will be in the root partition directly. I've edited to clarify.