Solved

Do I Really Need to “Eject” USB Drives?

Posted on 2016-12-01
10
20 Views
Last Modified: 2016-12-02
when i unplug my usb drives from mac, mac alerts me that it will damage the devices
0
Comment
Question by:Yicai Weng
  • 3
  • 3
  • 2
  • +2
10 Comments
 
LVL 82

Accepted Solution

by:
Dave Baldwin earned 500 total points
Comment Utility
'eject' flushes any cached data and directory entries to the drive.  May not be needed if you are only reading from the drive but it is a good idea if you have written anything to it.
3
 
LVL 87

Expert Comment

by:rindi
Comment Utility
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.
0
 
LVL 90

Expert Comment

by:John Hurst
Comment Utility
As noted, always Eject first. With Windows 10, the first eject may say "busy". Wait 10 seconds and eject again. That normally works.
0
 
LVL 27

Expert Comment

by:serialband
Comment Utility
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
1
 
LVL 90

Expert Comment

by:John Hurst
Comment Utility
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
0
Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

 
LVL 37

Expert Comment

by:Bing CISM / CISSP
Comment Utility
> 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"?
0
 
LVL 27

Expert Comment

by:serialband
Comment Utility
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.
1
 
LVL 37

Expert Comment

by:Bing CISM / CISSP
Comment Utility
> 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.
0
 
LVL 27

Expert Comment

by:serialband
Comment Utility
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.
1
 
LVL 37

Expert Comment

by:Bing CISM / CISSP
Comment Utility
> Macs are not really corporate environment (Windows infrastructure) ready.

+1

Macs are today's "personal"  computers.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Finder.   The ubiquitous, built-in feature of the Mac OS X platform, that never sleeps, can help get to any destination within your Mac OS X volume, allows you to customize your desktop, files and folders and so much more. As one of the primary…
Deploystudio is a system which can be used to deploy OSX clients and servers within the small/medium or large business environments. The system is built ontop of the OSX Server NetBoot system and uses images & workflows as its core assets. Although …
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now