使用TestDisk进行数据恢复
版本1.0
作者:Falko Timme
TestDisk是一个功能强大的免费数据恢复软件,主要用于帮助恢复丢失的分区和/或使非引导磁盘重新启动,这些症状是由故障软件,某些类型的病毒或人为错误(如意外删除您的分区)引起的表)。 TestDisk可用于许多操作系统,包括Linux,Windows和MacOS,并支持大量的文件系统。
本文是对TestDisk的简短介绍; 如果您想了解有关TestDisk的更多信息以及它可以为您做什么,您应该参考TestDisk文档 。
我不会保证这将为您工作!
1获取TestDisk
TestDisk可用作许多Linux发行版的软件包,例如Debian / Ubuntu,Fedora,Mandriva等(完整列表可以在http://www.cgsecurity.org/wiki/TestDisk_Livecd上找到 )。 在Debian / Ubuntu上,你会跑
apt-get install testdisk
安装它。
如果您的发行版没有包,您可以从http://www.cgsecurity.org/wiki/TestDisk_Download下载TestDisk。
使用TestDisk的更好的方法是下载包含TestDisk的Linux Live-CD,如GParted或Knoppix (可以在http://www.cgsecurity.org/wiki/TestDisk_Livecd上找到Live-CD的完整列表) ,因为如果TestDisk安装在不能由于分区错误而不能启动的系统上,则无法帮助
2使用TestDisk
TestDisk可以从命令行运行。
testdisk /list
给你一个分区列表:
server1:~# testdisk /list
TestDisk 6.5, Data Recovery Utility, October 2006
Christophe GRENIER <grenier@cgsecurity.org>
http://www.cgsecurity.org
Please wait...
Disk /dev/sda - 32 GB / 29 GiB - CHS 3916 255 63, sector size=512
Disk /dev/sda - 32 GB / 29 GiB - CHS 3916 255 63
Partition Start End Size in sectors
1 * Linux 0 1 1 3869 254 63 62171487
2 E extended 3870 0 1 3915 254 63 738990
5 L Linux Swap 3870 1 1 3915 254 63 738927
现在我们假设我们已经丢失了分区表,并希望恢复它。 要使用TestDisk,只需运行
testdisk
这是一个菜单驱动的工具,所以这是你会看到的(我会用红色标记我的选择):
TestDisk 6.5, Data Recovery Utility, October 2006
Christophe GRENIER <grenier@cgsecurity.org>
http://www.cgsecurity.org
TestDisk is a data recovery designed to help recover lost partitions
and/or make non-booting disks bootable again when these symptoms
are caused by faulty software, certain types of viruses or human error.
It can also be used to repair some filesystem errors.
Information gathered during TestDisk use can be recorded for later
review. If you choose to create the text file, testdisk.log , it
will contain TestDisk options, technical information and various
outputs; including any folder/file names TestDisk was used to find and
list onscreen.
Use arrow keys to select, then press Enter key:
[ Create ] Create a new log file
[ Append ] Append information to log file
[ No Log ] Don't record anything
< - 创建
TestDisk 6.5, Data Recovery Utility, October 2006
Christophe GRENIER <grenier@cgsecurity.org>
http://www.cgsecurity.org
TestDisk is free software, and
comes with ABSOLUTELY NO WARRANTY.
Select a media (use Arrow keys, then press Enter):
Disk /dev/sda - 32 GB / 29 GiB
[Proceed ] [ Quit ]
Note: Disk capacity must be correctly detected for a successful recovery.
If a disk listed above has incorrect size, check HD jumper settings, BIOS
detection, and install the latest OS patches and disk drivers.
< - 继续
TestDisk 6.5, Data Recovery Utility, October 2006
Christophe GRENIER <grenier@cgsecurity.org>
http://www.cgsecurity.org
Disk /dev/sda - 32 GB / 29 GiB
Please select the partition table type, press Enter when done.
[Intel ] Intel/PC partition
[Mac ] Apple partition map
[None ] Non partioned media
[Sun ] Sun Solaris partition
[XBox ] XBox partition
[Return ] Return to disk selection
Note: Do NOT select 'None' for media with only a single partition. It's very
rare for a drive to be 'Non-partitioned'.
< - Intel
TestDisk 6.5, Data Recovery Utility, October 2006
Christophe GRENIER <grenier@cgsecurity.org>
http://www.cgsecurity.org
Disk /dev/sda - 32 GB / 29 GiB - CHS 3916 255 63
[ Analyse ] Analyse current partition structure and search for lost partitions
[ Advanced ] Filesystem Utils
[ Geometry ] Change disk geometry
[ Options ] Modify options
[ MBR Code ] Write TestDisk MBR code to first sector
[ Delete ] Delete all data in the partition table
[ Quit ] Return to disk selection
Note: Correct disk geometry is required for a successful recovery. 'Analyse'
process may give some warnings if it thinks the logical geometry is mismatched.
< - 分析
TestDisk 6.5, Data Recovery Utility, October 2006
Christophe GRENIER <grenier@cgsecurity.org>
http://www.cgsecurity.org
Disk /dev/sda - 32 GB / 29 GiB - CHS 3916 255 63
Current partition structure:
Partition Start End Size in sectors
No partition is bootable
*=Primary bootable P=Primary L=Logical E=Extended D=Deleted
[Proceed ]
Try to locate partition
如您所见,没有找到可引导的分区。 选择
< - 继续
接着说。 在下一个屏幕上,TestDisk将显示您找到的分区:
TestDisk 6.5, Data Recovery Utility, October 2006
Christophe GRENIER <grenier@cgsecurity.org>
http://www.cgsecurity.org
Disk /dev/sda - 32 GB / 29 GiB - CHS 3916 255 63
Partition Start End Size in sectors
* Linux 0 1 1 3869 254 63 62171487
L Linux Swap 3870 1 1 3915 254 63 738927
Structure: Ok. Use Up/Down Arrow keys to select partition.
Use Left/Right Arrow keys to CHANGE partition characteristics:
*=Primary bootable P=Primary L=Logical E=Extended D=Deleted
Keys A: add partition, L: load backup, T: change type, P: list files,
Enter: to continue
EXT3 Large file Sparse superblock Recover, 31 GB / 29 GiB
< - ENTER
在下一个屏幕上,我们选择写入
将新分区表(由TestDisk从刚刚发现的分区计算)写入硬盘:
TestDisk 6.5, Data Recovery Utility, October 2006
Christophe GRENIER <grenier@cgsecurity.org>
http://www.cgsecurity.org
Disk /dev/sda - 32 GB / 29 GiB - CHS 3916 255 63
Partition Start End Size in sectors
1 * Linux 0 1 1 3869 254 63 62171487
2 E extended LBA 3870 0 1 3915 254 63 738990
5 L Linux Swap 3870 1 1 3915 254 63 738927
[ Quit ] [Search! ] [ Write ]
Write partition structure to disk
< - 写
通过输入Y
确认:
TestDisk 6.5, Data Recovery Utility, October 2006
Christophe GRENIER <grenier@cgsecurity.org>
http://www.cgsecurity.org
Write partition table, confirm ? (Y/N)
< - Y
TestDisk告诉您必须重新启动以使更改生效:
TestDisk 6.5, Data Recovery Utility, October 2006
Christophe GRENIER <grenier@cgsecurity.org>
http://www.cgsecurity.org
You will have to reboot for the change to take effect.
[Ok]
< - 好的
在下一个屏幕上选择退出
:
TestDisk 6.5, Data Recovery Utility, October 2006
Christophe GRENIER <grenier@cgsecurity.org>
http://www.cgsecurity.org
Disk /dev/sda - 32 GB / 29 GiB - CHS 3916 255 63
[ Analyse ] Analyse current partition structure and search for lost partitions
[ Advanced ] Filesystem Utils
[ Geometry ] Change disk geometry
[ Options ] Modify options
[ MBR Code ] Write TestDisk MBR code to first sector
[ Delete ] Delete all data in the partition table
[ Quit ] Return to disk selection
Note: Correct disk geometry is required for a successful recovery. 'Analyse'
process may give some warnings if it thinks the logical geometry is mismatched.
< - 退出
选择再次退出
以终止TestDisk:
TestDisk 6.5, Data Recovery Utility, October 2006
Christophe GRENIER <grenier@cgsecurity.org>
http://www.cgsecurity.org
TestDisk is free software, and
comes with ABSOLUTELY NO WARRANTY.
Select a media (use Arrow keys, then press Enter):
Disk /dev/sda - 32 GB / 29 GiB
[Proceed ] [ Quit ]
Note: Disk capacity must be correctly detected for a successful recovery.
If a disk listed above has incorrect size, check HD jumper settings, BIOS
detection, and install the latest OS patches and disk drivers.
Quit program
< - 退出
我们现在已经离开TestDisk并且返回到shell。 我们现在要做的是重新启动系统(从CD / DVD驱动器中删除任何CD / DVD),如果一切顺利,原始系统应该启动,因为我们的新分区表。
3链接
- TestDisk: http : //www.cgsecurity.org/wiki/TestDisk