Copying files from PC to Pendrive gets stuck at the end on Ubuntu 16.04
772
I don't know why it's happening only to me. Whenever copyingbigger or sometimes smaller < 1GB files from PC to pendrive literally gets stuck at the end.
It’s not just happening to you :-) The problem is due to how linux works and the default settings that Ubuntu gives you. The file copy tool is reading a chunk of the source file then writing it to the destination, and updates the progress bar each time it finishes a write. However, to speed things up, Linux takes the data that is meant to be written and immediately tells the program that is has been written, while doing the work in the background. Linux allows some percentage of system memory to be used for this purpose, which with the size of memory these days is usually more than the entire file, so a program can think it has written the whole thing when in reality the copy has just begun. But, when a program tries to close the file, Linux makes it wait for the operation to complete. (else the program might try doing something with a half-written file)
You see this the most when writing large files to slow devices, like USB, but it can show up in other situations too and make it look like the computer is locking up.
The thing I do to “fix” the problem is tell Linux to buffer less data. That way an application can’t get so far ahead of the actual progress. This involves changing a kernel parameter, which is a power-user thing that should be done with care. You need to add “vm.dirty_bytes=15000000” to /etc/sysctl.conf
echo vm.dirty_bytes=15000000 | sudo tee -a /etc/sysctl.conf
then reboot.
That sets the buffer size to 15MB, which is a number I picked, and roughly translates to “half a second writing to a fast USB2 device”. You can choose larger (or smaller, but probably not too much smaller) as you like.
The disadvantage of this setting is that high-throughput operations might run slower, like running a bunch of file copies simultaneously. It could also cause a laptop drive to come out of sleep mode more frequently.
I had same issue on Ubuntu 19.10 with 16GB Kingston G4 USB 3.0 pendrive. Files gnome app was stuck at end of progress forever and you could not eject the usb.
I was copying movie file of 1.2 GB size.
Solution is just to format pendrive to NTFS file system instead of FAT. When I did that, everything was working fine.
It’s not just happening to you :-) The problem is due to how linux works and the default settings that Ubuntu gives you. The file copy tool is reading a chunk of the source file then writing it to the destination, and updates the progress bar each time it finishes a write. However, to speed things up, Linux takes the data that is meant to be written and immediately tells the program that is has been written, while doing the work in the background. Linux allows some percentage of system memory to be used for this purpose, which with the size of memory these days is usually more than the entire file, so a program can think it has written the whole thing when in reality the copy has just begun. But, when a program tries to close the file, Linux makes it wait for the operation to complete. (else the program might try doing something with a half-written file)
You see this the most when writing large files to slow devices, like USB, but it can show up in other situations too and make it look like the computer is locking up.
The thing I do to “fix” the problem is tell Linux to buffer less data. That way an application can’t get so far ahead of the actual progress. This involves changing a kernel parameter, which is a power-user thing that should be done with care. You need to add “vm.dirty_bytes=15000000” to /etc/sysctl.conf
then reboot.
That sets the buffer size to 15MB, which is a number I picked, and roughly translates to “half a second writing to a fast USB2 device”. You can choose larger (or smaller, but probably not too much smaller) as you like.
The disadvantage of this setting is that high-throughput operations might run slower, like running a bunch of file copies simultaneously. It could also cause a laptop drive to come out of sleep mode more frequently.
I had same issue on Ubuntu 19.10 with 16GB Kingston G4 USB 3.0 pendrive. Files gnome app was stuck at end of progress forever and you could not eject the usb. I was copying movie file of 1.2 GB size.
Solution is just to format pendrive to NTFS file system instead of FAT. When I did that, everything was working fine.
Try install the ntfs driver first.