[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Problem unplugging a USB drive



On Mon 26 Oct 2020 at 17:09:17 (+0000), Mick Ab wrote:
> > > > > […] the messages revealed that just before
> > > > > the stick was unplugged, the kernel suddenly found the stick and
> > > > > automatically mounted it to /media/usb0.

> Why did the kernel automatically mount the stick ?

>From the mount point chosen, I would guess that it was mounted by
some kind of automounter. (My guess is based on conversations here:
I don't run either DE or an automounter.)

> > > > > While the stick was being
> > > > > unplugged, the system performed a 'lazy' unmount from /media/usb0.

That seems logical for a automounter. When you pull the stick,
it prevents umount from failing because the device was busy.
Assuming you weren't writing to the stick at the time, the
amount of corruption that would occur is likely to be influenced
by the filesystem on it. In my experience with vfat, it's likely
to be as little setting the dirty bit.

> > > > > 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.

I didn't know that dmesg was that precise in diagnosis. I frequently see
"Volume was not properly unmounted. Some data may be corrupt. Please run fsck."
AIUI that's just the dirty bit speaking.

I've seen worse, for example:

[47557.370417] FAT-fs (sdb1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.
[47689.952378] FAT-fs (sdb1): error, fat_get_cluster: invalid start cluster (i_pos 0, start cdc8429e)
[47689.952384] FAT-fs (sdb1): Filesystem has been set read-only
[47689.952491] FAT-fs (sdb1): error, fat_get_cluster: invalid start cluster (i_pos 0, start 2c494d0f)

In this case, the stick was on its way out.

The flakiness of your usb ports might have some influence on disk
corruption in any case. Do you have   errors=remount-ro   is the
appropriate place(s)? (fstab, in my configuration.)

> Usually mounts have to be made manually for this port.

Even if I knew how your machine was configured, I'm not sure I would
know the answer. When I see people using an automounter, but mounting
on a mount point of their choosing, I've always presumed that they're
using a bind mount (assuming that they haven't configured rules for
their automounter).

I generate only mountpoints automatically with my own rules, but
I mount and unmount devices manually.

Cheers,
David.


Reply to: