
| Ubuntu Rescue Remix Ubuntu Rescue Remix is a GNU/Linux live system which runs from CD or USB flash device. It provides the data recovery specialist with a command-line interface environment equipped with the best free-libre, open source data recovery and forensics tools available. There is also a special Ubuntu Rescue Remix Web Forum where you may ask for expert help with your problems. |
| DataRecovery - Ubuntu Community Docs Please read the Ubuntu Documentation page on data recovery before you do anything. |
| TestDisk - CG Security
the official homepage for TestDisk, TestDisk has its own excellent illustrated documentation. PhotoRec - CG Security the official homepage for PhotoRec, TestDisk's companion application, so you can read the official documentation. An Introduction to Data Recovery, by Daniel B. Sedory (better know as The Starman). recommended reading, it contains a lot of very good information. How to recover lost files after you accidentally wipe your hard drive by Shawn Hermans - Recommended if you're going to use PhotoRec Recovering Windows files with a Ubuntu CD III: deleted files - Ubuntucat by aysiu - also recommended if you need to use PhotoRec Disk Recovery, a Ubuntu Web Forums thread, particularly see brennydoogles' prorganize.sh script - for use with PhotoRec |
| Recovering an accidentally deleted NTFS partition on a second hard disk with TestDisk in Ubuntu installed in the first hard disk (simple) Recovering a Lost Partition With TestDisk - searching deeper (advanced) |
| There
are some important things to understand if you need to use TestDisk for
restoring a lost partition or for reconstructing a damaged partition
table. TestDisk can be used to scan your hard disk for sectors that resemble the beginning sectors of file systems. Those sectors may remain on the hard disk for virtually forever or until they get 'zeroed out' or overwritten with new data. When the information about the starting locations and the lengths of the file systems is found, TestDisk will show you that information and you can choose which partitions you want written to a new partition table (in the MBR of the hard disk). That information is often enough to restore the complete file system and all the data it contains. If you have a hard disk that has not been repartitioned a great number of times, using TestDisk should be fairly simple, as shown in the first example in this page. If you are running TestDisk on a hard disk that has had of repartitioning work done on it, then TestDisk might find file systems that might not be compatable to restore together. They may overlap other partitions or they might not all fit in the partition table. The partition table contains four slots of sixteen bytes each, so there can only be four primary partitions per hard disk. One of those slots can contain an 'extended' partition instead, which refers to a string of 'logical' partitions, but these 'logical' partitions need to be strung together in a series. (A primary partition can't be placed in between logical partitions or it will 'break the chain'). The second example in this page shows how ot use TestDisk to 'search deeper', and is more advanced. You'll see right at the bottom of this page (in the last illustration) where there is a range of possible partitions presented for possible restoration to the partition table and the user needs to be able to decide which ones are required or compatible (possible). The partitions to be included in the new partition table must be marked with an ' * ' or an 'L' or a 'P', or they won't be included in the new partition table. Partition numbering may be possibly changed, that can be a good thing in some circumstances, and if you become skilled with TestDisk you may be able to use that to your advantage. Having changed partition numbers for a data partition probably won't matter. Having changed partition numbers for an operating system partition might mean a little extra work for some people because that may affect booting. If you're using Ubuntu Linux you may need to edit /boot/grub/menu.lst to update it with new partition numbers, and possibly /etc/fstab if your file systems have been changed too. Editing /etc/fstab. You may find Super Grub Disk useful for helping you boot for the first time so you can edit those files easily. If you change the partition number for a Windows XP operating system, you will probably need to edit boot.ini to make Windows XP bootable again. If you can't boot Windows XP you might go to How to fix: NTLDR is missing, press any key to restart and look there for a boot CD file you can burn to disk and use for booting your Windows XP, there are floppy of USB files you can download there too. |
| herman@amdxz:~$ sudo fdisk -l Password: Disk /dev/hda: 160.0 GB, 160041885696 bytes 255 heads, 63 sectors/track, 19457 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/hda1 * 1 9145 73457181 b W95 FAT32 /dev/hda2 9146 19106 80011732+ 83 Linux /dev/hda3 19107 19457 2819407+ 5 Extended /dev/hda5 19107 19457 2819376 82 Linux swap / Solaris Disk /dev/hdb: 160.0 GB, 160041885696 bytes 255 heads, 63 sectors/track, 19457 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System Disk /dev/hdc: 20.8 GB, 20847697920 bytes 255 heads, 63 sectors/track, 2534 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/hdc1 * 1 2427 19494846 83 Linux /dev/hdc2 2428 2534 859477+ 5 Extended /dev/hdc5 2428 2534 859446 82 Linux swap / Solaris |
| herman@amdxz:~$ sudo testdisk Password: |
| 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, certian 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 a text file, testdisk.log , it will contain TestDisk options, technical information and various outputs, including any folders/file names TestDisk was used to find and list on screen. Use Arrow keys to select, then press Enter key: [ Create ] Create a new log file [ Append ] Append information to the log file [ No Log ] Don't record anything |
| TestDisk 6.5, Data Recovery Utility, October 2006 Christophe GRENIER <grenier@cgsecurity.org> http://www.cgsecurity.org TestDisk as free software, and comes with ABSOLUTELY NO WARRANTY. Select a media (use Arrow keys, then press Enter): Disk /dev/hda - 160 GB / 149 GiB Disk /dev/hdb - 160 GB / 149 GiB Disk /dev/hdc - 20 MB / 19 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. |
| TestDisk 6.5, Data Recovery Utility, October 2006 Christophe GRENIER <grenier@cgsecurity.org> http://www.cgsecurity.org Disk /dev/hdb - 160 GB / 149 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'. |
| TestDisk 6.5, Data Recovery Utility, October 2006 Christophe GRENIER <grenier@cgsecurity.org> http://www.cgsecurity.org Disk /dev/hdb - 160 GB / 149 GiB - CHS 19457 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 the 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. |
| TestDisk 6.5, Data Recovery Utility, October 2006 Christophe GRENIER <grenier@cgsecurity.org> http://www.cgsecurity.org Disk /dev/hdb - 160 GB / 149 GiB - CHS 19457 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 |
| TestDisk 6.5, Data Recovery Utility, October 2006 Christophe GRENIER <grenier@cgsecurity.org> http://www.cgsecurity.org Disk /dev/hdb - 160 GB / 149 GiB - CHS 19457 255 63 Current partition structure: Partition Start End Size in sectors * HPFS - NTFS 0 1 1 19456 254 63 312576642 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 NTFS, 160 GB /149 GiB |
| TestDisk 6.5, Data Recovery Utility, October 2006 Christophe GRENIER <grenier@cgsecurity.org> http://www.cgsecurity.org Disk /dev/hdb - 160 GB / 149 GiB - CHS 19457 255 63 Current partition structure: Partition Start End Size in sectors 1 * HPFS - NTFS 0 1 1 19456 254 63 312576642 [ Quit ] [ Search! ] [ Write ] Write partition structure to disk |
| TestDisk 6.5, Data Recovery Utility, October 2006 Christophe GRENIER <grenier@cgsecurity.org> http://www.cgsecurity.org Write partition table, confirm ? (Y/N) |
| 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] |
| TestDisk 6.5, Data Recovery Utility, October 2006 Christophe GRENIER <grenier@cgsecurity.org> http://www.cgsecurity.org Disk /dev/hdb - 160 GB / 149 GiB - CHS 19457 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 the 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. |
| TestDisk 6.5, Data Recovery Utility, October 2006 Christophe GRENIER <grenier@cgsecurity.org> http://www.cgsecurity.org TestDisk as free software, and comes with ABSOLUTELY NO WARRANTY. Select a media (use Arrow keys, then press Enter): Disk /dev/hda - 160 GB / 149 GiB Disk /dev/hdb - 160 GB / 149 GiB Disk /dev/hdc - 20 MB / 19 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. |
| herman@amdxz:~$ sudo testdisk Password: TestDisk 6.5, Data Recovery Utility, October 2006 Christopher GRENIER <grenier@cgsecurity.org> http://www.cgsecurity.org TestDisk exited normally. You have to reboot for the change to take effect. |
| gparted ~ # testdisk |
| TestDisk 6.6, Data Recovery Utility, February 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, certian types of viruses or human errors. Information gathered during TestDisk use can be recorded for later review. If you choose to create a text file, testdisk.log , it will contain TestDisk options, technical information and various outputs, including any folders/file names TestDisk was used to find and list on screen. Use Arrow keys to select, then press Enter key: [ Create ] Create a new log file [ Append ] Append information to the log file [ No Log ] Don't record anything |
| TestDisk 6.6, Data Recovery Utility, February 2007 Christophe GRENIER <grenier@cgsecurity.org> http://www.cgsecurity.org TestDisk as free software, and comes with ABSOLUTELY NO WARRANTY. Select a media (use Arrow keys, then press Enter): Disk /dev/hda - 60 GB / 55 GiB Disk /dev/hdc - 139 MB / 132 MiB (RO) [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. |
| TestDisk 6.6, Data Recovery Utility, February 2007 Christophe GRENIER <grenier@cgsecurity.org> http://www.cgsecurity.org Disk /dev/hda - 60 GB / 55 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'. |
| TestDisk 6.6, Data Recovery Utility, February 2007 Christophe GRENIER <grenier@cgsecurity.org> http://www.cgsecurity.org Disk /dev/hda - 60 GB / 55 GiB - CHS 7295 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 the 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. |
| Here
is a list of these options and the subsequent options each one offers,
we won't be covering all these in this how-to, only the 'Analyse'
option. But here's a quick look all the stuff TestDisk can do if we wanted, Analyse = Analyse current partition structure and search for lost partitions --> Proceed --> Backup = Save current partition list to backup.log file and proceed --> Proceed --> Quit = Return to Main Menu --> Search = Search Deeper, try to find more partitions --> Write = Write partition table to disk Advanced Filesystem Utils = FAT: Boot and FAT repair NTFS: Boot and MFT repair EXT2/EXT3: Find Backup SuperBlock Geometry = Change disk geometry --> Cylinders = Change cylinder geometry --> Heads = Change head geometry --> Sectors = Change sector geometry --> Sector Size = Change sector size (WARNING: VERY DANGEROUS!) --> Ok = Done with changing geometry Options = Modify options --> Expert mode: Yes/No -Expert mode adds some functionalities --> cylinder boundary: Yes/No/Head boundary only Partitions are aligned on cylinder head boundaries --> Allow partial last cylinder Yes/No --> Dump = Yes/No Dump essential sectors --> Ok = Done with changing options MBR Code = Write TestDisk MBR code to the first sector (similar to fdisk, includes aa55 sig too) --> Write a new copy of MBR code to first sector? (Y/N) Delete = Delete all data in the partition table Quit = Return to disk selection |
| TestDisk 6.6, Data Recovery Utility, February 2007 Christophe GRENIER <grenier@cgsecurity.org> http://www.cgsecurity.org Disk /dev/hda - 60 GB / 55 GiB - CHS 7295 255 63 Current partition structure: Partition Start End Size in sectors check_FAT: Unusual number or reserved sectors 9 (FAT), should be 1. 1 P FAT16 0 1 1 22 254 63 369432 [NO NAME] 2 * Linux 23 0 1 1552 254 63 24579450 [ACER] *=Primary bootable P=Primary L=Logical E=Extended D=Deleted [Proceed ] [ Save ] Try to locate partition |
| TestDisk 6.6, Data Recovery Utility, February 2007 Christophe GRENIER <grenier@cgsecurity.org> http://www.cgsecurity.org Disk /dev/hda - 60 GB / 55 GiB - CHS 7295 255 63 Current partition structure: Partition Start End Size in sectors * FAT16 0 1 1 22 254 63 369432 [PQSERVICE] P FAT32 LBA 23 0 1 1552 254 63 24579450 [ACER] L Linux Swap 1561 1 1 1691 254 63 2104452 P Linux 1692 0 1 7294 254 63 90012195 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 FAT16, 189 MB /180 MiB |
| TestDisk 6.6, Data Recovery Utility, February 2007 Christophe GRENIER <grenier@cgsecurity.org> http://www.cgsecurity.org Disk /dev/hda - 60 GB / 55 GiB - CHS 7295 255 63 Current partition structure: Partition Start End Size in sectors 1 * FAT16 0 1 1 22 254 63 369432 [NO NAME] 2 P FAT32 LBA 23 0 1 1552 254 63 24579450 [ACER] 3 E extended LBA 1553 0 1 1691 254 63 2233035 4 P Linux 1692 0 1 7294 254 63 90012195 5 L Linux Swap 1561 1 1 1691 254 63 2104452 [Quit ] [ Search! ] [ Write ] Search deeper, try to find more partitions |
| TestDisk 6.6, Data Recovery Utility, February 2007 Christophe GRENIER <grenier@cgsecurity.org> http://www.cgsecurity.org Disk /dev/hda - 60 GB / 55 GiB - CHS 7295 255 63 Analyse cylinder 852/7295: 12% check_FAT: Unusual number or reserved sectors 9 (FAT), should be 1. FAT16 >32M 0 1 1 22 254 63 369432 [NO NAME] FAT32 LBA 23 0 1 1552 254 63 24579450 [ACER] FAT32 LBA 23 0 1 1552 254 63 24579450 [ACER] Linux Swap 1561 1 1 1691 254 63 2104452 Linux 1692 0 1 7294 254 63 90012195 FAT32 LBA 2279 0 1 3808 254 63 24579450 [ACER] FAT32 LBA 2279 0 1 3808 254 63 24579450 [ACER] FAT32 LBA 3809 0 1 5338 254 63 24579450 [ACER] FAT32 LBA 3809 0 1 5338 254 63 24579450 [ACER] [ Stop ] |
| TestDisk 6.6, Data Recovery Utility, February 2007 Christophe GRENIER <grenier@cgsecurity.org> http://www.cgsecurity.org Disk /dev/hda - 60 GB / 55 GiB - CHS 7295 255 63 Partition Start End Size in sectors * FAT16 >32M 0 1 1 22 254 63 369432 [NO NAME] P FAT32 LBA 23 0 1 1552 254 63 24579450 [ACER] L Linux Swap 1561 1 1 1691 254 63 2104452 P Linux 1692 0 1 7294 254 63 90012195 D Linux 1692 0 1 7294 254 63 90012195 D FAT32 LBA 2279 0 1 3808 254 63 24579450 [ACER] D FAT32 LBA 3809 0 1 5338 254 63 24579450 [ACER] D FAT16 LBA 7273 0 1 7294 254 63 369596 [ACER_SERVIC] 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 FAT16, 189 MB /180 MiB |