[SOLVED] Copy to USB stick slows down the more I copy
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
If I copy 500Mb of files, all mp3, files of about 4-10Mb in size it goes at a madrate pace.
If I copy 2Gb of files of a similar nature it starts quick enough but slows down to a snails pace
Okat, it is USB 2.0 so I'm not expecting lightning speed but it is extremely slow.
I've used the USB Stick Formatter and tried FAT32 and NTFS - no difference. To be fair NTFS looked good at first, really fast but after a 1 or 2Gb it slowed down.
I've tried usong Thunar, Right Click, Copy and using cp -r -v in a terminal. No difference in speed.
Doing free shows this
Code:
total used free shared buff/cache available
Mem: 12282524 2339168 1217300 71400 8726056 9486072
Swap: 2097148 0 2097148
And I've included a few screenshots of Thunar progress.
So I was wondering if there might be a cunning way of doing this copy, for example a loop through A to Z (All the directories begin with an Uppercase letter) in a terminal might be quicker.
Distribution: Cinnamon Mint 20.1 (Laptop) and 20.2 (Desktop)
Posts: 1,673
Rep:
I can't think of any technical reason off the top of my head but my first thought is:
"Where are you copying the files FROM?"
If it's the Internet, depending on where in the World the files are, Internet speeds and whether the files are stored in a contiguous format somewhere could impact the copy speed.
If it's local storage... Does copying to a different stick behave differently?
I can't think of any technical reason off the top of my head but my first thought is:
"Where are you copying the files FROM?"
If it's the Internet, depending on where in the World the files are, Internet speeds and whether the files are stored in a contiguous format somewhere could impact the copy speed.
If it's local storage... Does copying to a different stick behave differently?
Play Bonny!
It's from a local HDD to a USB 2.0 32GB stick, and using a different stick doesn't make much difference
Could it simply be card buffer being filled up combined with slow-ish usb2 speed?
Your numbers says nothing for me, but a pci card with usb3 ports for your front panel cost next to nothing... could be an option if you fail to gain speed.
Has it always been slow? New kernel? I've noticed numerous times that kernel had bug/quirk fixes re. usb ports and cards...
I've seen this. It is simply a buffer gets filled and then must wait for writes to complete. Writes to the USB Flash slows down the copy process. This is normal. I've since moved on to using USB SSD drives (Samsung T5s and T7s) which seem to have a 'bigger' buffer and are normally quite quick. Also everything I use now is USB 3.x compatible if possible.
There is an area of memory set aside as a cache. When you are copying from one device to another each input record is read into the cache and then written from cache to the output device. If the input device is faster than the output device the copy runs at the input device speed but writes from cache to the output device at the output device speed until the cache fills up. Then the copy cannot read an input record until cache space becomes available for another input record. So at that point the reported copy speed drops to the speed of the output device.
Some copy programs report the end of the copy when the last input record is read into the cache. In fact the copy does not end until the cache is completely written to the output device. So is important that you issue a umount command before removing any devices. The umount command makes sure that there are no outstanding records still waiting to be written from the cache before unmounting the device.
As to device speed there are many cheap USB devices that run at less than the rated speed so two supposedly equal devices may run at different speeds.
So is important that you issue a umount command before removing any devices.
Just to highlight! Important. If the USB drive has a light, you need to wait until it stops flashing (or wait a few seconds if no light) after the umount command is issued (whether from command line or from GUI) before manually removing drive.
Thanks folks, I think it's just a rubbish cheap usb 2.0 stick, whether it's a command line cp or using copy with Thunar I'm not sure if it makes any difference.
Here is an iostat every 60 seconds where I used cp
Just to highlight! Important. If the USB drive has a light, you need to wait until it stops flashing (or wait a few seconds if no light) after the umount command is issued (whether from command line or from GUI) before manually removing drive.
Yep I know that, and yes I always unmount usb devices before removing them.
I think that some of the kernels are responsible for this. I've got 3 little 2GB usb3 canvio basic external hard drives. Around kernel 5.10.something(arch). That little hard drive had bad write speeds that fluctuated all over, took forever to write. I thought maybe the drive was going bad, or the board on the drive. I updated to kernel 5.12.something(arch). Problem went away. Had no problem since, until kernel 5.16.14(arch). Same problem appeared, so I downgraded the kernel to 5.14.7. which I had in the cache, problem went away again. And that is on multiple drives.
When you change kernels and the usb write speed and stability changes, I can't help but think that is the problem.
With a good kernel the write speed is 24-26MBps on USB2, and 110-120MBps on USB3. According to gkrellm.
With the problem kernels the speeds on USB2 fluctuate from 24MBps down to 1.5Mbps.
And that is from SATA hard drive to usb port.
I don' have a fix. I've read about how that works like others have. Something for you to consider.
I was looking into this:
(Dont run this, just a direction of thought from my notes.)
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.