[P]artial [F]ile [R]ecovery in case of badSector, HDD Error

Published Date: 2022/12/04 by: DaVieS

[P]artial [F]ile [R]ecovery in case of badSector, HDD Error
[P]artial [F]ile [R]ecovery in case of badSector, HDD Error

Our new Software released under Open Source license.

PFR is a cross-platform easy-to-use powerfull tool to recover broken files that caused HDD or Filesystem errors. Seemed very usefull recovering corrupted innoDB databases as well. 

Download here: https://github.com/DaVieS007/Partial-File-Recovery

Overview

Software is intended to recover files from a bad drive, written in pure C, by doing the following:

  • Unlike other similar softwares, default action is Fast Forward which is a 64K direct-copy and only fallback to Block Mining aka byte-to-byte copy when badblock found and for a short period as recovery necessary, this mechanism give insane recovery speed on huge files.
  • In recovery mode, there is an option to define max retry, which intended to probe [x] times the same sector to recover badblock, there is a little chance to succeed anyway. Also if the block could not be recovered the software will fill a specified character instead (default: 0x00) and continues read, this mechanism allows to partially recover the file.

 

What can be recover partially

  • innoDB tables (*.ibd) recovery possible on small amount of data loss, combinated with innodb_recovery_mode = 6 there are a great chance to able to dump the database with only a few rows missing.
  • Video Files, Mp3 Files, Pictures, Text Files, Anything.

What can NOT be recover

  • Deleted files, this software intended to use on files that affected by filesystem error or HDD error.



The story behind it

  • First of all: I never thought that this could happen on modern hardware and software.
  • A VPS-Host machine with ZFS storage and a Virtual Machine with Centos 7 running top of ext4 filesystem. The ext4 filesystem suddenly collapsed for no reason, (it was extended months before).
  • mySQL database gone with some bigger files under heavy load.
  • I successfully developed this software that allowed us to recover all the files within the entire system without a data loss, due only 15x 16K pages lost where was not userdata.
  • Partial recovery was allowed us to start mySQL server, however middle of dump creation, hang up and crashed down lately, the setting: ˛innodb_recovery_mode did the trick, dump & restore without any problem after all.
  • Yet Tested on old HDD with corrupted mp3, and mp4. Successfully recovered the mp3 with an audible glitch middle of the song, and also a video file with 3-4 second of frameskip at the begining.
[25381.474111] blk_update_request: I/O error, dev vda, sector 106469896
[25381.998891] blk_update_request: I/O error, dev vda, sector 106469896
[25382.529098] blk_update_request: I/O error, dev vda, sector 106469896
[25383.134682] blk_update_request: I/O error, dev vda, sector 106469896
[25383.546360] blk_update_request: I/O error, dev vda, sector 106469896
[25383.756537] blk_update_request: I/O error, dev vda, sector 106469896



Compilation

  • gcc -o pfr pfr.c or clang -o pfr pfr.c

Usage

[P]artial [F]ile [R]ecovery Version: 1.0r
Author: Viktor Hlavaji aka DaVieS, davies@npulse.net | Licensed under: GNU/GPLv3
Usage: ./pfr [source_file] [dest_file] [try = 1] [fill = 00]
 - source_file: The file that needs recover
 - dest_file: Output file will generated by this software
 - try: (Optional) number of attempts to read a badSector
 - fill: (Optional) unrecovered bytes will replaced by hexCode 0x[XX]
Software Output:
Action | Current Block: 315385359, Round Left: 1, lost: 26127, recovered: 12, acquired: 315359232, Progress: 60.154984
 |       |                         |              |            |              |                    |-> Progress
 |       |                         |              |            |              |-> Bytes read successfully
 |       |                         |              |            |-> Bytes magically recovered
 |       |                         |              |-> Unrecovered Bytes that filled with a specified character
 |       |                         |-> Retry Count Left
 |       |-> Show current position
 |-> [Fast Forward] when continous data read available, or [Block Mining] when recovery in action
Example: ./pfr ./broken_file.mp3 ./broken_file_fix.mp3
Example: ./pfr /home/music/broken_file.mp3 /tmp/broken_file_fix.mp3 2 00

 

Sample Output

[root@vhost damaged]# ./pfr ib_logfile1 ib_logfile1.fix
[P]artial [F]ile [R]ecovery Version: 1.0r
Author: Viktor Hlavaji aka DaVieS, davies@npulse.net | Licensed under: GNU/GPLv3
Source File Opened Successfully: ib_logfile1
Destination File Opened Successfully: ib_logfile1.fix
Total Bytes to recover: 524288000
badBlock Try Count: 1
badBlock fill char: 0x00
Fast Forward | Current Block: 0, Round Left: 1, lost: 0, recovered: 0, acquired: 0, Progress: 0.000000
Fast Forward | Current Block: 271253504, Round Left: 1, lost: 0, recovered: 0, acquired: 271253504, Progress: 51.737499
Block Mining | Current Block: 313786368, Round Left: 0, lost: 0, recovered: 0, acquired: 313786368, Progress: 59.850002
Block Mining | Current Block: 313819234, Round Left: 0, lost: 98, recovered: 0, acquired: 313819136, Progress: 59.856270
Block Mining | Current Block: 313819309, Round Left: 0, lost: 173, recovered: 0, acquired: 313819136, Progress: 59.856285
Block Mining | Current Block: 313819445, Round Left: 0, lost: 309, recovered: 0, acquired: 313819136, Progress: 59.856308
Block Mining | Current Block: 313819447, Round Left: 0, lost: 311, recovered: 0, acquired: 313819136, Progress: 59.856312
Block Mining | Current Block: 313819455, Round Left: 0, lost: 319, recovered: 0, acquired: 313819136, Progress: 59.856312
Block Mining | Current Block: 313819473, Round Left: 0, lost: 337, recovered: 0, acquired: 313819136, Progress: 59.856316
Block Mining | Current Block: 315390216, Round Left: 0, lost: 30984, recovered: 0, acquired: 315359232, Progress: 60.155910
Block Mining | Current Block: 315391149, Round Left: 0, lost: 31917, recovered: 0, acquired: 315359232, Progress: 60.156090
Block Mining | Current Block: 315439742, Round Left: 0, lost: 32768, recovered: 0, acquired: 315406974, Progress: 60.165356
Finished | Current Block: 524288000, Round Left: 0, lost: 32768, recovered: 0, acquired: 524255232, Progress: 100





If you like the article then don't forget to share!


Nexus Datalogger 2023

Our first version of Datalogger Software released back in 2012. What we made is a simple and continuous datalogging software with a reliable..


TrackIT-PortGuard

This is a simple TCP Gateway or proxy with advanced security features.The mechanism similar to port knocking, however much more safe..


BVCP: FreeBSD Bhyve Web UI

This is a personal project from the author of nPulse.net, Viktor Hlavaji (DaVieS).nPulse.net is always willing to share knowledge and resources..


Kinga-Framework

This is an industry-class cross-platform complete Framework written in C/C++ with many built-in functions implemented and designed with..


SSH Two-Factor Authentication

SSH Twofactor Authentication is our "still-under-development" project.It for Android mobile phones and linux / FreeBSD servers.The goal is make..


sysAdmin ToolBox v2.0

We are happily announce that our second version of sysAdmin ToolBox for Adnroid mobile phones published into live.The first version of this..


ASPF-Milter

ASPF-Milter is our next generation Centralised SPAM Filter on both directions (sending, receiving).ASPF-Milter as it's name suggest uses MILTER..


Trackit-2019

Trackit-2019 is our enterprise class /very advanced/ all-in-one monitoring/datalogger application for IT / ICT Infrastructure. This is the 5th..


MVCP 1.0 (Discounted, 2.0 coming soon)

MVCP is our 5th generation of Mass Virtual Hosting Control Panel. Unlike any-other versions MVCP is written in PHP instead of C/C++/LUA.MVCP uses..

All rights reserved nPulse.net 2009 - 2024
Powered by: MVCP2 / BVCP / ASPF-MILTER / PHP 8.3 / NGINX / FreeBSD