July 18 2023

Speed ​​up disk reads and writes with Linux, safeguarding disk wear and tear thanks to the noatime and nodoratime mounting options

Two simple attributes to improve the speed and performance of the disks and safeguard their wear.

It is important to understand how to optimize disk read and write operations on a Linux system to ensure high performance, longer disk life, and overall system efficiency. With the advancement in technology, we have seen an increase in the use of solid state storage devices such as SSD and NVMe drives. These drives are known for their speed and endurance, but have a limited lifecycle of read and write operations.

One of the techniques we can use to extend the life of these devices and improve system performance is the use of the 'noatime' and 'nodiratime' mount options. These options allow us to limit the updating of access metadata, thus reducing the number of writes to disk and increasing I/O performance. In this article, we will explore in detail how these options work and how they can be applied to improve system performance and disk longevity.

Understand SSD and NVMe drive technology

In order to fully optimize read and write operations on a Linux system, it is essential to have a clear understanding of the data storage devices used. In this section, we will focus on two types of data storage devices that are widely used today: SSDs (Solid State Drives) and NVMe (Non-Volatile Memory Express).

SSD VS nVME

SSD drives: speed and resilience

SSDs, or Solid State Drives, have revolutionized the world of data storage. Unlike traditional hard disk drives (HDDs), which use mechanical disks and moving read/write heads, SSDs have no moving parts. This makes them not only more robust and resistant to shocks, but also much quieter.

At the heart of SSDs is flash memory, a form of non-volatile memory that retains data even when there is no power. This flash memory is made up of memory cells that can store electrons, which are used to represent data. Unlike hard drives, which physically need to move a read/write head to access data, SSDs can quickly access any cell of flash memory. This allows SSD drives to have extremely fast data access times, significantly improving overall system performance.

NVMe drives: a step forward in SSD technology

NVMe drives, or Non-Volatile Memory Express, represent the evolution of SSD drives. While traditional SSD drives use interfaces such as SATA (Serial ATA) or SAS (Serial Attached SCSI), which were originally designed for hard drives, NVMe drives use the system's PCI Express (Peripheral Component Interconnect Express) interface.

PCI Express is a high-speed interface that connects devices directly to the system processor, allowing them to communicate much faster than SATA or SAS interfaces. This allows NVMe drives to achieve significantly faster data transfer speeds than traditional SSD drives.

However, like SSD drives, NVMe drives also have a limit on the number of read and write operations they can withstand before starting to show signs of wear. This limit, known as Total Bytes Written (TBW) or Drive Writes Per Day (DWPD), represents the total amount of data that can be written to the drive during its lifetime. Exceeding this limit can lead to performance degradation or even drive failure.

In conclusion, SSD and NVMe drives represent a significant step forward over traditional hard drives in terms of speed and resiliency. However, it is important to take into account their read and write limit to ensure they last as long as possible and continue to provide high performance. The 'noatime' and 'nodiratime' mount options, which we will explore in the next sections, are invaluable tools that can help us achieve this.

Access metadata and disk wear

On a Linux system, every time a file is read, the operating system updates an attribute called 'atime', or access time, which records the last time the file was accessed. This information may be useful for some applications, but most of the time it is not used. The problem is that each update of 'atime' requires a disk write operation. Considering that many operations on a Linux system involve reading files, constantly updating 'atime' can cause significant disk write overhead.

Similarly, the 'diratime', or directory access time, attribute records the last time a directory was accessed. Again, most applications don't need this information, but the operating system keeps updating it every time a directory is read, causing additional writes to the disk.

The 'noatime' and 'nodiratime' mount options

That's where the 'noatime' and 'nodiratime' mount options come into play. When these options are enabled, the operating system stops updating the 'atime' and 'diratime' attributes, respectively. This means there will be fewer writes to the disk, which can help extend the life of SSD and NVMe drives.

Also, since write operations generally require more time and resources than read operations, reducing the number of writes can also help improve system performance. In particular, it can increase disk throughput (the amount of data that can be read from or written to in a given period of time) and improve system I/O.

How to apply the 'noatime' and 'nodiratime' mount options

To apply the 'noatime' and 'nodiratime' mount options, you need to edit your system's /etc/fstab file. This file contains information about where the system should mount the various parts of the file system. For each partition you want to optimize, you can add 'noatime,nodiratime' to the mount options column.

noatime knotiratime

For example, suppose you have a partition /dev/sda1 mounted at /home. The corresponding line in the /etc/fstab file might look like this:

/ dev / sda1 / home ext4 defaults 0 2

To apply the 'noatime' and 'nodiratime' options, you would change this line to:

/dev/sda1 /home ext4 defaults,noatime,nodiratime 0 2

After saving and closing the file, you can apply the changes with the 'mount -o remount' command.

Conclusion

SSD and NVMe drives are powerful tools that can provide significant speed and efficiency in a Linux system. However, their lifespan can be limited by the number of read and write operations they can perform. Using the 'noatime' and 'nodiratime' mount options, you can reduce the number of writes to the disk, helping to extend the life of these drives and improve system performance.

It is important to note that while these options can offer many advantages, they can also have some disadvantages. For example, some applications may need the 'atime' and 'diratime' information and may not work properly without them. Therefore, before applying these options, it is always a good idea to research and understand the possible implications for your specific system and workload.

Do you have doubts? Don't know where to start? Contact us!

We have all the answers to your questions to help you make the right choice.

Chat with us

Chat directly with our presales support.

0256569681

Contact us by phone during office hours 9:30 - 19:30

Contact us online

Open a request directly in the contact area.

DISCLAIMER, Legal Notes and Copyright. RedHat, Inc. holds the rights to Red Hat®, RHEL®, RedHat Linux®, and CentOS®; AlmaLinux™ is a trademark of the AlmaLinux OS Foundation; Rocky Linux® is a registered trademark of the Rocky Linux Foundation; SUSE® is a registered trademark of SUSE LLC; Canonical Ltd. holds the rights to Ubuntu®; Software in the Public Interest, Inc. holds the rights to Debian®; Linus Torvalds holds the rights to Linux®; FreeBSD® is a registered trademark of The FreeBSD Foundation; NetBSD® is a registered trademark of The NetBSD Foundation; OpenBSD® is a registered trademark of Theo de Raadt; Oracle Corporation holds the rights to Oracle®, MySQL®, MyRocks®, VirtualBox®, and ZFS®; Percona® is a registered trademark of Percona LLC; MariaDB® is a registered trademark of MariaDB Corporation Ab; PostgreSQL® is a registered trademark of PostgreSQL Global Development Group; SQLite® is a registered trademark of Hipp, Wyrick & Company, Inc.; KeyDB® is a registered trademark of EQ Alpha Technology Ltd.; Typesense® is a registered trademark of Typesense Inc.; REDIS® is a registered trademark of Redis Labs Ltd; F5 Networks, Inc. owns the rights to NGINX® and NGINX Plus®; Varnish® is a registered trademark of Varnish Software AB; HAProxy® is a registered trademark of HAProxy Technologies LLC; Traefik® is a registered trademark of Traefik Labs; Envoy® is a registered trademark of CNCF; Adobe Inc. owns the rights to Magento®; PrestaShop® is a registered trademark of PrestaShop SA; OpenCart® is a registered trademark of OpenCart Limited; Automattic Inc. holds the rights to WordPress®, WooCommerce®, and JetPack®; Open Source Matters, Inc. owns the rights to Joomla®; Dries Buytaert owns the rights to Drupal®; Shopify® is a registered trademark of Shopify Inc.; BigCommerce® is a registered trademark of BigCommerce Pty. Ltd.; TYPO3® is a registered trademark of the TYPO3 Association; Ghost® is a registered trademark of the Ghost Foundation; Amazon Web Services, Inc. owns the rights to AWS® and Amazon SES®; Google LLC owns the rights to Google Cloud™, Chrome™, and Google Kubernetes Engine™; Alibaba Cloud® is a registered trademark of Alibaba Group Holding Limited; DigitalOcean® is a registered trademark of DigitalOcean, LLC; Linode® is a registered trademark of Linode, LLC; Vultr® is a registered trademark of The Constant Company, LLC; Akamai® is a registered trademark of Akamai Technologies, Inc.; Fastly® is a registered trademark of Fastly, Inc.; Let's Encrypt® is a registered trademark of the Internet Security Research Group; Microsoft Corporation owns the rights to Microsoft®, Azure®, Windows®, Office®, and Internet Explorer®; Mozilla Foundation owns the rights to Firefox®; Apache® is a registered trademark of The Apache Software Foundation; Apache Tomcat® is a registered trademark of The Apache Software Foundation; PHP® is a registered trademark of the PHP Group; Docker® is a registered trademark of Docker, Inc.; Kubernetes® is a registered trademark of The Linux Foundation; OpenShift® is a registered trademark of Red Hat, Inc.; Podman® is a registered trademark of Red Hat, Inc.; Proxmox® is a registered trademark of Proxmox Server Solutions GmbH; VMware® is a registered trademark of Broadcom Inc.; CloudFlare® is a registered trademark of Cloudflare, Inc.; NETSCOUT® is a registered trademark of NETSCOUT Systems Inc.; ElasticSearch®, LogStash®, and Kibana® are registered trademarks of Elastic NV; Grafana® is a registered trademark of Grafana Labs; Prometheus® is a registered trademark of The Linux Foundation; Zabbix® is a registered trademark of Zabbix LLC; Datadog® is a registered trademark of Datadog, Inc.; Ceph® is a registered trademark of Red Hat, Inc.; MinIO® is a registered trademark of MinIO, Inc.; Mailgun® is a registered trademark of Mailgun Technologies, Inc.; SendGrid® is a registered trademark of Twilio Inc.; Postmark® is a registered trademark of ActiveCampaign, LLC; cPanel®, LLC owns the rights to cPanel®; Plesk® is a registered trademark of Plesk International GmbH; Hetzner® is a registered trademark of Hetzner Online GmbH; OVHcloud® is a registered trademark of OVH Groupe SAS; Terraform® is a registered trademark of HashiCorp, Inc.; Ansible® is a registered trademark of Red Hat, Inc.; cURL® is a registered trademark of Daniel Stenberg; Facebook®, Inc. owns the rights to Facebook®, Messenger® and Instagram®. This site is not affiliated with, sponsored by, or otherwise associated with any of the above-mentioned entities and does not represent any of these entities in any way. All rights to the brands and product names mentioned are the property of their respective copyright holders. All other trademarks mentioned are the property of their respective registrants.

JUST A MOMENT !

Have you ever wondered if your hosting sucks?

Find out now if your hosting provider is hurting you with a slow website worthy of 1990! Instant results.

Close the CTA
Back to top