Can Mole Analyze External Drives? Complete Guide to Scanning /Volumes
Yes, Mole can analyze external drives by passing the mount point (such as /Volumes/MyUSB) as an argument to the mo analyze command, though it deliberately skips them in default overview mode to maintain startup speed.
Mole is a fast, terminal-based disk usage analyzer from the tw93/Mole repository that provides interactive TUI or JSON output for inspecting storage consumption. While the application defaults to an overview mode that focuses on internal system locations for rapid initialization, its scanning engine is fully capable of recursively analyzing any mounted filesystem, including external USB drives, network volumes, or SD cards attached to your system.
How to Scan External Drives with Mole
To inspect external storage, you must explicitly provide the target path as a command-line argument. Mole treats external volumes exactly like standard directories once specified.
Scan All Attached External Drives
Run the mo analyze command with /Volumes as the target to scan every currently mounted external drive on macOS:
mo analyze /Volumes
This initiates a recursive scan of the entire /Volumes directory, presenting an interactive tree view of all connected external storage devices.
Target a Specific Drive
For focused analysis of a single external drive, pass the specific mount point:
mo analyze /Volumes/MyUSB
Replace MyUSB with the actual name of your mounted volume. Mole resolves this to an absolute path via filepath.Abs() and begins scanning immediately.
Export JSON Reports for External Volumes
For automation or integration with external tools, use the --json flag to output structured data instead of the TUI:
mo analyze --json /Volumes/MyBackup > backup-report.json
This command scans /Volumes/MyBackup and redirects the JSON output to a file for further processing or archiving.
Implementation Details in the Source Code
The ability to analyze external drives is implemented in the CLI entry point and scanning engine within the cmd/analyze package.
Entry Point and Path Resolution
In cmd/analyze/main.go, the application determines the scan target through either the MO_ANALYZE_PATH environment variable or the first positional argument. Lines 34-46 handle the logic: if a target is provided, the code resolves it to an absolute path and sets isOverview to false, triggering a direct scan of that location regardless of whether it is internal or external storage.
// Simplified excerpt from cmd/analyze/main.go
func main() {
flag.Parse()
target := os.Getenv("MO_ANALYZE_PATH")
if target == "" && len(flag.Args()) > 0 {
target = flag.Args()[0] // ← user-supplied path, e.g. "/Volumes"
}
var abs string
var isOverview bool
if target == "" {
isOverview = true // default overview (skips /Volumes)
abs = "/"
} else {
var err error
abs, err = filepath.Abs(target) // resolve to absolute path
if err != nil {
fmt.Fprintf(os.Stderr, "cannot resolve %q: %v\n", target, err)
os.Exit(1)
}
isOverview = false
}
if *jsonMode {
runJSONMode(abs, isOverview)
} else {
runTUIMode(abs, isOverview)
}
}
Overview Mode vs. Targeted Scanning
When no path argument is provided, Mole initializes overview mode (lines 45-48), which limits the scan to predefined top-level locations such as Home, Applications, and System Library. This mode intentionally omits /Volumes to ensure the application starts instantly without waiting for potentially slow external drive spin-up or network volume latency.
However, when you supply a specific path—whether /Volumes, /Volumes/ExternalSSD, or any other mount point—Mole bypasses the overview restrictions and treats the target as a standard directory tree.
The Scanning Engine
The actual filesystem traversal occurs in scanPathConcurrent and related helpers within the same package (lines 71-79 referenced in the view implementation). This engine walks the directory structure recursively using standard filesystem APIs, meaning it has no distinction between internal storage and externally mounted volumes. As implemented in tw93/Mole, the scanner reads directory entries, calculates sizes, and caches results uniformly for any valid path the operating system presents.
Summary
- Mole supports external drive analysis via explicit path arguments to
mo analyze. - Default overview mode skips
/Volumesto optimize startup performance. - Specify
/Volumesto scan all external drives, or use/Volumes/DriveNamefor specific targets. - JSON export is available via
--jsonflag for programmatic workflows. - Source implementation in
cmd/analyze/main.gohandles path resolution, whilescanPathConcurrentperforms the actual recursive scan.
Frequently Asked Questions
Does Mole automatically detect and scan external drives?
No. According to the source code in cmd/analyze/main.go, Mole’s default overview mode intentionally excludes /Volumes to ensure fast initialization. You must explicitly provide the external drive path as a command-line argument or via the MO_ANALYZE_PATH environment variable to trigger a scan.
What path should I use to analyze external drives on macOS?
Use /Volumes as the target path to scan all mounted external drives, or /Volumes/YourDriveName to analyze a specific device. The README.md explicitly documents this workflow, noting that these paths resolve to standard mount points where macOS attaches external storage.
Can I analyze multiple external drives simultaneously?
Yes. Running mo analyze /Volumes scans every subdirectory within /Volumes, effectively analyzing all currently attached external drives in a single operation. The TUI will display the combined directory tree, or you can export JSON for aggregated analysis.
Is there a performance difference when scanning external versus internal drives?
The scanning logic itself (scanPathConcurrent) treats all paths identically. However, the default overview mode skips external locations specifically to avoid the latency associated with spinning up external HDDs or connecting to network volumes. Once you explicitly target an external drive, the scan proceeds at the speed of the underlying connection protocol (USB, Thunderbolt, etc.).
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →