转自:http://www.howtoforge.com/data_recovery_with_testdisk 官方文档:http://www.cgsecurity.org/wiki/TestDisk
需求:
单系统ubuntu,想装windows,结果误删除了ubuntu下的一个分区(windows安装的时候明明看了好几遍,还是误删了),安装前,确认下分区状况,发现分区不对,立即停止安装系统,进入ubuntu(ubuntu启动不起来,将前512字节dd回MBR,也可以通过grub>命令修复),安装testdisk
testdisk简介
testdisk是一款强大并且免费的数据恢复的软件,软件的主要功能是当人为的错误(意外的删除你的分区表),软件出现问题,或者中毒的情况下,帮助用户找回丢失的分区,或者是将一个不能启动的盘让其启动起来。在很多的操作系统上,都可以使用testdisk,包括Linux,MacOS,Windows,并支持许多的文件系统
1 下载 TestDisk
2 使用TestDisk
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
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
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.
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'.
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.
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
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
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
Christophe GRENIER <grenier@cgsecurity.org>
http://www.cgsecurity.org
Write partition table, confirm ? (Y/N)
Christophe GRENIER <grenier@cgsecurity.org>
http://www.cgsecurity.org
You will have to reboot for the change to take effect.
[Ok]
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.
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
3 Links
- TestDisk: http://www.cgsecurity.org/wiki/TestDisk