Link to home
Start Free TrialLog in
Avatar of Yicai Weng
Yicai Weng

asked on

Do I Really Need to “Eject” USB Drives?

when i unplug my usb drives from mac, mac alerts me that it will damage the devices
ASKER CERTIFIED SOLUTION
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Just pulling out the drive doesn't damage it, but it can corrupt the file-system and files on it. Ejecting prevents that from happening.
As noted, always Eject first. With Windows 10, the first eject may say "busy". Wait 10 seconds and eject again. That normally works.
I've never actually lost anything or corrupted anything when I just yanked the drive.  The main danger of corruption comes from voltage fluctuations on the data lines when power is disconnected, but USB is designed to disconnect the data lines before the power lines.  I have purposely tested it during a write and it just didn't finish writing the file.  The file data was probably partially written, but the actual file table does not get written until the data is complete.  However, it's not something you want to do continuously.  It's always best to just eject the device first to make sure you don't lose data.

Sometimes the system is stuck and can't eject or you don't want to spend time finding which of your open Terminal Windows has a current path set to the USB.  Sometimes it's spotlight.  I suggest you turn off spotlight on external USB storage if you're going to be unplugging the device frequently.

If spotlight is delaying your eject, you can force it to stop by shutting off mdutil on it first and you can then eject it.
mdutil -i off /Volumes/USBDrive

If you want all Macs to stop indexing your USBDrive, then do the following:
cd /Volumes/USBDrive
rm -rf .{,_.}{fseventsd,Spotlight-V*,Trashes}
mkdir .fseventsd
touch .fseventsd/no_log .metadata_never_index .Trashes
I've never actually lost anything or corrupted anything when I just yanked the drive

I have, so I use care. Think twice, yank once and be careful
> The file data was probably partially written, but the actual file table does not get written until the data is complete.

how about ejected just when writing the directory block, volume bitmap and file record after all file data is complete? you got a corrupt file system.

the shorter data lines in USB connector is for preventing physical damage from accidental operations, not for protecting file system.

so never do that, always eject before unplugging.

> If you want all Macs to stop indexing your USBDrive, then do the following

thanks for sharing the hint.

what do you mean by "all Macs"?
what do you mean by "all Macs"?

It should cause any Mac you plug it into to see that file structure and tell it to not Spotlight index the USB storage.  This means you can't do spotlight searches on that external storage.

As for curruption:
I generally don't yank it during critical writing phases.  I've only yank it when the system is stuck and I know there shouldn't be any writes, just some command prompt or previous program has an open path to the system.  I've only ever purposely tested a removal of a large file during a write phase.  If you yank it while it's writing the File Table or Directory Block, then you can mess up the file table and cause corruption.  Just removing it during the data phase will cause it not to save the data.  If you have a file open, but not writing, you will basically lose unsaved data.  If you understand how the process works, you can easily avoid data corruption.  I haven't corrupted any external storage when I've forcibly removed them.  Sometimes you have to forcibly removed them and generally, those are backups of backups.  I don't use them as primary data stores.
> This means you can't do spotlight searches on that external storage.

i love spotlight but i do hate the "shits" the indexing engine leaves on external drives.
Unfortunately, Spotlight causes lots of issues on mounted drives, both USB external and Windows shares.  I have to turn it off for all users on external storage to reduce problems with user access and file and folder locking on windows shares.  It's designed for permanent storage with single user access in mind.  It's a little less troublesome to just teach them to run ls with regular expressions or find in terminal to find things on mounted Windows shares.  Macs are not really corporate environment (Windows infrastructure) ready.
> Macs are not really corporate environment (Windows infrastructure) ready.

+1

Macs are today's "personal"  computers.