Get rid of freeze-ups during disk I/O activity in Ubuntu

If you are using Ubuntu(or it’s variants), and your computer locks/freezes up or becomes unusable during copying files or heavy disk activity, this post is for you.

Ubuntu currently employs the kernel default I/O scheduler, CFQ or Completely Fair Queuing. It has been known to cause lags and lock-ups during heavy disk activity like copying/moving or backing up data, and one (still-active) bugs report demands the use of an alternative I/O scheduler by default in future Ubuntu releases.

Personally, my computer became virtually unusable during moving/copying files and it has been completely eradicated by the use of an alternative scheduler, Deadline. I’ll be using it for the examples here. Other alternative I/O schedulers include :

noop

anticipatory

At first, you need to check whether you really benefit from the use of an alternative i/o scheduler. To do this, run this from the console :

echo "deadline" | sudo tee /sys/block/sda/queue/scheduler

Now copy a large file to/from your hard drive. If the lock-ups vanish, this has worked for you. Now, we need to make this permanent for your system. To do this, you need to know which version of Ubuntu you are using. If you are using Ubuntu 9.10 (Karmic Koala) or higher, you will be using Grub2, else you’ll be using Grub Legacy. I have got instructions for both.

For Grub2 :

gksudo gedit /etc/default/grub

For Kubuntu and Xubuntu, you will need to use kdesu kate and gksudo mousepad in place of gksudo gedit respectively.

Find :

GRUB_CMDLINE_LINUX_DEFAULT=""

Add elevator=deadline before the end of the closing double-quotes. For me, after the edit, that line looked like this :

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash elevator=deadline"

After you are done, save and close the file. Now run “update-grub” from the terminal.

[...] it seems that the disk scheduler is to blame here. But fear not, for there is a simple solution to your grievings. Changing the scheduler from CFQ (Completely Fair Queuing) to Deadline seems to [...]