Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 125
  • Last Modified:

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
0
Yicai Weng
Asked:
Yicai Weng
  • 3
  • 3
  • 2
  • +2
1 Solution
 
Dave BaldwinFixer of ProblemsCommented:
'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
 
rindiCommented:
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
 
John HurstBusiness Consultant (Owner)Commented:
As noted, always Eject first. With Windows 10, the first eject may say "busy". Wait 10 seconds and eject again. That normally works.
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
serialbandCommented:
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
 
John HurstBusiness Consultant (Owner)Commented:
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
 
bbaoIT ConsultantCommented:
> 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
 
serialbandCommented:
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
 
bbaoIT ConsultantCommented:
> 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
 
serialbandCommented:
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
 
bbaoIT ConsultantCommented:
> Macs are not really corporate environment (Windows infrastructure) ready.

+1

Macs are today's "personal"  computers.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 3
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now