Programster's Blog

Tutorials focusing on Linux, programming, and open-source

Fix Freezes When Transferring Files


I have found that my Ubuntu Desktop machine will keep pausing/freezing whenever I am transferring a large amount of data to my NFS. Others have experienced this issue when transferring files to a USB stick.

It appears that this has to do with having a very large cache of "dirty files" being held, and when that cache gets too full, your system will "pause" whilst it ensures all that data is actually written to disk. Thus to "fix" this issue, you can reduce your cache size so your system doesn't get overwhelmed to the point where it becomes unusable.

You can implement this immediately with the following

sudo echo $((100*1024*1024)) | sudo tee /proc/sys/vm/dirty_background_bytes && \
  sudo echo $((100*1024*1024)) | sudo tee /proc/sys/vm/dirty_bytes

... however, you would need to run that every time your system reboots. To resolve this issue across reboots, you may wish to add this to your /etc/rc.local file.

echo $((100*1024*1024)) | sudo tee /proc/sys/vm/dirty_background_bytes
echo $((100*1024*1024)) | sudo tee /proc/sys/vm/dirty_bytes


Last updated: 10th January 2023
First published: 16th August 2018