Lazytime Filesystem Mount Option
lazytime
Lazytime
is a filesystem mount option offering performance improvements over relatime
or noatime
whilst retaining the advantages of atime
, mtime
and ctime
. It optimises timestamp writes to memory storage media and thus assists in reducing wear of solid state memory devices, such as SD cards.
The option has been around since 2015, but at the time of revising this post (October 2024) it is in my view still not common knowledge, perhaps because for most users editing mount options in fstab or systemd or manually mounting a device is a rare event.
Whilst the use of lazytime
looks promising there may be caveats and you should do your own research for your specific filesystem and use case:
- For example, see this discussion titled "Mounting btrfs with an atime, bad idea?". The text is extensive, so it may help to copy and paste the whole discussion text in to a large language model, such as those available in lmarena.ai, and ask "Please summarise the following text in relation to
lazytime
", or another phrase of your choice.
Some articles about lazytime
The Linux mount command manual page describes the lazytime
mount option as:
lazytime
Only update times (atime, mtime, ctime) on the in-memory version of the file inode.
This mount option significantly reduces writes to the inode table for workloads that perform frequent random writes to preallocated files.
The on-disk timestamps are updated only when:
- the inode needs to be updated for some change unrelated to file timestamps
- the application employs
fsync(2)
,syncfs(2)
, orsync(2)
- an undeleted inode is evicted from memory
- more than 24 hours have passed since the i-node was written to disk.
A Wikipedia article has this to say about lazytime :
Version 4.0 of the Linux kernel mainline, which was released on April 12, 2015, introduced the new mount option
lazytime
. It allows POSIX-styleatime
updates to be performed in-memory and flushed to disk together with some non-time-related I/O operations on the same file;atime
updates are also flushed to disk when some of the sync system calls is executed, or before the file's in-memory inode is evicted from the filesystem cache. Additionally, it is possible to configure for how longatime
modifications can remain unflushed. That way,lazytime
retains POSIX compatibility while offering performance improvements.
And KernelNewbies says :
lazytime
option for better update of file timestamps
Lazytime causes access, modified and changed time updates to only be made in the cache. The times will only be written to the disk if the inode needs to be updated anyway for some non-time related change, iffsync()
,syncfs()
orsync()
are called, or just before an undeleted inode is evicted from memory. This is POSIX compliant, while at the same time improving the performance.
To my naive understanding it seems in general a good idea to consider the use lazytime
in place of either noatime
or relatime
depending upon your filesystem and use case.
I hope the above information about lazytime
may be beneficial to you next time you need to configure filesystem mounts.
Perhaps those with more knowledge and expertise in this area may like to comment further.
Congratulations @forestacorn! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :
Award for the number of upvotes
Click on the badge to view your Board of Honor.
If you no longer want to receive notifications, reply to this comment with the word
STOP
Congratulations @forestacorn! You received a personal award!
Click here to view your Board of Honor