Disk Repair Utility

A comprehensive bash script for disk health checking, repair, and data recovery with integrated malware scanning.

Disk Repair Process

Script Overview

The Disk Repair Utility is a comprehensive bash script designed to diagnose, repair, and recover data from storage devices. It performs a series of systematic checks and operations to ensure disk health and data integrity.

▗▄▄▖ ▗▄▄▄▖▗▄▄▖ ▗▄▖ ▗▄▄▄▖▗▄▄▖ ▗▄▄▄ ▗▄▄▄▖ ▗▄▄▖▗▖ ▗▖ ▐▌ ▐▌▐▌ ▐▌ ▐▌▐▌ ▐▌ █ ▐▌ ▐▌▐▌ █ █ ▐▌ ▐▌▗▞▘ ▐▛▀▚▖▐▛▀▀▘▐▛▀▘ ▐▛▀▜▌ █ ▐▛▀▚▖▐▌ █ █ ▝▀▚▖▐▛▚▖ ▐▌ ▐▌▐▙▄▄▖▐▌ ▐▌ ▐▌▗▄█▄▖▐▌ ▐▌▐▙▄▄▀▗▄█▄▖▗▄▄▞▘▐▌ ▐▌

Key Features

Bad Sector Detection

Uses badblocks to identify and log problematic sectors on the disk, helping prevent data loss.

Filesystem Integrity Check

Performs comprehensive filesystem checks using fsck and e2fsck to repair inconsistencies.

SMART Diagnostics

Runs long SMART tests to assess disk health and predict potential failures before they occur.

Data Recovery

Uses ddrescue to recover data from failing disks, creating a disk image for safe extraction.

Malware Scanning

Integrates ClamAV and Maldet to scan recovered data for malware, ensuring safe data restoration.

Comprehensive Reporting

Generates detailed reports with ASCII art headers, logging all operations and results for analysis.

Usage Example

# Make the script executable
chmod +x repairdisk

# Run the script on a disk device
sudo ./repairdisk /dev/sdb

# View the generated report
cat /var/log/disk_health_check/disk_health_report.txt

Technical Implementation

The script follows a logical sequence of operations:

  1. Checks if the target disk is mounted and unmounts it if necessary
  2. Runs badblocks to detect and log bad sectors
  3. Performs filesystem checks and repairs with fsck and e2fsck
  4. Executes SMART diagnostics to assess disk health
  5. Attempts to mount the disk for data recovery operations
  6. Uses ddrescue to create a disk image for data recovery
  7. Scans recovered data with antivirus tools
  8. Generates a comprehensive report of all operations

Project Information

  • Category: System Utility & Bash Scripting
  • Technologies:
    Bash Linux SMART ddrescue ClamAV Maldet Filesystem Tools
  • Project Date: March 2025
  • Project URL: GitHub Repository

Technical Details

This disk repair utility is implemented as a bash script for maximum compatibility with Linux systems. It requires root privileges to perform low-level disk operations and interacts with various system utilities for comprehensive disk health assessment and recovery operations.

Dependencies

  • badblocks (for sector checking)
  • fsck/e2fsck (for filesystem repair)
  • smartctl (for SMART diagnostics)
  • ddrescue (for data recovery)
  • clamav (for malware scanning)
  • maldet (for additional malware detection)

Logging

The script creates comprehensive logs in /var/log/disk_health_check/ including:

  • Badblocks detection results
  • Filesystem check outputs
  • SMART test data
  • Data recovery progress
  • Malware scan reports
  • A comprehensive summary report