safely remove USB hard drive

Patrick O'Callaghan pocallaghan at gmail.com
Thu Apr 24 14:51:51 UTC 2008


On Thu, 2008-04-24 at 21:08 +0930, Tim wrote:
> Tim:
> >> It's been my experience that it will not unmount until it's finished
> >> being used.  You'll be told so, and it will remain mounted.
> 
> g:
> > this has been my experience up to one time that after clicking
> > 'unmount' _and_ drive led went out, i removed disk. yet, when i went
> > back to add to disk, i did note that file i had copied to disk was not
> > there. so, to remain on safe side, i went back to old habit of 'sync'
> > 3 time to ensure data buffers are flushed. 
> 
> A LED going out doesn't mean it's dismounted, that just means the LED
> went out.  Many drive LEDs just show current access activity, without
> providing information about anything else (such as mount status).  You'd
> have to check that it is actually dismounted (desktop access icons
> disappearing, the drive not listed in the directory tree, etc.).
> 
> I can't see syncing after a dismount being able to do anything.  Surely
> it could only work on mounted filesystems?  Syncing before dismounting
> would have to vainly hope that no further file system writes happen
> before you dismount.

You've stopped using the filesystem, you sync to make sure everything's
hunky dory, then you unmount. If you can't be sure that activity has
stopped (i.e. there are no open files or current directories on the fs)
you have to hope that unmount will fail and let you know, but there is a
potential race condition if you're not careful. The only way to avoid
the race would be if 'unmount' included a 'sync' within the kernel, but
the docs don't say that. I imagine the reason it's that way is that
unmount can take an indeterminate amount of time, especially for
remotely mounted filesystems. Just speculating of course.

poc




More information about the users mailing list