Balky Flash Drive

Screenshot 2025-02-24 at 6.01.06 PM

OK, here is my dilemma. Ging through some old flash drives… this one had 3 partitions on it. Pretty sure it’s HFS+, was made sometime after High Sierra. Wanted to copy a 6G file of if it, but it said it would take 21 days! Time to erase and reformat. Many, I tried every trick I know of but I kept getting messages like the one above. Or Id get the dreaded “cant because in use by another process.” Or it might use a different “process” in place of the one above. Oh, OS 15.3.1

Is there anything, other than tossing it in the garbage, that I can do?

Run FIRST AID on each of the partitions and then the entire drive. that should allow you to reformat it then.

Tried that but got this for all 3 partitions:
Screenshot 2025-02-27 at 6.21.47 PM

Oh, remembered I had DiskWarrior, so tried it. MAssively slow, but I rebuilt the directories on all 3 partitions. Made no difference.

No idea what other options I have… except to toss the flash drive. Now it seems that I can NOT even eject the damn thing. Oh after a few minutes I get the “in use by another program.” Eventually I got an option to force ject, after a few min sutes fussing with that, it did get ejected. BTW, as I reated it back when I was running HS on my cMP, all 3 partitions are HFS+.

I don’t have an active macOS machine right now to test, but a couple of things worth trying:

  • Reboot into safe mode by holding down the shift key while booting. That will prevent running programs at login which might be locking files on the drives. Antivirus software that tries to scan inserted media can cause these kinds of problems.
  • Boot into Recovery Mode by holding down command-R while booting. Once in Recovery Mode you should be able to launch Disk Utility and work your will on the balky drives.

Not sure if either of these things work on Apple Silicon Macs, which I’ve never used. There is a good chance the drives are failing and these tricks will result in further failures or very slow operations, in which case it’s probably time to bin the drives.

Looking at the error messages, it seems the reason you cannot reformat nor run disk first aid is that the volumes cannot be unmounted. That’s the reason ejecting the disk eventually requires a Force Eject.

I have 2 ideas, first, leave the flash drive mounted overnight, then try to eject it in the morning. That may give the system time to do whatever its doing that has the volumes busy.

If that doesn’t work, force eject the volumes, leave them unmounted, and then reformat the disk using disk utility.

1 Like

The first screenshot posted tells exactly what process is blocking unmounting: it is mds_stores, which is part of Spotlight indexing. Perhaps if you remove the volumes from Spotlight, you will have better luck.

4 Likes

That doesn’t make sense to me. The error refers to “one of the other volumes in the volume’s container”. That means APFS, which Disk Warriror can’t repair.

If these three volumes are all part of a single APFS container (Disk Utility should be able to show you this), then you have to unmount all of them in order to perform a repair. Disk Utility is trying to do this for you, but it can’t, hence the error.

If these volumes are actually HFS+ formatted, then the error message makes no sense to me.

Or the partition table could be messed up such that part of the device think it is HFS+ and part thinks it is APFS. That would explain a lot of the mess as well. If there was an attempt to convert the storage from HFS+ to APFS, and the attempt failed or was stopped halfway-through (e.g. power failure or disconnecting the device), that might do it.

This is what Disk Utility was complaining about - it couldn’t eject the volumes either.

Yes. Once upon a time, I had an HFS+ volume get into this state. It wouldn’t mount, but wouldn’t eject either. As it turns out, there was some corruption that couldn’t be fixed by a quick replay of the journal, so the system was running the fsck utility to perform an in-depth repair prior to mounting.

There was no indication in the GUI that this was taking place (I only noticed it when using Terminal commands like lsof and ps and saw that fsck was running on that volume). But before I learned this, I had power-cycled it a few times, which probably made the problem even worse. When I left it alone for several hours, the fsck process eventually completed and the volume was working fine afterward.

That’s also not a bad idea.

A third option would be to plug the drive into another (non-Mac) computer and use some tool there to wipe the device. Or at least write zeros to the first few blocks of storage.

I’ve done this (using a Linux PC) on occasion. I can then plug it back into the Mac and use Disk Utility to partition and format it. With the start of the disk (including the partition table) wiped, it doesn’t try to mount the corrupt volumes and just sees a completely blank device.

2 Likes

As always, thanks so much for replying David. This flash drive was made during my High Sierra era. Everything I did in those days was macOS Extended Journaled. While DW was massively slow, it did rebuild the partitions, but said there was little need to. The fact it took forever kinda makes me wonder about their supposed “compatibility” with 15.x.

This fsck sounds interesting. Might explain some of the issues I’ve been having. So I just mounted all 3 partitions… quickly as I would normally expect. So I am curious how to know it’s running… oh wait Activity monitor…looking at it now. Hmmm, some very strange (to me) things are in there, but that’s another post, another time. It does not list any fsck activity. There is a fseventsd and fskit_helper running.

Do I just run either of the commands you noted to find out if it is running? Tried both. ps gave me:
[Pauls-Mac-mini:~] paulcons% ps
PID TTY TIME CMD
1415 ttys000 0:00.01 -tcsh

lsof gave me a HUGE listing. I dumped it to text and searched the text but found no instance of fsck. But this was the first time I have run Terminal since my HS days… something very odd is happening… but that should be a separate thread. I’m leaving the reluctant 3 partitions on my desktop for today, lets see what happens by the end of the day.

Knock me on the head… for some unknown reason, after all this I realized the disk activity light on the drive had stopped flashing. I was able to get that 5G file off not in 21 days. I did a small re-partition, it worked so I erased the drive and now all is well.

I do remember that yesterday, all the time the activity light was flashing, today was the first time I see it not on. The right question seems to have been “why is there disk activity going on?”

3 Likes

The lsof command lists all open files. You should look for any files on the problematic volume, because you can’t eject a volume while something has an open file on that volume.

For example, if I go looking for open files on my Time Machine volume, I would run lsof and filter it through the grep command to only show entries containing /Volumes/Time Machine in the path:

$ sudo lsof +c 0 | grep "Volumes/Time Machine"
mds         126  root  26r  DIR  1,15    192         2 /Volumes/Time Machine
mds         126  root  27r  DIR  1,15   3296        19 /Volumes/Time Machine/.Spotlight-V100/Store-V2/3D55DE01-E241-4BC2-AC3A-4728752E5C9C
...
revisiond   157  root  10r  DIR  1,15    192         2 /Volumes/Time Machine
revisiond   157  root  11r  DIR  1,15    288  18441702 /Volumes/Time Machine/.DocumentRevisions-V100
...
mds_stores  342  root  txt  REG  1,15  16384  11887988 /Volumes/Time Machine/.Spotlight-V100/Store-V2/3D55DE01-E241-4BC2-AC3A-4728752E5C9C/live.2.indexCompactDirectory
mds_stores  342  root  txt  REG  1,15     56        52 /Volumes/Time Machine/.Spotlight-V100/Store-V2/3D55DE01-E241-4BC2-AC3A-4728752E5C9C/dbStr-1.map.header
mds_stores  342  root  txt  REG  1,15     56        56 /Volumes/Time Machine/.Spotlight-V100/Store-V2/3D55DE01-E241-4BC2-AC3A-4728752E5C9C/dbStr-2.map.header
...

The +c 0 option tells it to not truncate process names (in the first column of output). Otherwise, they are truncated to 9 characters.

The above ouput is abbreviated, and I’ve removed a lot of horizontal whitespace to make it easier to read here, but the important take-away is that three processes: mds, revisiond and mds_stores have a lot of open files on the Time Machine volume. These are not unusual:

  • mds is the “Metadata Server”, a key component of Spotlight
  • revisiond is for tracking and managing file revisions.
  • mds_stores is Spotlight’s core indexing service.

Note that if your volume is not yet mounted, then software accessing it will be doing so through one of the “device” files, /dev/disk*. In my case, nothing is holding the device open, which should be expected unless a low-level disk utility (e.g. repartition, erase, repair, etc.) is running on the device:

$ sudo lsof +c 0 | grep "/dev/disk"

The ps command lists all processes running. By default, it only shows processes that belong to the user typing the command, which are mapped to a (physical or virtual) terminal device. But you can use the “a” option to show processes belonging to all users and the “x” option to show processes that aren’t mapped to a terminal.

The full set of processes is not typically useful, but you can use it in conjunction with a grep command to look for specific processes. For instance if I want to see information about the logind process (which manages user logins):

$ ps ax | grep logind
  156   ??  Ss     0:04.93 /System/Library/CoreServices/logind
31431 s000  S+     0:00.00 grep logind

Note that the output includes the full command-line of each command, including its parameters. So the grep filter picked up itself, because logind appeared on its command-line.

If you want to look to see if fsck is running:

$ ps ax | grep fsck
31457 s000  S+     0:00.00 grep fsck

In my example, it isn’t running, so the only match is the grep command itself.

Great. This means that whatever was running (and therefore holding open files, preventing unmounting) has finished. Given the original screen-shot, it was almost certainly the mds_stores process, which is Spotlight’s indexing daemon.

As for why it couldn’t be interrupted (and was therefore blocking the unmount), I can only speculate, but it may well be that it was reading and analyzing that 5GB file. It may only be able to pause itself between files, not while processing a single file.

Previously, you force-unmounted the drive before mds_stores finished or got to a checkpoint, which probably caused it to start over.

4 Likes

This is a timely article for me; I want to delete three APFS volumes in a container. (The container is the only item on the SSD, if that matters.) I tell Disk Utility to delete the volumes (sequentially), and Disk Utility tells me that mds_stores is busy with them. In Spotlight settings, I have excluded the volumes from indexing (although that was after mds_stores began work on them).

Interestingly, I just checked again, and one of the volumes is no longer listed in the Privacy pane, and trying to add it again returned an error. And just after typing that sentence, I checked again, and that volume is back in the list. (The other two volumes were present both times.)

Nothing I have done has resulted in the Force Eject dialog box that I have seen in the past. How do I get that choice? (This is on an M3 MacBook Air, running Sequoia 15.1.)

Since I want to delete all the mounted volumes and no unmounted volumes, would it be reasonable simply to unplug the SSD?

Thanks for any help.

Have you tried opening Activity Monitor and quitting mds-stores and any other mds-related processes? They will eventually restart, but you have a small window to start the deletion. Just have Disk Utility already running so that you can quickly start the deletion.

No, and I should have mentioned that. I was worried about quitting processes, and you implied there’s no problem. Even if they restart, does anything bad happen from forcing them to quit?

There’s one other reason I wouldn’t have quit the process even if I knew it wouldn’t hurt anything. It’s a new Mac, and I hadn’t told Activity Monitor to show All Processes. When I looked for mds_stores (both by PID and by name), it wasn’t there. Thanks for prodding me and making me think to tell Activity Monitor to show All Processes.

It’s great to be cautious, so here’s a fuller explanation of how I would approach this fix.

One thing I do before messing with a process is do a web search for ‘mac process-name’ and try to get a basic understanding of the consequences of quitting the process. Since the mds-store process is part of Spotlight indexing, the worst thing that could happen is that the Spotlight index is trashed. So let’s see if that can be easily fixed without causing other problems.

The process I would follow is to
1)Start Disk Utility
2) Quit mds-store from Activity Monitor (force-quit if necessary)
3) Erase the flash drive
4) Rebuild the Spotlight index as described in the support document
5) Reboot (to get a fresh start)

1 Like

Thank you very much. It’s wonderful to be taught how to fish rather than be given a fish.

I took matters into my own hands yesterday, when I was ready to quit for the day. The mds_stores was using 0% CPU time, so I quit it. (Force-quit was not necessary.) I then deleted the APFS partitions and unmounted the SSD. I’ll pick up on your instructions at step 4. Thanks again.

Bonus question. What is the difference between unmount and eject? In Disk Utility, with Show All Devices selected, I usually click the top triangle for the device (and then wait for all the volume indicators to turn gray, which can happen some seconds after the icons disappear from the desktop). I assume I’m unmounting all the volumes and ejecting the device; is that the standard terminology?

In general, unmounting is something you do to an individual volume (aka filesystem), while ejecting is something you do to an entire physical device.

IIRC, if you have a device with multiple volumes, you generally can unmount one volume while leaving the others alone, but if you “eject” one of the volumes, then all of the other volumes should be unmounted, too. Also, if your device has physically ejectable media, like a DVD, the eject command should physically eject the media.

In practice, on devices with a single volume, unmount and eject look the same to a typical user.

I don’t have a machine nearby to confirm this, but I think the story is more complicated with macOS 10.15+ devices that contain linked volumes, like a Sealed System Volume and an associated Data volume. I may be wrong, but I think if you use Disk Utility to unmount one, the other will get unmounted, too.

1 Like

Another big difference is that when you “unmount”, the device doesn’t go away. So you can re-mount it again. But after an eject, the device is removed from the system - you need to power-cycle or hot-plug the device to get it back.

You can see this in Disk Utility. Plug in your favorite flash drive and select its volume. If you click the “unmount” button, you can later click “mount” to get it back. But if you click the “eject” icon (in the left-side column), the device disappears from the list. You will need to remove and reconnect the drive in order to get it back.

1 Like

Is that the triangle with a vertex at the top and a line underneath?

What you describe is not what I see, but I’m using an SSD. Is that the reason for the difference? (I can click the triangle and choose Eject from the File menu for each volume, but the device remains in Disk Utility’s window and I can click the mount icon and get it back on the desktop.)

Yes, but there are two of them, assuming you have Disk Utility configured to show all devices (View → Show All Devices, or type ⌘2):

The icon next to the volume (green box in my screen-shot) does an unmount. The icon next to the device (red box in my screen-shot) does an eject.

If your Disk Utility is configure to only show volumes (the Apple-default configuration), then you will only see volumes, and the icon for them does an unmount, not an eject.

2 Likes

AND I might add, if you have the show volumes as the default, you will not be able to really format it the way you’d want. I was going crazy not seeing what I KNOW it can format as… UNTIL David mentioned elsewhere the bit about using “show all devices.” Once I set it like that, I had all the options I thought I should have available.

Oh, that was about not seeing APFS as an option for a flash drive. Once set to snow devices, boom, had the option for APFS.