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

BLOG

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.

INFORMATION

Managed Server Srl is a leading Italian player in providing advanced GNU/Linux system solutions oriented towards high performance. With a low-cost and predictable subscription model, we ensure that our customers have access to advanced technologies in hosting, dedicated servers and cloud services. In addition to this, we offer systems consultancy on Linux systems and specialized maintenance in DBMS, IT Security, Cloud and much more. We stand out for our expertise in hosting leading Open Source CMS such as WordPress, WooCommerce, Drupal, Prestashop, Joomla, OpenCart and Magento, supported by a high-level support and consultancy service suitable for Public Administration, SMEs and any size.

Red Hat, Inc. owns the rights to Red Hat®, RHEL®, RedHat Linux®, and CentOS®; AlmaLinux™ is a trademark of AlmaLinux OS Foundation; Rocky Linux® is a registered trademark of the Rocky Linux Foundation; SUSE® is a registered trademark of SUSE LLC; Canonical Ltd. owns 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 owns the rights to Oracle®, MySQL®, and MyRocks®; Percona® is a registered trademark of Percona LLC; MariaDB® is a registered trademark of MariaDB Corporation Ab; 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. Adobe Inc. holds the rights to Magento®; PrestaShop® is a registered trademark of PrestaShop SA; OpenCart® is a registered trademark of OpenCart Limited. Automattic Inc. owns the rights to WordPress®, WooCommerce®, and JetPack®; Open Source Matters, Inc. owns the rights to Joomla®; Dries Buytaert holds the rights to Drupal®. Amazon Web Services, Inc. holds the rights to AWS®; Google LLC holds the rights to Google Cloud™ and Chrome™; Microsoft Corporation holds the rights to Microsoft®, Azure®, and Internet Explorer®; Mozilla Foundation owns the rights to Firefox®. Apache® is a registered trademark of The Apache Software Foundation; PHP® is a registered trademark of the PHP Group. 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 Hetzner Online GmbH owns the rights to Hetzner®; OVHcloud is a registered trademark of OVH Groupe SAS; cPanel®, LLC owns the rights to cPanel®; Plesk® is a registered trademark of Plesk International GmbH; Facebook, Inc. owns the rights to Facebook®. This site is not affiliated, sponsored or otherwise associated with any of the entities mentioned above 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. Any other trademarks mentioned belong to their registrants. MANAGED SERVER® is a trademark registered at European level by MANAGED SERVER SRL, Via Enzo Ferrari, 9, 62012 Civitanova Marche (MC), Italy.

Back to top