Récupération de données avec TestDisk

TestDisk est un logicie de récupération de données qui a été conçu dans le but de récupérer les partitions perdu ou les disques qui ne boote plus à cause d'une défaillance. TesDisk est disponible pour les systèmes d'exploitation suivant : Linux, Windows, MacOS, et supporte un grand nombre de système de fichier.

Cette article est une introduction dans l'utilisation de TestDisk, si vous voulez en savoir plus consulter la documentation : TestDisk documentation.

1 Obtenir TestDisk

Installer TestDisk avec les outils de gestion de paquets propre à votre distribution, ou sinon vous pouvez le télécharger ici

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

TestDisk est aussi présent dans de nombreux LiveCD tel que GParted ou Knoppix (une liste complète ici : http://www.cgsecurity.org/wiki/TestDisk_Livecd).

2 Utiliser TestDisk

TestDisk peut etre utilisé depuis la ligne de commande.

testdisk /list

vous donnera la liste des partitions :

server1:~# testdisk /list
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

Maintenant imaginons que nous avons une partition de perdu et que l'on veut la restorer.

testdisk

Le menu vous permet de choisir les opérations suivantes :

 

TestDisk 6.5, Data Recovery Utility, October 2006
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

<-- Create

TestDisk 6.5, Data Recovery Utility, October 2006
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.

<-- Proceed

TestDisk 6.5, Data Recovery Utility, October 2006
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'.

<-- Intel

TestDisk 6.5, Data Recovery Utility, October 2006
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.

<-- Analyse

TestDisk 6.5, Data Recovery Utility, October 2006
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

Aucune partition bootable n'a été trouvée,

<-- Proceed

Sur l'écran suivat TesDisk montre les partitions qu'il a trouvé :

TestDisk 6.5, Data Recovery Utility, October 2006
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

<-- ENTER

Selectionner Write pour écrir notre nouvelle table de partition que TestDisk a trouvé sur le disque :

TestDisk 6.5, Data Recovery Utility, October 2006
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

<-- Write

Confirmer par Y

TestDisk 6.5, Data Recovery Utility, October 2006
Christophe GRENIER <grenier@cgsecurity.org>
http://www.cgsecurity.org

Write partition table, confirm ? (Y/N)

<-- Y

TestDisk vous indique de rebooter pour que les changements soit actif:

TestDisk 6.5, Data Recovery Utility, October 2006
Christophe GRENIER <grenier@cgsecurity.org>
http://www.cgsecurity.org

You will have to reboot for the change to take effect.

[Ok]

<-- Ok

Quitter TestDisk :

TestDisk 6.5, Data Recovery Utility, October 2006
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.

<-- Quit

Encore une fois :

TestDisk 6.5, Data Recovery Utility, October 2006
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

Le système reboot, retiré les CDs/DVDs et si tout va bien votre système boot avec la nouvelle table de partition.

 

3 Links