发博文
个人资料
psi
  • 博客访问:16528
  • 博文数量:6
  • 博客积分:1400
  • 博客等级:上尉
  • 注册时间:2006-09-08 16:00:49
订阅我的博客
  • 订阅
  • 订阅到鲜果
  • 订阅到抓虾
  • 订阅到Google
字体大小: 博文


    昨晚装系统,不小心把移动硬盘上一个 81G 的 reiserfs 分区给删除了,那上面可有积累了六年的资料啊,当时还没反应过来,甚至沾沾自喜,过了一会才发现该删的分区完好无损,这才仔细一看,原来如此...

    于是赶紧卸载了移动硬盘,保证不会再犯傻去给那块空闲的空间新建分区... 早上忽然想到以前在什么地方看到过的一个软件 TestDisk,于是赶紧展开救援工作...

一、安装 TestDisk

    在这里下载
    http://www.cgsecurity.org/testdisk-6.8.tar.bz2

tar jxvf testdisk-6.8.tar.bz2
cd testdisk-6.8
./configure
make
sudo make install


二、恢复实践

    启动 testdisk:

sudo /usr/local/sbin/testdisk

    第一页屏幕要求选择如何处理记录信息
   
TestDisk 6.8, Data Recovery Utility, August 2007
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.8, Data Recovery Utility, August 2007
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/hda - 40 GB / 37 GiB
Disk /dev/sda - 120 GB / 111 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.


    下一页选择分区表类型,一般都是 Intel/PC:

TestDisk 6.8, Data Recovery Utility, August 2007
Christophe GRENIER <grenier@cgsecurity.org>
http://www.cgsecurity.org


Disk /dev/sda - 120 GB / 111 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 very
rare for a drive to be 'Non-partitioned'.


    现在可以 Analyse 了:

TestDisk 6.8, Data Recovery Utility, August 2007
Christophe GRENIER <grenier@cgsecurity.org>
http://www.cgsecurity.org


Disk /dev/sda - 120 GB / 111 GiB - CHS 14593 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 分区昨晚被我删了...所以 9960 之前那些空间就是寻找的目标:

TestDisk 6.8, Data Recovery Utility, August 2007
Christophe GRENIER <grenier@cgsecurity.org>
http://www.cgsecurity.org

Disk /dev/sda - 120 GB / 111 GiB - CHS 14593 255 63
Current partition structure:
     Partition                  Start        End    Size in sectors

 1 P FAT32 LBA             9960   0  1 14592 254 63   74429145 [HZG'S]
No partition is bootable











*=Primary bootable  P=Primary  L=Logical  E=Extended  D=Deleted
[Proceed ]  [ Backup ]
                            Try to locate partition


    直接选择开始处理(Proceed),要问你一句:

TestDisk 6.8, Data Recovery Utility, August 2007
Christophe GRENIER <grenier@cgsecurity.org>
http://www.cgsecurity.org

Should TestDisk search for partition created under Vista ? [Y/N] (answer Yes if
unsure)


    不知道啥叫 Vista,我选 N:

TestDisk 6.8, Data Recovery Utility, August 2007
Christophe GRENIER <grenier@cgsecurity.org>
http://www.cgsecurity.org

Disk /dev/sda - 120 GB / 111 GiB - CHS 14593 255 63
     Partition               Start        End    Size in sectors
* Linux                    0   1  1  9959 254 63  160007337
P FAT32 LBA             9960   0  1 14592 254 63   74429145 [HZG'S]











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
ReiserFS 3.6 with standard journal, need recovery, 81 GB / 76 GiB


哈哈,看到了没有, 0~9959 那个 Linux 分区,被发现了...

    使用左右方向键将其调整成以前的状态 P(主分区),然后 Enter 继续:

TestDisk 6.8, Data Recovery Utility, August 2007
Christophe GRENIER <grenier@cgsecurity.org>
http://www.cgsecurity.org

Disk /dev/sda - 120 GB / 111 GiB - CHS 14593 255 63

     Partition                  Start        End    Size in sectors

 1 P Linux                    0   1  1  9959 254 63  160007337
 2 P FAT32 LBA             9960   0  1 14592 254 63   74429145 [HZG'S]













[  Quit  ]  [Search! ]  [ Write  ]
                       Write partition structure to disk


    选择 Write 保存,万事大吉!!

三、感慨

TestDisk 很好用...

亲,您还没有登录,请[登录][注册]后再进行评论