Defragger gives Linux a real graphical disk defragmenter

Defragger gives Linux a real graphical disk defragmenter

Defragger is a new open source graphical tool for Linux that brings back a piece of interface most people associate with old versions of Windows: a live block map showing how files, free space and filesystem metadata are laid out on disk, plus a button to reorganize it. According to the project's README, the developer behind it moved to Linux more than 20 years ago and kept missing that graphical defragmenter, not because modern Linux filesystems need weekly defragmentation the way older Windows systems did, but because the old block map was an interface that made the machine legible: you could actually watch the filesystem reorganize itself.

The idea turned from nostalgia into a working tool when its developer needed a reproducible storage layout while testing a high-throughput logger. Fragmentation and extent allocation were adding measurable timing variance to the tests, even on NVMe solid-state storage, where fragmentation is usually assumed not to matter.

Defragger analyzes fragmentation and displays an adaptive filesystem block map, finds fragmented files, and defragments supported filesystems on its own rather than by shelling out to existing utilities. For ext4, it reads allocation maps through the kernel's FS_IOC_GETFSMAP interface, maps individual files through FS_IOC_FIEMAP, and moves extents itself using the EXT4_IOC_MOVE_EXT interface, instead of wrapping tools such as e4defrag or filefrag. It also defragments and compacts offline FAT16 and FAT32 volumes, packing data toward the start of the filesystem; classic FAT writing only works while a volume is unmounted, and Defragger validates both copies of the file allocation table and the file chains, reads copied data back, and updates the mirrored allocation tables conservatively before it touches directory metadata.

The privilege model is a deliberate safety choice: the graphical application and its CLI never run as root. Privileged operations go through a narrow, PolicyKit-authorized helper that communicates over D-Bus and accepts only validated, opaque operation IDs, not arbitrary paths or commands.

The project describes itself as alpha filesystem software and tells users to back up important data before running it. The ext4 path has received the most testing; FAT write support is newer, and the README recommends trying it first on disposable or fully backed-up volumes. For a safer first look, Defragger ships a demo that unpacks a deliberately fragmented ext4 test image into a temporary loop device and opens the application against that copy; closing Defragger deletes the temporary image and never touches a real volume.

Building Defragger from source needs Rust 1.85 or newer, CMake 3.24 or newer, Qt 6 (Base and Declarative), KDE Kirigami, a Qt Quick Controls desktop style, PolicyKit, and a C++ toolchain. It runs on Linux with Qt 6 and Kirigami, and while KDE Plasma is its primary desktop target, the project says it is not specific to Arch Linux. A development build can run directly with cargo, using a transient systemd helper that prompts for PolicyKit authorization, or without that privileged helper at all on systems lacking systemd or PolicyKit. A separate CLI exposes list, analyze, defrag and compact commands against device paths, mount points or loop images. The project is dual-licensed under the MIT License or the Apache License 2.0, and its copyright is credited to Guillaume Binet.

Posted to Hacker News as a Show HN, the project had drawn 37 points and 31 comments at last check.

Key facts

  • Defragger reads ext4 allocation data through the kernel's FS_IOC_GETFSMAP and FS_IOC_FIEMAP interfaces and moves extents with EXT4_IOC_MOVE_EXT, rather than wrapping e4defrag or filefrag.
  • It also defragments and compacts offline FAT16 and FAT32 volumes by packing data toward the start of the filesystem, but classic FAT writing only works while the volume is unmounted.
  • The graphical app and CLI never run as root; a narrow PolicyKit-authorized helper carries out privileged operations over D-Bus using validated, opaque operation IDs rather than arbitrary paths or commands.
  • The project calls itself alpha filesystem software: the ext4 path has the most testing, and the README recommends trying FAT write support only on disposable or fully backed-up volumes first.
  • It builds with Rust 1.85 or newer, CMake 3.24 or newer, and Qt 6 with KDE Kirigami, and ships a demo that runs against a disposable loop-device copy of a fragmented ext4 fixture rather than a real disk.

Why it matters

Modern Linux filesystems do not need a weekly defragmentation ritual the way older Windows systems did, and the project's own README says as much. Its appeal is different: the old graphical block map was, in the README's words, an interface that made the machine legible, letting a user watch the filesystem reorganize itself as it worked. The project turned from nostalgia into a working tool once its developer needed a reproducible storage layout for testing a high-throughput logger; fragmentation and extent allocation were introducing measurable timing variance even on NVMe solid-state storage, where fragmentation is usually assumed not to matter.

Who it affects

The tool targets Linux desktop users, especially on KDE Plasma, though the project says it is not specific to Arch Linux. It is most relevant to ext4 users, since that filesystem's defragmentation path has received the most testing; people who still keep FAT16 or FAT32 volumes around get compaction and defragmentation too, but only while those volumes are unmounted. Developers who need a controlled, reproducible disk layout for benchmarking, the original use case behind the project, are a secondary but explicit audience.

How to use it

Defragger is open source and dual-licensed under the MIT License or the Apache License 2.0. Building it from source needs Rust 1.85 or newer, CMake 3.24 or newer, Qt 6 (Base and Declarative), KDE Kirigami, a Qt Quick Controls desktop style, PolicyKit, and a C++ toolchain. A development build can run directly with cargo, which uses a transient systemd helper and prompts for authorization through PolicyKit, or without that privileged helper on systems that lack systemd or PolicyKit. A separate CLI exposes list, analyze, defrag and compact commands against device paths, mount points or loop images. Installing system-wide follows the standard CMake configure, build and install sequence, which also registers the root-owned D-Bus helper, a systemd service, and the PolicyKit actions. For a safe first look, a bundled demo unpacks a deliberately fragmented ext4 test image into a temporary loop device and opens Defragger against it; closing the app deletes that temporary image and never touches a real volume.

How solid is it

The project describes itself as alpha filesystem software. Its ext4 defragmentation path has received the most testing, while FAT write support is newer and the README recommends starting on disposable or fully backed-up volumes. For FAT, Defragger validates both copies of the file allocation table and the file chains, reads copied data back before it redirects directory metadata, and updates the mirrored allocation tables conservatively, an approach aimed at avoiding a half-written volume if something goes wrong partway through. The privilege model is also a safety choice: the GUI and CLI run unprivileged, and the only code with elevated rights is a narrow, PolicyKit-authorized D-Bus helper that accepts validated, opaque operation IDs rather than arbitrary paths or commands, limiting what a bug or a malicious caller could do with it. The project points to separate architecture notes for the full privilege boundary and validation rules. On Hacker News, the Show HN post had drawn 37 points and 31 comments at last check.

Risks and caveats

The README's own warning is blunt: this is alpha filesystem software, and it tells users to back up important data before running it. FAT write support in particular is newer than the ext4 path and should first be tried on disposable or fully backed-up volumes, not on anything that matters. Classic FAT writing works offline only, so Defragger cannot safely rewrite a FAT volume while it is mounted. The source gives no benchmark numbers for how much defragmentation actually improves performance, no version number or release date for Defragger itself, and names no supported filesystems beyond ext4 and FAT16/FAT32.

“This is alpha filesystem software.”

— Defragger's README