Logo

dev-resources.site

for different kinds of informations.

Scan Your Linux Disk and Visualize It on Mac with GrandPerspective

Published at
1/13/2025
Categories
rust
mac
Author
kojix2
Categories
2 categories in total
rust
open
mac
open
Author
6 person written this
kojix2
open
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/

GrandPerspective Screenshot 1
GrandPerspective Screenshot 2

(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.

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:

  1. Download from SourceForge
  2. Purchase from the Mac App Store
  3. Install via Homebrew:
   brew install grandperspective
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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.

rust Article's
30 articles in total
Favicon
Mastering Rust's 'unsafe' Code: Balancing Safety and Performance in Systems Programming
Favicon
Meme Tuesday ๐Ÿšฑ
Favicon
Pulumi WASM/Rust devlog #3
Favicon
Typed integers in Rust for safer Python bytecode compilation
Favicon
### **Exploring Embedded Systems Development with Rust**
Favicon
Scan Your Linux Disk and Visualize It on Mac with GrandPerspective
Favicon
Diesel vs SQLx in Raw and ORM Modes
Favicon
C++ or Rust? I'd stick to my good old C++
Favicon
Rust
Favicon
Building a Developer-Focused Search Engine in Rust: Lessons Learned and Challenges Overcome ๐Ÿš€
Favicon
A Gentle Introduction to WebAssembly in Rust (2025 Edition)
Favicon
Stable Memory In Internet Computer
Favicon
Solana Account Model Simplified
Favicon
Rust Frameworks
Favicon
Mastering Rust's Type System: A Comprehensive Guide for Robust and Efficient Code
Favicon
๐Ÿš€ Intrepid AI 0.10: Ready for Liftoff!
Favicon
Swiftide 0.16 brings AI agents to Rust
Favicon
Introducing Yamaswap
Favicon
Rust and Generative AI: Creating High-Performance Applications
Favicon
Rust: Matchy Matchy
Favicon
Rust registry error "candidate versions found which didn't match"
Favicon
Mastering Rust Lifetimes: Advanced Techniques for Safe and Efficient Code
Favicon
Rust
Favicon
่ฎฉๅฎ‰ๅ“ๆ‰‹ๆœบไธๅ†ๅƒ็ฐ๏ผšๅœจๅฎ‰ๅ“ๆ‰‹ๆœบไธŠๆญๅปบ Rust ๅผ€ๅ‘็Žฏๅขƒ
Favicon
How to test Asynchronous Rust Programs with Tokio [TUTORIAL]
Favicon
SSH port forwarding from within code
Favicon
Reto de Rust 365 dรญas, 2025!!
Favicon
Rust-Powered Password Decrypter: Find the String Behind the Hash! ๐Ÿฆ€๐Ÿ”’
Favicon
๐Ÿš€ Rust Basics 5: Structs and Enums in Rust
Favicon
Rust mega-tutotial

Featured ones: