USB write: delay between when Ubuntu says its done and it actually being done
Solution 1
Unmount the drive properly before you pull it out.. From terminal, use sync
to make it write now, sudo umount /path/to/stick
to properly unmount it. From GUI file manager, there are quite a lot of ways to do this - you may have a symbol next to the drive icon, or right-click it & eject or unmount.
You can't reliably just pull out a stick in any common OS, as writes are cached to let your commands take priority - if you did multiple edits & it made you wait for each write, you'd not like it. It's the same as Windows 'safely remove..'
Solution 2
It happens because Ubuntu takes all the data from the disk that is to be written to the USB and save it in the RAM buffer (Depends on the capacity of RAM). Then Ubuntu shows that the data has been written to the USB but actually data is being transferred from the buffer to the USB at that time. So, if you remove your USB during the transfer (although Ubuntu has shown you the transfer is done), you'll find that all data has not been transferred. You can use
sudo iotop
to check for real time transfer between disk and other I/O and when you found that the transfer has really been done then you can safely remove the USB.
Related videos on Youtube
Cheiron
Updated on September 18, 2022Comments
-
Cheiron almost 2 years
When I write data to an USB device (like a memory stick or a external HDD) Ubuntu shows the data being transfered at a very high rate, it is done very fast. But then, when Ubuntu says its done, the usb write LED flickers for a long time. And when I pull out the USB during the flickering, the data transfer is not actually done and not all the data will have been written.
Is there a fix to this?
-
heemayl over 9 yearsAFAIK sync is used for flushing buffers to the block devices that are formatted using ext but USBs are formatted using vfat or similar FS. So will sync work while writing to USB?
-
Mark Williams over 9 yearsWorks for me! You can see the lights go, on sticks that have one.. You may be right & it's just doing the stick once the HDD is synced?
-
Darkmoor over 6 yearsAfter
sudo sync
(took a while) a pop up window informed me that now I can safely remove usb. Thanks. -
DannyFeliz about 4 yearsIn fact, this should be the right answer.