| 1 | 1 | new file mode 100644 | 
                    
                | ... | ... | @@ -0,0 +1,42 @@ | 
                    
                |  | 0 | +--- | 
                    
                |  | 1 | +layout: post | 
                    
                |  | 2 | +title: "Fix system freezing while copying to a flash drive" | 
                    
                |  | 3 | +date: 2014-04-26 21:11 | 
                    
                |  | 4 | +comments: true | 
                    
                |  | 5 | +categories: [linux] | 
                    
                |  | 6 | +cover: /images/cover/avatar.png | 
                    
                |  | 7 | +keywords: linux, kernel, freezing, usb, flash drive, fix, slow, unresponsive | 
                    
                |  | 8 | +description: Slow linux desktop while copying to a flash drive | 
                    
                |  | 9 | +--- | 
                    
                |  | 10 | + | 
                    
                |  | 11 | +I copied about 10 GiB data from my hard drive to a USB3.0 flash drive. | 
                    
                |  | 12 | +Much to my surprise the system started freezing, songs playback became | 
                    
                |  | 13 | +interrupted, etc. Eventually I had to wait until the copying process finished. | 
                    
                |  | 14 | + | 
                    
                |  | 15 | +Well, something like that is simply unacceptable if you have 8-core i7 processor, | 
                    
                |  | 16 | +8 GiB RAM and SSD.  | 
                    
                |  | 17 | + | 
                    
                |  | 18 | +So I've found a simple solution. The problem was wrong setting of dirty pages | 
                    
                |  | 19 | +(because of [historical reasons](https://lwn.net/Articles/572928/)). | 
                    
                |  | 20 | +It's a [well-known](http://thread.gmane.org/gmane.linux.kernel/1584789/focus=1587022) | 
                    
                |  | 21 | +Linux kernel problem. | 
                    
                |  | 22 | + | 
                    
                |  | 23 | +What I did was: | 
                    
                |  | 24 | + | 
                    
                |  | 25 | +{% codeblock lang:bash %} | 
                    
                |  | 26 | +echo 0 > /proc/sys/vm/dirty_background_ratio | 
                    
                |  | 27 | +echo 33554432 > /proc/sys/vm/dirty_background_bytes | 
                    
                |  | 28 | +echo 66554432 > /proc/sys/vm/dirty_bytes | 
                    
                |  | 29 | +{% endcodeblock %} | 
                    
                |  | 30 | + | 
                    
                |  | 31 | +After applying these changes CPU load dropped from 6 to 3 and system was fast  | 
                    
                |  | 32 | +and responsive. To make that changes persistent add the lines below to ```/etc/tmpfiles.d/dirty.conf```: | 
                    
                |  | 33 | + | 
                    
                |  | 34 | +{% codeblock %} | 
                    
                |  | 35 | +w /proc/sys/vm/dirty_background_ratio - - - - 0 | 
                    
                |  | 36 | +w /proc/sys/vm/dirty_background_bytes - - - - 33554432 | 
                    
                |  | 37 | +w /proc/sys/vm/dirty_bytes - - - - 66554432 | 
                    
                |  | 38 | +{% endcodeblock %} | 
                    
                |  | 39 | + | 
                    
                |  | 40 | +Maybe it's already fixed in current kernel, I don't know. I'm running OpenSUSE 13.1 | 
                    
                |  | 41 | +with 3.11.10-7-desktop kernel.  | 
                    
                | 0 | 42 | \ No newline at end of file |