Linux工具篇--TestDisk磁盘数据恢复

389 阅读2分钟

简介

TestDisk 是一款强大 的免费数据恢复软件! 早期主要是设计用来在使用有缺陷的软件,病毒或人为误操作(如不小心删除分区表)导致的分区丢失后,帮助用户恢复丢失分区,或修复不能启动的磁盘。 用Testdisk来恢复分区表非常简单。

下载和编译

https://www.cgsecurity.org/wiki/TestDisk_Download

git clone https://git.cgsecurity.org/testdisk.git
# 代码下载地址

cd testdisk
mkdir config
autoreconf --install -W all -I config
./configure
make

# 编译

testdisk可恢复的文件系统

TestDisk checks and recovers lost partitions
It works with :
- BeFS (BeOS)                           - BSD disklabel (Free/Open/Net BSD)
- CramFS, Compressed File System        - DOS/Windows FAT12, FAT16 and FAT32
- XBox FATX                             - Windows exFAT
- HFS, HFS+, Hierarchical File System   - JFS, IBM's Journaled File System
- Linux btrfs                           - Linux ext2, ext3 and ext4
- Linux GFS2                            - Linux LUKS
- Linux Raid                            - Linux Swap
- LVM, LVM2, Logical Volume Manager     - Netware NSS
- Windows NTFS                          - ReiserFS 3.5, 3.6 and 4
- Sun Solaris i386 disklabel            - UFS and UFS2 (Sun/BSD/...)
- XFS, SGI's Journaled File System      - Wii WBFS
- Sun ZFS

执行并选择磁盘

Select a media (use Arrow keys, then press Enter):
 Disk /dev/sda - 480 GB / 447 GiB - ATA SDLF1DAR480G-1HH
>Disk /dev/sdb - 107 GB / 100 GiB - QEMU HARDDISK
 Disk /dev/sdc - 536 GB / 500 GiB - QEMU HARDDISK
 Disk /dev/mapper/centos-root - 97 GB / 91 GiB - QEMU HARDDISK
 Disk /dev/mapper/centos-swap - 8455 MB / 8064 MiB - QEMU HARDDISK
 Disk /dev/dm-0 - 97 GB / 91 GiB - QEMU HARDDISK
 Disk /dev/dm-1 - 8455 MB / 8064 MiB - QEMU HARDDISK

# 选择需要数据恢复的磁盘

选择磁盘的分区表

Please select the partition table type, press Enter when done.
 [Intel  ] Intel/PC partition
>[EFI GPT] EFI GPT partition map (Mac i386, some x86_64...)
 [Humax  ] Humax partition table
 [Mac    ] Apple partition map (legacy)
 [None   ] Non partitioned media
 [Sun    ] Sun Solaris partition
 [XBox   ] XBox partition
 [Return ] Return to disk selection

# 一般磁盘使用的分区表为GPT

选择分析操作

>[ Analyse  ] Analyse current partition structure and search for lost partitions
 [ Advanced ] Filesystem Utils
 [ Geometry ] Change disk geometry
 [ Options  ] Modify options
 [ Quit     ] Return to disk selection
 
 # Analyse 恢复丢失的分区表,比如dd系统盘后,恢复系统等
 # Advanced 恢复文件系统丢失的文件,没有覆盖则可以找到
 # Geometry 修改文件系统的扇区,大小等参数

注意

对于文件恢复过程中的很多步骤,可以使用退出(按 q 或“[ Quit ]”)来返回上一步;
也可以选择退出选项一直回到该过程中的第一步;
也可以选择按下 ^c 立即退出。