Choose mount options for Ext4 file systems to balance data security, integrity, and I/O performance.
Mount for balanced security and performance
To balance data security and performance, run the mount command without specifying options.
sudo mount /dev/vdb /media/test
By default, the mount command uses the defaults option. The defaults option enables the following mount options: rw, atime, suid, dev, exec, async, auto, nouser, delalloc, data=ordered, barrier, and nodiscard. No additional options are required.
These defaults enable write cache, read-write permissions control, and file system logging to improve performance and stability while protecting data integrity.
-
Advantages: Balances data security and file system performance.
-
Disadvantages:
-
Data security: Some user data and file system metadata may remain in memory and not be written to disk, risking data loss.
-
Performance:
-
File access times are updated automatically, and the resulting metadata operations generate additional writes.
-
Blocks are allocated only when data is flushed from memory to disk, causing periodic large-block writes and delayed allocation.
-
-
Mount for data security
To prioritize data security, mount file systems with the following options: rw, atime, sync, barrier, and data=journal.
sudo mount -o rw,atime,sync,barrier,data=journal /dev/vdb /media/test
The atime, sync, barrier, and data=journal options degrade file system performance. The impact varies by instance type and workload. Examples:
-
I/O-intensive workloads are affected more significantly because each I/O operation involves a disk write.
-
HDD-based instance types (such as those with local HDDs) are affected more than SSD-based instance types (such as those with standard SSDs and enhanced SSDs).
Without these options, an unexpected software exit or hardware breakdown may cause data loss because unwritten data or metadata remains in memory. With these options, all modifications are synchronized to disk and all data is written to file system journals sequentially. However, data loss may still occur in rare cases even after file system recovery.
-
Advantages: Provides high data security and prevents data loss after a system breakdown.
-
Disadvantages: Degrades file system performance.
Mount for performance
To prioritize performance, mount file systems with the following options: defaults, noatime, nodiratime, nobarrier, nodelalloc, and data=writeback.
sudo mount -o defaults,noatime,nodiratime,nobarrier,nodelalloc,data=writeback /dev/vdb /media/test
The noatime, nodiratime, nobarrier, and data=writeback options reduce data security. Proceed with caution.
-
Without these options, each file operation is recorded, which delays block allocation and degrades performance.
-
With the
syncoption, file systems submit all logs and allocate blocks at once, which may cause periodic I/O glitches. For HDD storage media, this reduces disk writes, improves performance, and extends media lifetime. For SSD storage media, the performance improvement is negligible.
These options improve performance by disabling delayed block allocation, disabling log-ordered writes, and reducing disk writes.
-
Advantages: Improves file system performance (throughput and latency).
-
Disadvantages: Does not ensure data security. Data in file systems may be lost after a system breakdown.
-
Run
cat /proc/fs/ext4/vdb/optionsto view all mount options for a disk. Runman mountto view mount option descriptions, or see fstab. -
For other requirements, run the
mountcommand with appropriate options.