{"id":4791,"date":"2024-04-11T03:00:00","date_gmt":"2024-04-11T07:00:00","guid":{"rendered":"https:\/\/www.both.org\/?p=4791"},"modified":"2024-04-05T13:39:28","modified_gmt":"2024-04-05T17:39:28","slug":"tweak-your-system-performance-with-noatime","status":"publish","type":"post","link":"https:\/\/www.both.org\/?p=4791","title":{"rendered":"Tweak your system performance with \u2018noatime\u2019"},"content":{"rendered":"<div class=\"pld-like-dislike-wrap pld-template-1\">\r\n    <div class=\"pld-like-wrap  pld-common-wrap\">\r\n    <a href=\"javascript:void(0)\" class=\"pld-like-trigger pld-like-dislike-trigger  \" title=\"\" data-post-id=\"4791\" data-trigger-type=\"like\" data-restriction=\"cookie\" data-already-liked=\"0\">\r\n                        <i class=\"fas fa-thumbs-up\"><\/i>\r\n                <\/a>\r\n    <span class=\"pld-like-count-wrap pld-count-wrap\">    <\/span>\r\n<\/div><\/div>\n<p>Whenever I install a new Linux system, whether that\u2019s Linux on my desktop computer or a server distribution on my Raspberry Pi, I have a list of tasks that I do every time. These are habits I developed from my time, long ago, as a Unix systems administrator: backup the files, wipe the system, reinstall from scratch, restore the files, and install any extra applications.<\/p>\n\n\n\n<p>I also make a few tweaks to the system to improve performance. One such tweak is&nbsp;<code>atime<\/code>, one of the three key timestamps that Linux tracks on every file.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"understanding-file-timestamps\">Understanding file timestamps<\/h2>\n\n\n\n<p>You probably already know about the \u201cLast Modified\u201d timestamp on files and directories. You can see this output when you run the&nbsp;<code>ls -l<\/code>&nbsp;(long) command to view files ina directory; you\u2019ll also see the \u201cLast Modified\u201d timestamp in any file manager. But behind the scenes, Linux actually tracks several timestamps on files and directories:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>mtime<\/strong>: When the file was last modified<\/li>\n\n\n\n<li><strong>ctime<\/strong>: When the file was last changed<\/li>\n\n\n\n<li><strong>atime<\/strong>: When the file was last accessed<\/li>\n<\/ul>\n\n\n\n<p>You can use the&nbsp;<code>stat<\/code>&nbsp;command to view these details for any file. Here\u2019s one example for the Apache web server configuration file on my personal web server in my home office:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ stat \/etc\/httpd\/conf\/httpd.conf \n  File: \/etc\/httpd\/conf\/httpd.conf\n  Size: 12303       Blocks: 32         IO Block: 4096   regular file\nDevice: 253,0   Inode: 37749479    Links: 1\nAccess: (0644\/-rw-r--r--)  Uid: (    0\/    root)   Gid: (    0\/    root)\nContext: system_u:object_r:httpd_config_t:s0\nAccess: 2024-03-31 00:00:01.198883654 -0500\nModify: 2023-12-31 18:12:27.216328620 -0600\nChange: 2023-12-31 18:12:27.225328576 -0600\n Birth: 2023-12-31 18:12:27.215328625 -0600<\/code><\/pre>\n\n\n\n<p>This file was created on December 31, 2023. That\u2019s when I installed Linux on this Raspberry Pi. I haven\u2019t needed to modify the&nbsp;<code>httpd.conf<\/code>&nbsp;file since then, so the file has remained unchanged since then. But I recently viewed it, to look for a particular setting on the web server; by looking in the file using&nbsp;<code>cat<\/code>, Linux updated the \u201cAccess Time\u201d or&nbsp;<code>atime<\/code>&nbsp;timestamp.<\/p>\n\n\n\n<p>If I copy the&nbsp;<code>httpd.conf<\/code>&nbsp;file to a backup file, all of the timestamps change, indicating that this is a new file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ cp \/etc\/httpd\/conf\/httpd.conf \/tmp\/httpd.bak\n$ stat \/tmp\/httpd.bak \n  File: \/tmp\/httpd.bak\n  Size: 12303       Blocks: 32         IO Block: 4096   regular file\nDevice: 0,37    Inode: 253         Links: 1\nAccess: (0644\/-rw-r--r--)  Uid: ( 1000\/   jhall)   Gid: ( 1000\/   jhall)\nContext: unconfined_u:object_r:user_tmp_t:s0\nAccess: 2024-04-05 12:13:04.247401082 -0500\nModify: 2024-04-05 12:13:04.249401072 -0500\nChange: 2024-04-05 12:13:04.249401072 -0500\n Birth: 2024-04-05 12:13:04.247401082 -0500<\/code><\/pre>\n\n\n\n<p>But if I rename the file, Linux doesn\u2019t update&nbsp;<code>atime<\/code>&nbsp;or&nbsp;<code>mtime<\/code>&nbsp;because I didn\u2019t access the file\u2019s contents (<code>atime<\/code>) or otherwise modify the text (<code>mtime<\/code>):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ mv \/tmp\/httpd.bak \/tmp\/httpd.tmp\n$ stat \/tmp\/httpd.tmp\n  File: \/tmp\/httpd.tmp\n  Size: 12303       Blocks: 32         IO Block: 4096   regular file\nDevice: 0,37    Inode: 253         Links: 1\nAccess: (0644\/-rw-r--r--)  Uid: ( 1000\/   jhall)   Gid: ( 1000\/   jhall)\nContext: unconfined_u:object_r:user_tmp_t:s0\nAccess: 2024-04-05 12:13:04.247401082 -0500\nModify: 2024-04-05 12:13:04.249401072 -0500\nChange: 2024-04-05 12:14:24.902015034 -0500\n Birth: 2024-04-05 12:13:04.247401082 -0500<\/code><\/pre>\n\n\n\n<p>Notice that the \u201cLast Changed\u201d time (<code>ctime<\/code>) has been updated, because I changed the file\u2019s name.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"why-atime\">Why \u2018atime\u2019?<\/h2>\n\n\n\n<p>The \u201cLast Accessed\u201d (<code>atime<\/code>) is useful for certain legacy programs. For example,&nbsp;<strong>biff<\/strong>&nbsp;is an old mail notification program that alerts you when you have a new email message waiting for your attention. You don\u2019t see many people using&nbsp;<strong>biff<\/strong>&nbsp;in modern times, but in the days when mailboxes were local to the workstation you were using,&nbsp;<strong>biff<\/strong>&nbsp;was quite common.<\/p>\n\n\n\n<p><strong>biff<\/strong>&nbsp;compared the \u201cLast Modified\u201d time (when the Inbox was last updated with a new email message) and the \u201cLast Accessed\u201d time (the last time you read your email). If&nbsp;<code>mtime<\/code>&nbsp;was more recent than&nbsp;<code>atime<\/code>, then&nbsp;<strong>biff<\/strong>&nbsp;knew that an email had arrived since you last looked at your Inbox, and let you know. The&nbsp;<strong>Mutt<\/strong>&nbsp;email client does something similar to alert you to new email messages.<\/p>\n\n\n\n<p>The \u201cLast Accessed\u201d time is also useful if you need to do filesystem maintenance or performance tweaking. On large Linux systems, administrators may need to know what\u2019s being accessed more frequently so they can tune performance appropriately. This might involve moving less-frequently used files to slower, high-density storage and more-frequently used files to faster disks.<\/p>\n\n\n\n<p>But desktop systems and other \u201cpersonal use\u201d computers don\u2019t need the \u201cLast Accessed\u201d time, so there\u2019s been some argument to not use it at all. For example, Linux kernel developer Ingo Molnar commented about\u00a0<code>atime<\/code>\u00a0and filesystem performance:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>It\u2019s kind of weird that every Linux desktop and server is hurt by a noticeable IO performance slowdown due to the constant atime updates, while there\u2019s just two real users of it: tmpwatch [which can be configured to use ctime so it\u2019s not a big issue] and some backup tools. (Ok, and mail-notify too i guess.) Out of tens of thousands of applications.<\/p>\n<\/blockquote>\n\n\n\n<p>But some people use a few programs that rely on\u00a0<code>atime<\/code>\u00a0so Linux keeps updating the\u00a0<code>atime<\/code>\u00a0feature.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"tweaking-performance-with-noatime\">Tweaking performance with \u2018noatime\u2019<\/h2>\n\n\n\n<p>If you want to get a boost in desktop performance, you can disable&nbsp;<code>atime<\/code>&nbsp;on your system. You can also use this method on servers, but be careful that you do not run software that relies on the \u201cLast Accessed\u201d time. In my experience, modern desktop environments don\u2019t use&nbsp;<code>atime<\/code>&nbsp;so I disable it on the Linux systems I use.<\/p>\n\n\n\n<p>To disable&nbsp;<code>atime<\/code>, add the&nbsp;<code>noatime<\/code>&nbsp;filesystem option when your system mounts the storage for your computer. I usually add mine after the&nbsp;<code>defaults<\/code>&nbsp;entry in&nbsp;<code>\/etc\/fstab<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>UUID=93402b76-22d5-4533-ad1e-b8b94ccb24c0 \/                       btrfs   subvol=root,compress=zstd:1,x-systemd.device-timeout=0,noatime 0 0\nUUID=aa7dd33b-bd3c-4b12-a2e1-6cb0bf28a2e6 \/boot                   ext4    defaults,noatime        1 2\nUUID=C594-12B1          \/boot\/efi               vfat    umask=0077,shortname=winnt 0 2\nUUID=93402b76-22d5-4533-ad1e-b8b94ccb24c0 \/home                   btrfs   subvol=home,compress=zstd:1,x-systemd.device-timeout=0,noatime 0 0<\/code><\/pre>\n\n\n\n<p>This feature takes effect the next time you reboot. Whenever I reinstall my desktop system at home with a new version of Linux, the first thing I do after installing is add&nbsp;<code>noatime<\/code>, then reboot before I apply any system updates. Running the first system update after installing a fresh Linux will update many packages and files. Using&nbsp;<code>noatime<\/code>&nbsp;usually gives a slight but noticeable performance improvement on my computer<\/p>\n\n\n\n<p>However, if you use very fast storage such as a high-performance SSD or NVME for your root and home filesystems, you may not notice as much of an improvement.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Turn off \u201caccess time\u201d to make a slight but noticeable improvement on system performance.<\/p>\n","protected":false},"author":33,"featured_media":3306,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_lmt_disableupdate":"","_lmt_disable":"","footnotes":""},"categories":[100,5,328,89],"tags":[91,97],"class_list":["post-4791","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-command-line","category-linux","category-storage-management","category-system-administration","tag-linux","tag-sysadmin"],"modified_by":"Jim Hall","_links":{"self":[{"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/posts\/4791","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/users\/33"}],"replies":[{"embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4791"}],"version-history":[{"count":1,"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/posts\/4791\/revisions"}],"predecessor-version":[{"id":4793,"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/posts\/4791\/revisions\/4793"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/media\/3306"}],"wp:attachment":[{"href":"https:\/\/www.both.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4791"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4791"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4791"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}