Rescuing and restoring data
Disk Workshop
If you need to use ddrescue
to rescue a whole data storage medium rather than just one partition, you can run fdisk -l copy.img
to see whether the partition table is still present and correct. This gives you a list of all partitions, with the numbers behind the names in the first column matching the respective numbers in the device files.
If you are repairing a disk with the newer GPT (GUID partition table), use gdisk
[3]. You might have to install this tool using the package manager. On Ubuntu, it resides in the gdisk package. The following command:
gdisk -l copy.img
lists partitions in the image.
Finds
If you are missing one or more partitions, you can run TestDisk against the image [4]. This program tries to detect and recover partitions. You will need to install TestDisk [5] using the package manager; on Ubuntu, it resides in the testdisk package. Then, you simply call the tool and pass in the image file with testdisk copy.img
, which takes you to the text-based user interface (Figure 5).
At the top, TestDisk again presents the image file. Make sure that Proceed is highlighted at the bottom and press Enter. Next, you need to let TestDisk know whether the drive uses the modern GPT. In this case, select EFI GPT; otherwise, use Intel. Finally, restart with Analysis.
TestDisk now shows a summary of the current situation in the upper part of the window. Missing or duplicate partitions in the list indicate a defect. In this case, launch Quick Search. TestDisk runs a search and then lists all the partitions it finds (Figure 6). Pressing P lets you look at the files and directories on a partition; the arrow and Enter keys are used for navigation. Pressing Q takes you back to the list of all partitions.
After the tool has tracked down all the partitions, select Write. If you are still missing one or several partitions, select Deeper Search. TestDisk then performs an in-depth analysis, which takes a little longer. It might even reveal ancient partitions that partially overlap. Access the previously missing partition in the list; if in doubt, just guess. Use the arrow keys to make a primary or logical partition from the rediscovered partition. This partition is then restored by TestDisk.
TestDisk ignores all partitions with a D in the first column, so they remain deleted. When you are satisfied, press Enter and write the new partition table with Write. Press Y to confirm the prompt and then press OK to enable the write. Quit lets you go back a menu until TestDisk finally quits.
Choices
To mount the restored partitions, use the package manager to install the kpartx
program, which is part of the multipath-tools package (on Ubuntu, the package goes by the same name) and then point it to the image file:
kpartx -a -v copy.img
The tool now creates a separate device below /dev/mapper
for each partition in the image file. You only have to read the device file for your partition in the information displayed and then mount
(Figure 7):
mount -o loop,ro /dev/mapper/loop0p1 /mnt
The command in this example mounts the first partition (loop0p1
) from the image in the /mnt
subdirectory.
« Previous 1 2 3 4 Next »
Buy this article as PDF
(incl. VAT)