brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: noatime stops Linux from writing a timestamp every time you read a file

Linux
~/tips/tip-disk-mount-noatime

sudo mount -o remount,noatime /mnt/data

Stops the filesystem from updating access times on every read, which saves writes on data disks.

Reading a file can cause a write. Every file has an access time, and the filesystem can update it each time something opens the file. The noatime mount option switches that off completely. Before you add it everywhere, though, it helps to know what Linux already does by default.

Since Linux 2.6.30 the kernel uses relatime unless you tell it otherwise. With relatime, the access time is only updated when it’s older than the last modify or change time, or more than a day old. That already removes most of those writes. noatime goes all the way: no access time updates at all, for files and directories, and it implies nodiratime.

You can try it on a mounted filesystem with a remount, then check what’s active:

sudo mount -o remount,noatime /mnt/data
findmnt -o TARGET,VFS-OPTIONS /mnt/data

To keep it after a reboot, put it in the options column of the fstab line:

UUID=<your-uuid>  /mnt/data  ext4  defaults,noatime  0  2

Where I’d reach for it: a data disk full of media or backups that gets read a lot and where nobody cares when a file was last opened. Think of a disk that a media server scans over and over. The gain over relatime is small, so I wouldn’t expect miracles, but on a busy read-heavy disk it’s one less reason to write.

The caveat comes straight from the mount man page: some programs need to know whether a file was read since it last changed. The classic example is mutt, the mail client, which uses it to spot new mail in an mbox file. Relatime was made to keep those programs working, and noatime breaks them. So on a home directory or a mail spool I’d leave the default alone and keep noatime for plain data disks.

Further reading: mount(8) manual page

More Linux tips a2query -m rewrite renice -n 10 -p 4242 cat config.yml | xsel -ib xvfb-run -a your-program --some-flag dpkg --get-selections > packages.txt All Linux tips (261) All topics

Link