Methods of payment Abuse

Disable EXT4 journaling

24.10.2022, 03:14

You probably know about what journaling is. So, it is in file systems it is needed so that it is possible to recover the file system in case of a failure. This is especially useful in cases where data write operations were in progress at the time of the failure.

It is known that when a write is incomplete, the file system will remain in a corrupted state and cannot be mounted. If you enable logging, the fsck program will be able to perform a check during system boot and restore the state from the log. Next let's see how to disable logging in Ext4.

Disabling logging

How to check if logging is enabled for a particular disk partition? Execute:

$ sudo dumpe2fs /dev/nvme0n1p5 | grep has_journal

Disable EXT4 journaling

See /dev/nvme0n1p5 - partition file. It may have a different name. If there is has_journal in the Filesystem Features line, then the journal is enabled. If it is enabled and everything works. Disabling filesystem journaling is done like this:

$ sudo tune2fs -O ^has_journal /dev/nvme0n1p5

Disable EXT4 journaling

If you don't want to disable journaling, but still want the system to be more productive, enable writeback mode. After that, no data will be written to the journal, except for metadata.

The data is first on the disk, after which the operation is logged. Ext4 shows the best performance in this mode of operation.

Let's do it:

$ sudo tune2fs -o journal_data_writeback /dev/nvme0n1p5

How do I get the journaling mode back? To do this, you can execute:

$ sudo tune2fs -o journal_data_ordered /dev/nvme0n1p5

Disable EXT4 journaling

Similar to writeback mode , /etc/fstab can be activated by the user. In the partition mount options add data=writeback:

$ sudo vi /etc/fstab

Disable EXT4 journaling

Is there any other way to maximize performance? Yes, add the noatime option, which disables updating the last accessed file field. This reduces the number of disk accesses, but will extend the life of the SSD.