Skip to content

ReducingWrites

Adam Boardman edited this page Mar 23, 2018 · 4 revisions

Disable writes on access time

By default, linux tracks the last time a file has been read. This generates a disk write for every file read.

Note: current linux builds are using relatime which is half decent, but they don't use fstab so these instructions are useless to change it

We probably want to disable that for all SSD/Flash drives:

Edit the config file with:

sudo nano /etc/fstab

Add the noatime (no access time), nodiratime (same for directories instead of files) and data=writeback options after the defaults parameters for each drive, except swap. Modified lines should read something like:

UUID=[Random Numbers/Letters] / ext4 defaults,noatime,nodiratime 0 0

or

UUID=[Random Numbers/Letters] / ext4 noatime,nodiratime,errors=remount-ro 0 0

Do that for each drive, save, and reboot.

NOTE: The data=writeback option is optional (I've removed it as its not something I've tested personally, just sounded like it could be useful), data ordering is not preserved, data may be written into the main file system after its metadata has been committed to the journal. This means than when you save/update a file, the OS will take a few seconds to update the directory to point to the new file. If your computer crashes/stops in the mean time, you'll lose your changes.

NOTE2: Had a report of this causing someone to have a readonly filesystem with ext3, with the writeback option.

NOTE3: There some alternatives that might suite some use cases where the access time is actually used for something:

  • relatime - this only updates the access time if its also updating the mtime (modify) or if the last atime is greater than 24 hours.
  • lazytime - keeps the atime in memory and flushes it sometime later.