Show HN: I missed the moving blocks, so I built a real Linux disk defragmenter
Summary
A graphical disk defragmenter for Linux, built in Rust, that displays filesystem block maps and defragments ext4 and FAT volumes without requiring root access, inspired by Windows defrag tools.
View Cached Full Text
Cached at: 08/30/26, 03:40 AM
gbin/defragger
Source: https://github.com/gbin/defragger
Defragger
A real graphical defragmenter for Linux. Occasionally useful but weirdly satisfying.

After moving to Linux, 20+ years ago … I discovered that the Windows utility I missed most was the graphical disk defragmenter.
Not because modern Linux filesystems need a weekly defrag ritual. The old block map was one of those accidental interfaces that made the machine legible: you could actually watch the filesystem reorganize itself.
Then recently I needed a reproducible storage layout while testing a high-throughput logger. Fragmentation and extent allocation were adding measurable variance, even on NVMe, so the nostalgia project became a real filesystem tool.
Defragger shows how files, free space, and filesystem metadata are allocated,
finds fragmented files, and can reorganize supported filesystems without
shelling out to e4defrag or filefrag.
This is alpha filesystem software. Back up important data. The ext4 path has received the most testing. FAT write support is newer and should first be used with disposable or fully backed-up volumes.
Try it safely
just demo
This decompresses the repository’s deliberately fragmented ext4 fixture, attaches the copy as a temporary loop device, and opens Defragger. Select the loop device printed in the terminal. Closing Defragger detaches and deletes the temporary image; the demo does not write to your real volumes.
The demo needs just, zstd, loop-device support, and sudo for attaching the
temporary image. The application itself remains unprivileged.
How it works
Defragger is not a wrapper around existing command-line tools.
For ext4, it obtains filesystem allocation maps through FS_IOC_GETFSMAP, maps
individual files through FS_IOC_FIEMAP, and moves extents using the kernel’s
EXT4_IOC_MOVE_EXT interface.
The graphical application and CLI never run as root. Privileged operations are performed by a narrow PolicyKit-authorized helper over D-Bus. The helper accepts validated, opaque operation IDs rather than arbitrary paths or commands.
Classic FAT writing is offline only. Defragger validates both FAT copies and file chains, reads copied data back before redirecting directory metadata, and updates mirrored allocation tables conservatively.
See the architecture notes for the complete privilege boundary, validation rules, and update ordering.
What it does
- Analyzes fragmentation and displays an adaptive filesystem block map.
- Defragments ext4 files and offline FAT16/FAT32 volumes.
- Compacts offline FAT16/FAT32 volumes by moving data toward the start of the filesystem.
- Uses PolicyKit for operations that need elevated access while keeping the GUI and CLI unprivileged.
- Supports safe cancellation and reports progress and final metrics.
Supported environment
Defragger runs on Linux with Qt 6 and KDE Kirigami. KDE Plasma is the primary desktop target, but the project is not specific to Arch Linux. Privileged mode requires systemd, PolicyKit, and an active graphical PolicyKit agent.
| Filesystem | Analysis | Defragmentation | Compaction |
|---|---|---|---|
| ext4 | Online | Online | — |
| FAT16/FAT32 | Online | Offline | Offline |
| FAT12 | Online | — | — |
| exFAT | Online | — | — |
The build requires Rust 1.85 or newer, CMake 3.24 or newer, Qt 6 Base and Declarative, Kirigami, a Qt Quick Controls desktop style, PolicyKit, and a C++ toolchain. Package names vary by distribution.
Run from source
The default development build uses a transient systemd helper and prompts for authorization through PolicyKit; it does not need to be installed first.
cargo run --release
# or
just run
Run without the privileged helper when systemd or PolicyKit is unavailable:
cargo run --release --no-default-features
The CLI accepts device paths, mount points, device symlinks, and loop-image paths:
cargo run --release -p defragger-cli -- list
cargo run --release -p defragger-cli -- analyze /dev/nvme0n1p2
cargo run --release -p defragger-cli -- defrag /dev/nvme0n1p2 --yes
cargo run --release -p defragger-cli -- compact /dev/sdb1 --yes
System-wide installation
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr
cmake --build build
sudo cmake --install build
sudo systemctl daemon-reload
This installs the application, CLI, root-owned D-Bus helper, systemd service, and PolicyKit actions. See the architecture notes for the privilege boundaries and implementation details.
License
Copyright 2026 Guillaume Binet.
Defragger is dual-licensed under the MIT License or the Apache License 2.0, at your option.
Third-party components and assets remain under their respective licenses. In particular, the application icon is from KDE’s Breeze Icons project; see its attribution and licensing details.
Similar Articles
Show HN: Leaves – a text-UI disk usage treemap visualizer
Leaves is a text-UI disk usage treemap visualizer inspired by WinDirStat and QDirStat, allowing users to analyze disk usage over remote shell connections.
Show HN: I rebuilt the only parts of my IDE I use, in Rust, over a weekend
Kyde is a fast native Git client and code editor built in Rust using Zed's gpui framework, featuring GPU rendering, side-by-side diffs, tree-sitter syntax highlighting, and a hand-tuned dark theme.
Show HN: 18KB ls alternative in no_std rust and Libc
A minimal 18KB ls command alternative written in Rust using no_std and Libc.
@vintcessun: At noon I saw a tool that solves the chaos in download directories, a bit unbelievable—a system tray file organizer written in Rust+Tauri, memory usage only 5MB, and just added Linux support. The core is file monitoring plus a rule engine, automatically classifying by extension or regex, SQLite records operation history for one-click undo. Privacy-wise zero reporting, …
Introduces an open-source desktop file organizing tool Mouzi, built with Rust and Tauri, memory usage only 5MB, supports file monitoring and rule engine for automatic classification, emphasizes zero reporting for privacy.
Defrag98: Windows 98 Disk Defragmenter Simulator Online
Defrag98 is an online simulator of the Windows 98 Disk Defragmenter, allowing users to interact with the classic utility in a web-based format.