A series of specialized disk utilities for managing virtual and real disks and drives.
DiskHand is a comprehensive set of command-line tools and scripts designed for advanced disk management. Leveraging the performance of C++ for low-level disk operations and the scripting power of Python for user interfaces and automation, this project provides powerful utilities for tasks that go beyond standard operating system tools. Whether you need to recover data, manage partitions, or create bit-for-bit disk clones, DiskHand aims to be your go-to solution.
- Partition Management: Easily create, resize, format, and delete partitions on both physical and virtual drives.
- Disk Imaging & Cloning: Create precise, sector-by-sector copies of disks for backup, migration, or forensic analysis.
- File System Tools: Analyze and repair various file systems including NTFS, ext4, and FAT32.
- FAT Disk Checking and Defragmentation: Inspect FAT16/FAT32 disk images for allocation and directory issues, apply safe repairs, and defragment files in place.
- Data Recovery: Tools to search for and recover deleted files and lost partitions.
- Cross-Platform Support: Designed to work on various operating systems.
- Python: Used for high-level scripting, command-line interfaces, and orchestrating complex workflows. Python's rich ecosystem of libraries makes it ideal for building a user-friendly layer on top of the C++ core.
- C++: Utilized for performance-critical, low-level disk access and manipulation. This ensures that operations like disk imaging and data recovery are as fast and efficient as possible.
To get a copy of the project up and running on your local machine, follow these simple steps. Prerequisites
- Python 3.x
- A C++ compiler (e.g., GCC, Clang)
- make (or a similar build tool)
- Clone the repository:
git clone https://github.com/your-username/DiskHand.git
cd DiskHand
- Install Python dependencies:
pip install -r requirements.txt
- Build the C++ utilities:
make
Each utility is designed to be run from the command line.
For example:
python diskmech.py --help
python fat16img.py my-disk.img 64MiB 128MiB 256MiB
python disklist.py path/to/disk.imgCreate a map with automatic size:
python diskmap.py --i path/to/disk.img --o map.pngCreate a map with fixed output resolution:
python diskmap.py --i path/to/disk.img --o map_640x480.png --resolution=640x480Use fixed resolution with denser map blocks (fewer cells):
python diskmap.py --i path/to/disk.img --o map_hd.png --resolution=1280x720 --density=1000Use a density preset:
python diskmap.py --i path/to/disk.img --o map_balanced.png --resolution=640x480 --preset=balancedForce perfect square blocks:
python diskmap.py --i path/to/disk.img --o map_square.png --resolution=640x480 --preset=balanced --squareblocksDisable automatic density adjustment (strict mode):
python diskmap.py --i path/to/disk.img --o map_strict.png --resolution=640x480 --density=1 --no-autodensityNotes:
--resolution=WIDTHxHEIGHTsets the exact PNG size.- The legend and map panel positions are fixed for a given resolution.
- The map always uses the maximum available panel area for the chosen resolution.
--density=NgroupsNclusters into one map cell (default:1) and changes block size/detail inside the fixed map panel.--preset=detail|balanced|overviewis a shortcut for density values1,100, and1000.--squareblocksforces all map blocks to be perfect squares; to preserve square geometry, the drawn map can be slightly smaller than the panel.- For very large disks, density is auto-increased when needed so the map still fits the requested resolution.
--no-autodensitydisables this automatic increase and fails fast when the chosen density cannot fit.
Density quick guide:
--density=1: highest detail, smallest blocks.--density=10: very detailed, still fine-grained.--density=100: balanced overview/detail.--density=1000: coarse overview, large blocks.
diskmech.py works directly on MBR-partitioned disk images and targets FAT16 and FAT32 volumes.
It can:
- list partitions in an image
- run integrity checks for lost clusters, cross-links, directory-chain issues, FAT copy mismatches, and FAT32 FSInfo inconsistencies
- apply safe repairs for orphaned clusters and selected FAT metadata issues
- defragment files in place or run denser full/perfect packing passes
Examples:
List partitions:
python diskmech.py path/to/disk.img --listCheck a FAT partition only:
python diskmech.py path/to/disk.img -p 1 --check-onlyRepair all safe issues automatically:
python diskmech.py path/to/disk.img -p 1 --repair --repair-autofix --inplaceAsk before each repairable issue:
python diskmech.py path/to/disk.img -p 1 --repair --repair-ask --inplacePreview defragmentation without writing:
python diskmech.py path/to/disk.img -p 1 --dry-run --verboseRun in-place defragmentation:
python diskmech.py path/to/disk.img -p 1 --inplaceNotes:
--repairenables the repair workflow.--repair-autofixapplies all repairable actions without prompts.--repair-askasks before each repair action and requires an interactive terminal.--fullruns denser packing.--perfectruns iterative full optimization passes to reduce internal holes as much as possible.- Back up the image before any write operation.
Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (git checkout -b feature/AmazingFeature)
- Commit your Changes (git commit -m 'Add some AmazingFeature')
- Push to the Branch (git push origin feature/AmazingFeature)
- Open a Pull Request
Distributed under the MIT License. See LICENSE for more information.