1. Use memory instead of disk
This tip can also lead to data loss. If you do it, you will have to always shut down your computer properly from now on, because unexpected power failures will lead to data loss.
Linux usually ensures that all changes are written to disk every few seconds. Since disk writes are so slow, you can change your system to keep things in memory longer. All changes will be written to memory, and the excruciatingly slow writes to happen in the background while you continue working. This has an instant, noticeable effect, but it can lead to data loss.
Add these lines to /etc/sysctl.conf, and reboot.
vm.swappiness = 0 vm.dirty_background_ratio = 20 vm.dirty_expire_centisecs = 0 vm.dirty_ratio = 80 vm.dirty_writeback_centisecs = 0
The problem: using this tip means that your system stops writing changes to disk until you shut down or type “sync” at a command line. If your system loses power unexpectedly, you will get bad blocks. I did. You can limit the amount of data loss in the event of a power failure to one minute by setting vm.dirty_writeback_centisecs = 6000.
A side effect is that shutting down your computer will may take several minutes where it appears to be doing nothing. Don’t cut the power until it’s done, because it is busy writing all those changes to disk.
2. Using ramdisks (tmpfs) for temporary files
It is quite easy to move directories where temporary files are stored (primarily /tmp) to a ramdisk, and it can make a significant difference in performance. The following lines added to /etc/fstab cause /tmp and /var/tmp to be stored in ramdisks:
tmpfs /tmp tmpfs defaults 0 0 tmpfs
/var/tmp tmpfs defaults 0 0 Reference: http://linuxonflash.blogspot.hk/2014/10/optimizing-system-performance-of-flash.html
By default, the ext3/ext4 filesystem updates the access time attribute on a file system object whenever it’s read. This results in even the most trivial file reads result in a write operation. Keeping the access time updated is only important for some very specific tasks which we’re not likely to come across.
/etc/fstab and for each mount that is on your USB storage, add a
noatime parameter. For example:
/dev/mapper/vg_root-lv_root / ext4 errors=remount-ro 0 1
/dev/mapper/vg_root-lv_root / ext4 noatime,errors=remount-ro 0 1
4. IO Scheduler
The default IO Scheduler used by Ubuntu is
cfq. Changing this to
deadline will see improved performance during times where multiple processes are trying to read/write to disk. You can change the default scheduler for all devices by adding a kernel parameter into grub.
/etc/default/grub and find the following line:
Or, if you added the
verbose option earlier:
update-grub to apply your changed setting to
grub.cfg and restart for the change to take effect.
sudo update-grub sudo reboot
To see that your new scheduler has taken effect you can query which scheduler is currently in use for a specific device with this command: