MAC OS恢复rm -rf删除的文件

问题:工作中使用一个apple mac操作系统电脑,偶然误操作rm -rf删除了辛苦熬出来的代码,如何恢复?

 

解决方法:1.  进入http://www.cgsecurity.org/wiki/TestDisk_Download,下载适合自己系统的版本,我下载http://www.cgsecurity.org/testdisk-6.13.linux26.tar.bz2,解压

 

                  2.  cd testdisk-6.14-WIP

                       ./photorec_static

                  3. 看到选择界面

>Select a media (use Arrow keys, then press Enter):

>Disk /dev/sda - 21 GB / 20 GiB - VMware, VMware Virtual S
>[Proceed]  [  Quit  ]                                                                       

                     运行  Proceed

 

                  4. 看到选择界面
>     Partition                  Start        End    Size in sectors                              
>     No partition             0   0  1  2610 212 34   41943040 [Whole disk]
>     1 * Linux                 0   1  1    12 254 63     208782 [/boot]
>     2 P Linux Swap      13   0  1   143 254 63    2104515
>     3 P Linux               144   0  1  2609 254 63   39616290 [/]

 

>[ Search ]  [Options ]  [File Opt]  [  Quit  ]

                       选择要恢复文件  所在文件系统 我在是在根目录   / 运行  Search      右边的那些参数想调的自己调  我默认了

 

                   5. 看到选择界面

To recover lost files, PhotoRec need to know the filesystem type where the
file were stored:
>[ ext2/ext3 ] ext2/ext3/ext4 filesystem
 [ Other ] FAT/NTFS/HFS+/ReiserFS/...
                       选择所丢失文件 所在的文件系统类型  我的是EXt3 所以选择了  第一个


                   6. 看到选择界面

Please choose if all space need to be analysed:
 [ Free ] Scan for file from ext2/ext3 unallocated space only
>[ Whole ] Extract files from whole partition
                       选择 Whole,费的时间稍长

 

                   8. 看到选择界面

Please select a destination to save the recovered files.
Do not choose to write the files to the same partition they were stored on.
Keys: Arrow keys to select another directory
      C when the destination is correct
      Q to quit
Directory /boot/testdisk-6.14-WIP
>drwxrwxr-x   500   500      1024 20-Mar-2012 14:01 .
 drwxr-xr-x     0     0      1024 17-Mar-2012 11:20 ..
 drwxrwxr-x   500   500      1024 11-Mar-2012 00:23 ico
 drwxrwxr-x   500   500      1024 11-Mar-2012 00:23 l
 -rw-r--r--   500   500       216 12-Nov-2007 00:21 AUTHORS
 -rw-r--r--   500   500     17987 16-Jun-2006 06:01 COPYING
 -rw-r--r--   500   500    117098 15-Nov-2011 15:17 ChangeLog
 -rw-r--r--   500   500       117  2-Jan-2012 01:35 INFO
 -rw-r--r--   500   500     14644 17-Nov-2011 20:55 NEWS
 -rwxrwxr-x   500   488   4793221 11-Mar-2012 00:35 testdisk_static
                      你选择恢复出来的文件存放位置,注意不要选择跟原文件目录,我的丢失的文件在  /shell下,选择恢复到/boot,然后按C键,就开始恢复。

 

                  9. 恢复完成后,去/boot找即可。

猜你喜欢

转载自834945712.iteye.com/blog/2018908