I am running Ubuntu 20.04 on an old Dell Optiplex 760 box and the transfer speeds while copying files to USB flash drives are quite slower than what they should be, furthermore, at the end of the transfer the transfer program (I've tried copying files with nautilus
, cp
, dd
, rsync
) hangs even after the whole file has been transferred to the USB drive - this hanging makes scripted file transfers difficult as execution can't proceed until the transfer program returns 0. I checked the file size and even did an md5sum
checksum to check the files' integrity and saw that the files had been copied correctly and were intact and yet the transfer program hangs around for around 5 minutes after 100% of the file has been transferred.
I thought the issue might be the device being recognized as a USB-1.0 device. I checked the output of lsusb
and cross-referenced that with the output of usb-devices
and found out that the flash drives are always being recognized as having USB2.0 speeds i.e. 480Mbps - so no problem with USB versions.
user@box:~$ lsusb Bus 006 Device 059: ID 0781:5567 SanDisk Corp. Cruzer Blade Bus 006 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 004 Device 002: ID 10f1:1a19 Importek USB 2.0 Camera Bus 004 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
the relevant part of the usb-devices
output
T: Bus=06 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 59 Spd=480 MxCh= 0 D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1 P: Vendor=0781 ProdID=5567 Rev=01.26 S: Manufacturer=SanDisk S: Product=Cruzer Blade S: SerialNumber=200530450005728000EF C: #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=200mA I: If#=0x0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage
which shows nothing amiss with the USB version being employed. I checked around and others have found some workarounds that have to do with setting vm.dirty_bytes
and vm.dirty_background_bytes
configuration in sysctl
to $((15*1024*1024))
bytes. This didn't improve the transfer speeds but the transfer programs are now allowed smaller buffer sizes and the lingering after 100% has stopped.
While working in Windows 7 on the same machine - using the same flash drives, I can consistently transfer with average speeds of 7-8MBps. However when I reboot and switch back to Ubuntu, average transfer rates onto USB flash drives don't ever top 2MBps.
The next apparent solution might have to do with the sync
mount option being used while mounting the drive. I checked my /etv/fstab
file and it has only entries pertaining to my HDDs - both SATA and USB connected drives are listed. But, none of my flash drives get listed in there. I use udiskctl --mount -b /dev/sdXX
to mount my USB drives - or nautiluts
automounts them for me - and don't know how I can check if sync
is a mount option.
How can I check if sync
is enabled, if so how can I disable it in Ubuntu 20.04
?
fsync
at that time). This will wait until everything from cache is written to the drive. Reading the file or runningmd5sum
will not check if the files is ok on the drive, it'll just read the cache. If you remove the drive during this time, plug it in somewhere else, and check the file, you'll see the file is corrupted.mount
command won't show you options that remain in default;cat /proc/mounts
orgrep /dev/sdXX /proc/mounts
should show you all.