dev-resources.site
for different kinds of informations.
Scan Your Linux Disk and Visualize It on Mac with GrandPerspective
Introduction
GrandPerspective is a useful disk space visualization tool for Mac. Have you ever wanted to scan files on Linux and visualize their disk usage with GrandPerspective? I created a Rust-based command-line tool called gpscan that scans directories on Linux and generates GrandPerspective-compatible files.
https://github.com/kojix2/gpscan
Visualizing Disk Usage with GrandPerspective's Treemap
GrandPerspective is a disk usage visualization tool for Mac developed by Erwin Bonsma. It can be downloaded for free from SourceForge. (It is also available for purchase on the Mac App Store. If you'd like to support Erwin, feel free to buy it!)
https://grandperspectiv.sourceforge.net/
(Screenshots from the official website)
If you've used GrandPerspective before, you'll agree that this desktop application is visually appealing and operates quickly and smoothly. It's extremely helpful for identifying and organizing files that occupy large amounts of disk space.
The method of visualizing quantities using area on a plane is called a Treemap. GrandPerspective is not the only tool that visualizes disk usage with treemapsโsimilar tools are available for various operating systems.
Mac | Linux | Windows |
---|---|---|
GrandPerspective | QDirStat | WinDirStat |
How to Visualize Linux Disk Usage on Mac
However, visualizing disk usage on a Linux server and analyzing it on your Mac is not straightforward.
You might think using QDirStat on Linux would work, but Linux servers often lack desktop environments or Qt dependencies.
QDirStat comes with Perl scripts for scanning disks, but you still need QDirStat to visualize the results. There is a Mac version of QDirStat, but it doesn't match GrandPerspective in usability.
To solve this, I developed a simple command-line tool called gpscan, which scans directories on Linux and outputs files compatible with GrandPerspective.
Introducing the Command-line Tool gpscan
Overview
gpscan is a Rust-based command-line tool that outputs files compatible with Mac's GrandPerspective. You can download the output file to your local Mac and open it with GrandPerspective. This allows you to visualize storage usage and effectively identify and organize large files.
https://github.com/kojix2/gpscan
Prerequisites โ Installing GrandPerspective
Install GrandPerspective using one of the following methods:
- Download from SourceForge
- Purchase from the Mac App Store
- Install via Homebrew:
brew install grandperspective
Installing gpscan
Method 1: Download the Precompiled Binary
Download the executable from the GitHub Release and copy it to a directory in your system's PATH.
Method 2: Install via Rust's Cargo Package Manager
cargo install gpscan
How to Use gpscan
To scan your entire home directory, run the following commands:
cd ~/ # Navigate to the home directory
gpscan ./ > result.gpscan # Scan the current directory and save the results
The generated file (result.gpscan
) is an XML file compatible with GrandPerspective. Use SFTP, SCP, Cyberduck, or similar tools to transfer it to your Mac.
Open the file (result.gpscan
) with GrandPerspective on your Mac to visualize the directory's disk usage.
You can identify and manage old or unnecessary files by moving or deleting them to free up disk space.
Command-Line Options
-o, --output <FILE> Output file (default: stdout)
-A, --apparent-size Use apparent size instead of disk usage [false]
-m, --mounts Cross filesystem boundaries during scan [false]
-z, --include-zero-files Include zero-byte files in scan [false]
-e, --include-empty-folders Include empty folders in scan [false]
-q, --quiet Suppress all informational messages [false]
-h, --help Print help
-V, --version Print version
Development and License
gpscan is released under the MIT License. While much of the code and commit messages were generated with the assistance of ChatGPT, the development was directed by me as a human, involving repeated revisions and commits. Although AI was utilized, a considerable amount of time and effort was personally invested in the project.
If you discover any bugs, feel free to submit an issue or pull request at https://github.com/kojix2/gpscan.
The original of this post was posted on Qiita and translated into English by ChatGPT. Thank you for reading. Have a good day.
Featured ones: