Lazytime Filesystem Mount Option

in #lazytime7 years ago

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 this time of writing (March 2018) in my view, it is not common knowledge, perhaps because for most users editing mount options in fstab or systemd or manually mounting a device is a rare event. However use of lazytime looks promising.

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), or sync(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-style atime 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 long atime 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, if fsync(), syncfs() or sync() 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 use lazytime in place of either noatime or relatime and I have edited my fstab files accordingly. However after my computer system (Manjaro) is booted I note lazytime and relatime are used in conjunction (something more for me to learn about):

$ mount  
:  
/dev/sda3 on / type btrfs (rw,relatime,lazytime,space_cache,autodefrag,subvolid=257,subvol=/@)  
:  
/dev/sda3 on /home type btrfs (rw,relatime,lazytime,space_cache,autodefrag,subvolid=258,subvol=/@home)  
...  

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.


Sort:  

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

Support SteemitBoard's project! Vote for its witness and get one more award!

Congratulations @forestacorn! You received a personal award!

1 Year on Steemit

Click here to view your Board of Honor

Support SteemitBoard's project! Vote for its witness and get one more award!