Skip to content

External Disk Permissions and Disk Usage

First PublishedByAtif Alam

A practical runbook for ownership and access problems on macOS external volumes and for interactive disk usage with dua and related CLI tools (Homebrew, Apple Silicon). Replace /Volumes/YourDrive and example UIDs (44222) with your volume path and orphaned IDs.

Terminal window
# Interactive disk usage analyzer
brew install dua-cli
# eza (icons + tree listing)
brew install eza
# Alternative TUI disk analyzer
brew install ncdu

Before changing ownership, inspect the current state:

Terminal window
# List top-level files and owners
sudo /bin/ls -lhA /Volumes/YourDrive
# Filesystem type and ownership status
diskutil info /Volumes/YourDrive | grep -E "Type|File System|Owners"
# How the volume is mounted
mount | grep YourDrive
# Orphaned UIDs often show as numbers, not names
sudo /bin/ls -lhA /Volumes/YourDrive | awk '{print $3}' | sort | uniq -c | sort -rn

Common owner states:

Owner shownMeaning
yournameOwned by your current login
rootSystem metadata — usually leave as-is
44222Example orphaned UID — from a deleted or migrated account
_unknownmacOS cannot resolve the UID
Previous Mac usernameMigration or copy from another machine

If tools report Operation not permitted (os error 1) even when using sudo, macOS is enforcing TCC, not Unix permissions. sudo does not bypass TCC.

Grant Full Disk Access to your terminal app when bulk reads (find, indexing tools) hit protected locations — otherwise commands fail regardless of UID 0.

Steps:

  1. Open System Settings → Privacy & Security → Full Disk Access
  2. Use + and add your terminal (iTerm2, Terminal.app, Warp, and so on)
  3. Add /usr/bin/sudo if your workflow relies on escalation helpers TCC associates with it
  4. Turn the entries On
  5. Quit fully and reopen the terminal session

Test:

Terminal window
/bin/ls /Volumes/YourDrive

External volumes often enforce POSIX ownership. That can block access until metadata is repaired or ownership behavior is relaxed for that volume:

Terminal window
diskutil info /Volumes/YourDrive | grep "Owners"
sudo diskutil disableOwnership /Volumes/YourDrive
diskutil info /Volumes/YourDrive | grep "Owners"
# Owners: Disabled

Disabling ownership is a normal choice for removable or backup disks you administer yourself.

Do not run disableOwnership on your Macintosh HD / system volume. Use this only on external volumes you intend to manage as bulk data stores.

Terminal window
# Files owned by a known old UID (example: 44222)
sudo find /Volumes/YourDrive -user 44222 2>/dev/null | wc -l
# Paths with no valid user mapping
sudo find /Volumes/YourDrive -nouser 2>/dev/null | wc -l

Fix Ownership — Targeted Approach (Fastest)

Section titled “Fix Ownership — Targeted Approach (Fastest)”

Prefer this when ls -lhA shows a small set of top-level folders carrying bad ownership:

#!/usr/bin/env bash
set -euo pipefail
VOLUME="/Volumes/YourDrive"
ME="$(whoami)"
DIRS=(
"data-from-old-mac"
"Dropbox_archive"
"Documents"
"Projects"
)
echo "Fixing ownership as: $ME"
for dir in "${DIRS[@]}"; do
full_path="$VOLUME/$dir"
if [ -d "$full_path" ]; then
echo "Processing: $dir"
sudo chown -R "$ME" "$full_path" 2>/dev/null &
else
echo "Skipping (not found): $dir"
fi
done
wait
echo "Done!"

Save and run:

Terminal window
chmod +x ~/fix_ownership.sh
~/fix_ownership.sh

Fix Ownership — Bulk Approach (Slower but Thorough)

Section titled “Fix Ownership — Bulk Approach (Slower but Thorough)”
Terminal window
sudo find /Volumes/YourDrive -user 44222 -print0 | \
xargs -0 -P 8 -n 500 sudo chown "$(whoami)" 2>/dev/null
sudo find /Volumes/YourDrive -nouser -print0 | \
xargs -0 -P 8 -n 500 sudo chown "$(whoami)" 2>/dev/null

Parallelism raises I/O load; reduce -P on slow disks.

Terminal window
sudo chown "$(whoami)" /Volumes/YourDrive/SomeFile.zip
sudo chown -R "$(whoami)" "/Volumes/YourDrive/Some Folder"
sudo chown "$(whoami)" \
"/Volumes/YourDrive/file1.zip" \
"/Volumes/YourDrive/Folder Name" \
"/Volumes/YourDrive/another-file"

Unlock macOS-Locked Files (If chown Still Fails)

Section titled “Unlock macOS-Locked Files (If chown Still Fails)”
Terminal window
sudo chflags -R nouchg /Volumes/YourDrive 2>/dev/null
sudo chown -R "$(whoami)" /Volumes/YourDrive 2>/dev/null
Terminal window
sudo find /Volumes/YourDrive -user 44222 2>/dev/null | wc -l
sudo find /Volumes/YourDrive -nouser 2>/dev/null | wc -l
/bin/ls -lhA /Volumes/YourDrive | awk '{print $3, $4, $NF}' | column -t
/bin/ls -lhA /Volumes/YourDrive/SomeFolder | grep "44222\|_unknown"

Expected clean state:

Path typeExpected owner
Your data dirs/filesYour login
.Spotlight-V100root
.fseventsdroot
.Trashesroot
.DocumentRevisions*Often root
Backups.backupdbroot (Time Machine layout)

A fuller dua walkthrough (install, aggregate mode, troubleshooting) lives in dua (disk usage). The following stays oriented to external volumes once access works.

Terminal window
dua i /Volumes/YourDrive
dua i ~
KeyAction
/ Move selection
EnterOpen directory
dMark for deletion
uUndo mark
qQuit
?Help
Terminal window
dua i /Volumes/YourDrive \
--ignore-dirs /Volumes/YourDrive/.DocumentRevisions-V100 \
--ignore-dirs /Volumes/YourDrive/.Spotlight-V100 \
--ignore-dirs /Volumes/YourDrive/.fseventsd

Adjust paths if your volume uses slightly different Spotlight or revisions folder names.

Terminal window
dua /Volumes/YourDrive

eza lists trees with flair; combine with dua when you care about recursive directory totals:

Terminal window
eza --tree --long -h --level=2 /Volumes/YourDrive
eza --tree --long -h --level=2 --icons /Volumes/YourDrive
Terminal window
alias ls='eza --icons --group-directories-first'
alias ll='eza -lhA --icons --group-directories-first'
alias lt='eza --tree --icons --level=2'
alias lta='eza --tree --icons --long -h --level=3'

Individual file sizes in eza are not rolled-up folder sizes — use dua when choosing what to delete or archive.

Terminal window
du -sh /Volumes/YourDrive/* 2>/dev/null | sort -rh

Operation not permitted (os error 1) Even With sudo

Section titled “Operation not permitted (os error 1) Even With sudo”

TCC restriction. Configure Full Disk Access as in Fix TCC / Full Disk Access above.

chown: /Volumes/YourDrive: Operation not permitted at the Volume Root

Section titled “chown: /Volumes/YourDrive: Operation not permitted at the Volume Root”

Harmless: macOS guards the synthetic mount-point; chown targets inside the volume still work.

Use Fix Ownership — Targeted Approach (Fastest) for known folder names instead of scanning the entire tree repeatedly.

colorls or Ruby Gems Break Your Shell Prompt

Section titled “colorls or Ruby Gems Break Your Shell Prompt”

Prefer eza (Homebrew-maintained C/Rust toolchain, no Rubygems requirement):

Terminal window
brew install eza

dua Errors on .Spotlight or .DocumentRevisions

Section titled “dua Errors on .Spotlight or .DocumentRevisions”

Add matching --ignore-dirs paths; those trees are indexed or versioned outside normal cleanup workflows.

If ownership semantics are relaxed but Finder or ls still looks odd, re-run a -nouser sweep:

Terminal window
sudo find /Volumes/YourDrive -nouser -print0 | xargs -0 -P 4 sudo chown "$(whoami)" 2>/dev/null

Generated for macOS with Homebrew; workflows were validated on Apple Silicon Macs running recent macOS versions.