2

I have hundreds of gigabytes of files that I manually (tried) to delete from an external hard drive. However I can't empty my trash, and no space has freed up on the drive.

When I try to empty my trash, I get an error saying that I can't, because some of the files are locked, or in use or I don't have permission. The Macos popup tells me I should manually locate and change the permissions of the offending file.

Here's the problem, there are 10s of thousands of files, so that is not realistic.

What hasn't worked: Putting sudo rm -R into my command line and dragging the offensive trash into my terminal.

Selecting trash files in question, clicking "get info" and unlocking them still doesn't let me right click and delete immediately.

Restarting my computer hasn't helped either. When I reconnect the drive, I still have no space freed and the junk files are still living in my trash folder... unable to be removed.

As things are now, I've exhausted all available solutions to reclaim this space on my drive.

My setup: Macbook air, up to date with Big Sur 11.4

3
  • 1
    What format is the external?
    – Tetsujin
    Jun 30 at 18:23
  • Mac OS Extended (Case-sensitive, Journaled) Jun 30 at 18:54
  • I'd put some effort into trying to figure out why the files are so hard to delete. Check the volume's mount attributes with the mount command, and see if it lists anything like "read-only" or "owned by...". Also, check some of the files and directories for weird attributes and permissions with ls -laeO@ /path/to/files. Jul 1 at 1:50
1

Let's assume the name of the drive is /Volumes/External/ for the sake of discussion.

Go into Terminal and type:

sudo find "/Volumes/External/.Trashes/$EUID" -depth -mindepth 1 -print

That should show you all of the files in your Trash on the external drive.

If you want to try deleting them, try this:

sudo find "/Volumes/External/.Trashes/$EUID" -depth -mindepth 1 -print -delete

Note: Be careful. Mistyping this command can do serious damage since you are deleting files using sudo. The -print command by itself is safe. Once you add -delete then you are deleting files.

Use at your own risk.

0

Get Info on the external drive & check the box marked "Ignore ownership on this volume"

Then all you have to deal with are any files in use or locked, which can usually be dealt with by a reboot.

4
  • That's an excellent idea... I haven't tried it in a while but does holding option while deleting still force delete stubborn/locked files? Jun 30 at 18:30
  • I've never tried it - never had anything quite that stubborn ;) I know it bypasses the Trash, but I don't actually know what else it might do to achieve that.
    – Tetsujin
    Jun 30 at 18:39
  • I did not see any option to "Ignore ownership on this volume". Jun 30 at 18:55
  • Perhaps the issue is 'deeper'. Run fsck - should look like this… i.stack.imgur.com/7xwnh.png
    – Tetsujin
    Jun 30 at 19:31
0

I had the same problem today and here is what I did after failing to find any helpful information on the issue. I followed the instructions here on enabling the root user:

https://support.apple.com/en-us/HT204012

I then logged out, and back in as root by selecting "Other" on the login screen and typing in "root" for the user and my new password.

I tried to use the terminal to delete the files, but that failed and just refused to do it. Then I tried to delete them in the Finder, which worked! Annoying. I went back to the terminal and the files seemed to now be visible, so I used rm -r just for good measure and they went away. I don't know if that part was critical or some file system issue.

Note that I had to first use Finder to navigate to my regular user home by turning on the path bar in the View menu, then clicking on my drive, then the Users directory, then my regular user directory. Then, showing that directory in Finder, I used the Go To Folder option on the Go menu and typed in ".Trash" which, unlike the Terminal, showed me all of the files in the trash! I didn't expect Finder to have abilities that the terminal lacked.

I then selected the troublesome files and used Command-Delete to delete them. I actually decided to totally clear the trash since I was making a backup bootable clone and didn't want to copy all of this trash there.

I'm making my clone now and it seems to be OK. The reason I went down this rabbit hole was because I tried to install a music app and it failed and I deleted it, and the "bad" files ended up in the trash.

I'm just a developer and not an OS expert and I don't understand why this is happening. I've been doing searches to find a detailed explanation, but have had no luck so far. The problem never showed itself before upgrading to Big Sur and I've had a number of issues where some low level driver type files, that do not come through the App Store installers, if that matters, are getting wedged into the file system and not always behaving correctly.

For example, I've had both Carbon Copy Cloner and Little Snitch have problems where the solution was to boot into single user mode and track down a locked file or directory and delete it, then reinstall or upgrade the app to get it working. I've got a few other app doing something similar and I'm not sure what's causing it. I think the music app I tried had the same problem. There seems to be some kind of situation where some program components are installed as "locked" but this causes problems in the normal execution of the apps. (See the sparse docs on the uchg file flags, which is all very obscure to me.)

The worse thing is that not everybody has this issue. The support folks at some app companies have told me that it is only a handful of users seeing this. I don't know why, and suspect it related to my 2015 model being upgraded again and again as new OS releases get installed. Plus, I have a lot of developer tools installed and they sometimes install weird things under the hood.

I don't really know why, but this managed to get me going. Read the docs about the root user in full before you try this, they warn against doing this.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .