Skip to content

Instantly share code, notes, and snippets.

@2E0PGS
Last active April 29, 2024 15:21
Show Gist options
  • Save 2E0PGS/f63544f8abe69acc5caaa54f56efe52f to your computer and use it in GitHub Desktop.
Save 2E0PGS/f63544f8abe69acc5caaa54f56efe52f to your computer and use it in GitHub Desktop.
Fix Ubuntu and other Linux slow/hanging file copying via USB.

If your running a x64 bit Ubuntu or other Linux and find USB transfers hang at the end apply this fix:

echo $((16*1024*1024)) > /proc/sys/vm/dirty_background_bytes
echo $((48*1024*1024)) > /proc/sys/vm/dirty_bytes

I suggest you edit your /etc/rc.local file to make this change persistant across reboots.

sudo nano /etc/rc.local

Go to the bottom of the file and leave a space then paste in those two lines.

Save the file with ctrl + x then press y.

To revert the changes enter this in console and remove the lines in /etc/rc.local

echo 0 > /proc/sys/vm/dirty_background_bytes
echo 0 > /proc/sys/vm/dirty_bytes

More info and references: https://unix.stackexchange.com/questions/107703/why-is-my-pc-freezing-while-im-copying-a-file-to-a-pendrive/107722#107722

@linuxtavarez
Copy link

I'm not sure but suggested solution is just the placebo... nothing changed much...

Nothing at all 😂

It did for me.

@J-khatri
Copy link

J-khatri commented Dec 1, 2023

I'm not sure but suggested solution is just the placebo... nothing changed much...

Nothing at all

😂

I did not get your point ... does it work... or I'm right ( its placebo ) :-)

@guy-teube
Copy link

$ echo $((16*1024*1024)) > /proc/sys/vm/dirty_background_bytes
bash: /proc/sys/vm/dirty_background_bytes: Permission non accordée

$ echo $((48*1024*1024)) > /proc/sys/vm/dirty_bytes
bash: /proc/sys/vm/dirty_bytes: Permission non accordée

Is sudoing these commands safe? (Ubuntu 22.04)

@rktomz
Copy link

rktomz commented Mar 1, 2024

@guy-teube use - sudo su

@webolot
Copy link

webolot commented Mar 27, 2024

Works! Thank's @2E0PGS !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment