Filesystem Tweaks

From Athenaeum
Jump to: navigation, search


Clear Disk Cache

echo 3 | sudo tee /proc/sys/vm/drop_caches

ext4 Speed Tweaks

1) Run this command on every partition you want to boost:

tune2fs -o journal_data_writeback /dev/sdXY

2) Edit fstab for your boosted partitions. Change the options to:

commit=100,nodiratime,noatime,data=writeback,barrier=0,nobh,errors=remount-ro
Note: If you're using an SSD make sure to add discard to the end.
  • Replacing atime/relatime with noatime or nodiratime. This causes the FS to not write read-times to a file/directory when read. Think about it. Writing to the FS for every read of the FS?
  • Next is data=writeback. This means that metadata for files can be written lazily after the file is written. This will not cause file system corruption, but it may cause the most recent changes to be lost in the event of a crash (so you may jump back into the past a bit). However, if you're using a battery backup you have nothing to worry about.
  • Next is barrier, which is slightly more dangerous:

barrier=<0|1(*)> This enables/disables the use of write barriers in the jbd code. barrier=0 disables, barrier=1 enables. This also requires an IO stack which can support barriers, and if jbd gets an error on a barrier write, it will disable again with a warning. Write barriers enforce proper on-disk ordering of journal commits, making volatile disk write caches safe to use, at some performance penalty. If your disks are battery-backed in one way or another, disabling barriers may safely improve performance.

  • Next is nobh:

bh (*) ext4 associates buffer heads to data pages to nobh (a) cache disk block mapping information (b) link pages into transaction to provide ordering guarantees. “bh” option forces use of buffer heads. “nobh” option tries to avoid associating buffer heads (supported only for “writeback” mode).

Note:You can skip barrier and nobh if you’d like. noatime and data=writeback are the big ones.

3) Reboot to your system.