--- layout: post title: "Fix system freezing while copying to a flash drive" date: 2014-04-26 21:11 comments: true categories: [linux] cover: /images/cover/avatar.png keywords: linux, kernel, freezing, usb, flash drive, fix, slow, unresponsive description: Slow linux desktop while copying to a flash drive --- I copied about 10 GiB data from my hard drive to a USB3.0 flash drive. Much to my surprise the system started freezing, songs playback became interrupted, etc. Eventually I had to wait until the copying process finished. Well, something like that is simply unacceptable if you have 8-core i7 processor, 8 GiB RAM and SSD. So I've found a simple solution. The problem was wrong setting of dirty pages (because of [historical reasons](https://lwn.net/Articles/572928/)). It's a [well-known](http://thread.gmane.org/gmane.linux.kernel/1584789/focus=1587022) Linux kernel problem. What I did was: {% codeblock lang:bash %} echo 0 > /proc/sys/vm/dirty_background_ratio echo 33554432 > /proc/sys/vm/dirty_background_bytes echo 66554432 > /proc/sys/vm/dirty_bytes {% endcodeblock %} After applying these changes CPU load dropped from 6 to 3 and system was fast and responsive. To make that changes persistent add the lines below to ```/etc/tmpfiles.d/dirty.conf```: {% codeblock %} w /proc/sys/vm/dirty_background_ratio - - - - 0 w /proc/sys/vm/dirty_background_bytes - - - - 33554432 w /proc/sys/vm/dirty_bytes - - - - 66554432 {% endcodeblock %} Maybe it's already fixed in current kernel, I don't know. I'm running OpenSUSE 13.1 with 3.11.10-7-desktop kernel.