LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (https://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   USB port causes data corruption (https://www.linuxquestions.org/questions/linux-hardware-18/usb-port-causes-data-corruption-4175684249/)

debianlearner 10-26-2020 09:43 AM

USB port causes data corruption
 
A USB memory stick has been plugged into a USB 3 port for quite a few days. The stick was left there after it was discovered that the kernel does not recognise it (e.g. fdisk - l does not show the stick).

It was decided to unplug the stick. Subsequently the command
cat* /var/log/messages was run and the messages revealed that just before the stick was unplugged, the kernel suddenly found the stick and automatically mounted it to /media/usb0. While the stick was being unplugged, the system performed a 'lazy' unmount from /media/usb0.

The stick was later plugged back into the USB 3 port and the dmesg command issued. The dmesg messages revealed that the stick was probably corrupted due to the lazy unmount.

My question is :-

Why did the kernel suddenly find the stick and automatically mount it just before the stick was unplugged ?

RandomTroll 10-26-2020 08:10 PM

If it wasn't properly plugged in, perhaps because there's a bit of corrosion on the surfaces, moving it just that little bit when taking it out made the connection work, triggered an interrupt that caused the kernel to mount it. If you turn off auto-mounting this won't happen. The kernel flushes buffers to disks regularly. If a device hasn't been written-to for a few minutes unplugging without unmounting shouldn't lose data, though it may trigger a warning. fsck it.


All times are GMT -5. The time now is 07:46 AM.