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 :

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

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 :

[bash]gksudo gedit /etc/default/grub[/bash]

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

Find :

[code]GRUB_CMDLINE_LINUX_DEFAULT=""[/code]

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

[code]GRUB_CMDLINE_LINUX_DEFAULT="quiet splash elevator=deadline"[/code]

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

[bash]sudo update-grub[/bash]

You’ll get something like this :

[code]Generating grub.cfg …
Found linux image: /boot/vmlinuz-2.6.31-20-generic
Found initrd image: /boot/initrd.img-2.6.31-20-generic
Found memtest86+ image: /boot/memtest86+.bin
done[/code]

It means grub.cfg has been rebuilt successfully. You are now good to go.

For legacy Grub :

[bash]gksudo gedit /boot/grub/menu.lst[/bash]

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

Find the kernel line for your current kernel. It will be something like :

[code]kernel /boot/vmlinuz-2.6.12-10-386 root=/dev/hda2 ro quiet splash[/code]

It will differ according to the kernel version and the logical drive to which Ubuntu is installed. Now add elevator=deadline to it. After the edit, it should look like this :

[code]kernel /boot/vmlinuz-2.6.12-10-386 root=/dev/hda2 ro quiet splash elevator=deadline[/code]

Reboot your system and you are good to go.

Join the Conversation

12 Comments

  1. I have started using the “deadline” scheduler this morning at work, and my i7 now feels like a quad-core powered beast instead of a freeze-prone kitty 😀

    Thank you very much!

  2. Worked like a charm, thanks a lot ! What’s the difference between this scheduler and the default (and the other alternatives) ?

Leave a comment

Leave a Reply