Drive Shredder is a robust, security-focused desktop application built with Qt 6 and C++. It is designed to permanently erase data from external storage devices (USB drives, SD cards, external HDDs) using industry-standard sanitization algorithms, rendering the data unrecoverable.
- 🚀 Auto-Elevation: Automatically detects if the application is running without root privileges and relaunches itself with
pkexecto ensure it has the necessary permissions to write directly to block devices. - 🔍 Real-Time Drive Detection: Automatically detects connected drives and updates the list in real-time. Smart filtering hides system partitions (like
/,/boot,/home) to prevent accidental damage to your operating system. - 🧹 Multiple Shredding Algorithms:
- Zero (1 Pass): Fast, fills the drive with zeros.
- DoD 5220.22-M (3 Passes): US Department of Defense standard (Zeros, Ones, Random).
- Gutmann (35 Passes): Maximum security, overwrites data 35 times with specific patterns.
- Secure Erase (ATA/NVMe): Uses the drive's built-in firmware commands to erase all data. Ideal for SSDs and NVMe drives as it resets all blocks.
- Cryptographic Erasure: Instantly destroys the media encryption key, rendering data unreadable. Fastest method for self-encrypting drives (SEDs).
- ⏱️ Precision Tracking:
- Real-time Progress Bar.
- Elapsed Time counter.
- Estimated Time Remaining (ETA) calculation based on current write speed.
- 🛠️ Integrated Formatting: Seamlessly formats the drive after shredding (supports
ext4,ntfs,fat32,exfat) so it's ready to use again immediately.
- Startup: App checks for root permissions. If missing, it requests password via PolicyKit (
pkexec) to restart as root. - Detection: Scans for removable media, filtering out system drives.
- Selection: User selects a target drive and a shredding method.
- Preparation:
- Safety Check: Confirms user intent with a warning dialog.
- Unmount: Automatically unmounts the drive to ensure exclusive access and prevent OS interference.
- Shredding:
- Runs in a background thread to keep the UI responsive.
- Writes patterns directly to the raw device file (e.g.,
/dev/sdb) OR issues Secure Erase commands. - Updates UI with progress and time estimates.
- Completion & Recovery:
- Notifies user upon success.
- Offers to Format the now-empty (raw) drive.
- If formatted, the drive is remounted and ready for use.
This project solves several complex system-level challenges:
Writing to raw block devices requires root access. Instead of asking the user to run sudo ./app, the application handles this natively:
- It checks
getuid()at startup. - If not root, it spawns a new instance of itself using
pkexec, passing necessary environment variables (DISPLAY,XAUTHORITY) to preserve the GUI session.
- The Problem: You cannot write to or format a mounted drive safely. The OS will fight you.
- The Solution: We implemented an automated
unmountDrive()helper. Before any destructive operation, the app issues aumountcommand. - UI Challenge: Unmounting a drive usually makes it disappear from
QStorageInfo. We handle this by pausing UI updates during the operation and caching the device path (m_currentDrivePath), ensuring the app doesn't "lose" the drive it's working on.
- Shredding a large drive takes time. Running this on the main thread would freeze the GUI.
- We use
QtConcurrent::runto offload the heavy I/O operations (shredding and formatting) to a background thread. - Signals and Slots (
progressUpdated,timerUpdated) are used to safely communicate back to the main UI thread.
- The app doesn't write to files; it writes to the physical device (e.g.,
/dev/sdb). - It handles low-level details like buffer sizes (4KB chunks) and flushing to ensure data is physically written to the disk platter/flash cells.
- For Secure Erase, it interfaces with system tools (
nvme-cli,hdparm) to trigger the drive's internal erasure routines.
- OS: Linux (requires
pkexec,lsblk,umount,mkfs.*,nvme-cli,hdparm) - Framework: Qt 6.x
- Build System: CMake or qmake
This software permanently destroys data. Once shredded, data cannot be recovered by any means. Use with caution.