1.为了顺利安装testdisk 工具,安装开发四个组包(正确的配制yum)。
yum groupinstall " Development Libraries " -y,注意一定要加引号。
yum groupinstall " Development Tools " -y
yum groupinstall " Legacy Software Development " -y
yum groupinstall " X Software Development " -y
注:对应成中文就是:Development Libraries 开发库; Development Tools 开发工具;
Legacy Software Development 老的软件开发; X Software Development X软件开发;
查看分区表。发现少了一个主分区。
2.安装testdisk
[[email protected] ~]# tar -jxvf testdisk-6.8.tar.bz2
[[email protected] ~]# cd testdisk-6.8
3.查看configure帮助
[[email protected] testdisk-6.8]# ./configure --help |less
预编译。
[[email protected] testdisk-6.8]# ./configure --prefix=/usr/local/sbin //指明安装路径。
4.编译。产生头文件,库文件,可执行文件,说明文件。
[[email protected] testdisk-6.8]# make && make install
启动 testdisk:
[[email protected] sbin]# ls
man photorec sbin share testdisk testdisk.log
[[email protected] sbin]# ./testdisk
第一页屏幕要求选择如何处理记录信息
第二页要求选择磁盘:
TestDisk is free software, and
comes with ABSOLUTELY NO WARRANTY.
Select a media (use Arrow keys, then press Enter):
Disk /dev/hdc - 3005 MB / 2866 MiB (RO)
Disk /dev/sda - 21 GB / 19 GiB
[Proceed ] [ Quit ]
第三页选择分区表类型,一般都是 Intel/PC:
Disk /dev/sda - 21 GB / 19 GiB
Please select the partition table type, press Enter when done.
[Intel ] Intel/PC partition
[Mac ] Apple partition map
[None ] Non partitioned 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 veryrare for a drive to be 'N
现在可以 Analyse (分析)了:
Disk /dev/sda - 21 GB / 19 GiB - CHS 2610 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.
列出现有的分区表内容,并提示继续还是备份,这里只有一个分区,实际上另外一个 Linux 分区被删了...所以 1661 之前那些空间就是寻找的目标:
Disk /dev/sda - 21 GB / 19 GiB - CHS 2610 255 63
Current partition structure:
Partition Start End Size in sectors
1 * Linux 0 1 1 130 254 63 2104452 [/boot]
3 P Linux Swap 1661 0 1 1791 254 63 2104515
Should TestDisk search for partition created under Vista ? [Y/N] (answer Yes if
unsure)y
Disk /dev/sda - 21 GB / 20 GiB - CHS 2611 255 63
Partition Start End Size in sectors
* Linux 0 1 1 130 254 63 2104452 [/boot]
P Linux 131 0 1 1660 254 63 24579450 [/]
P Linux Swap 1661 0 1 1791 254 63 2104515
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, 1077 MB / 1027 MiB
*=Primary bootable P=Primary L=Logical E=Extended D=Deleted
[Proceed ] [ Backup ]
使用左右方向键将其调整成以前的状态 P(主分区),然后 Enter 继续:
Disk /dev/sda - 21 GB / 20 GiB - CHS 2611 255 63
Partition Start End Size in sectors
1 * Linux 0 1 1 130 254 63 2104452 [/boot]
2 P Linux 131 0 1 1660 254 63 24579450 [/]
3 P Linux Swap 1661 0 1 1791 254 63 2104515
[ Quit ] [Search! ] [ Write ]
Write partition structure to disk
选择 Write 保存
Write partition table, confirm ? (Y/N)Y
退出,reboot
源码testdisk http://down.51cto.com/data/695210
转载于:https://blog.51cto.com/dg123/1148735