1

A few days ago I was in a middle of copying or cutting folders and data to my external hard drive and it was corrupted.

I have tried to locate the lost information on Test Disk but I have now lost it because it has already been over written. The file is 0. 0. copy and completed.

I have now only have the image.dd file. How can I restore this to it's normal folders and files without losing the names? Many thanks.

LifeIsATest
  • 27
  • 1
  • 8

1 Answers1

0

Image of a partition

If the image.dd file is an image of a partition (or an iso file), you can easily loop mount it and read the files. Change directory to where you have the file and mount it.

sudo mkdir /mnt/pt1
sudo mount -o loop image.dd /mnt/pt1
cd /mnt/pt1
ls -l *
...

Image of a whole drive

If the image.dd file is an image of a whole drive (a HDD, SSD, pendrive, memory card), it is possible but more complicated to loop mount a partition. You may succeed with kpartx.

In this case it is probably easier to restore from the image file to a drive with at least the same size as the original drive from where it was cloned. Please notice that this drive will be overwritten, so all previous data on it will probably disappear.

You can do that with dd (simple but risky], or with mkusb, which 'wraps a safety belt around dd' by helping you identify the target drive and giving you a final checkpoint.

In Windows there is Win32DiskImager that can also clone with a final checkpoint.

After restoring you can connect the drive,

  • either while running an operating system, and mount the partition(s), browse and read files there,
  • or boot from the drive, if it a system that can boot your computer, and get into its partition(s), browse and read files there.

Edit: See also the following link with details how to use kpartx

sudodus
  • 46,324
  • 5
  • 88
  • 152
  • Thank you very much. Don't know where to start but I try. Do you have any further videos that I can do it? I use linux instead of microsoft. Thank you again. – LifeIsATest Dec 02 '18 at 14:04
  • Thank you very much. Don't know where to start but I try. Do you have any further videos that I can do it? I use linux instead of microsoft. Thank you again. – LifeIsATest Dec 02 '18 at 14:06
  • @JonA, Did you create the image file image.dd? In that case you should know, if it is an image of a partition or of the whole drive. If you don't know, you can test, if you get something useful when trying to mount the image file. Otherwise you can restore from the image file to a drive according to the details in my answer. Good luck :-) – sudodus Dec 02 '18 at 15:08
  • Mount probably doesn't need the "-o loop", it's man page says "The mount command automatically creates a loop device from a regular file if a filesystem type is not specified or the filesystem is known for libblkid". And could ask file what it thinks of the image, it says this about an image containing the first few megs of an MBR device (like /dev/sda): "DOS/MBR boot sector; partition 1 : ID=0x83...; partition 2 :...", and strangely just this about a partition image (like /dev/sda1): "DOS/MBR boot sector" (but I think that disk might be weird). Or could ask gparted or fdisk... – Xen2050 Dec 03 '18 at 10:23
  • @sudodus I tried to sudo mount ~/home/username/Desktop/image.dd /media/disk -t ext3 -o loop still doesnt work. It says. "mount: /media/disk: failed to setup loop device for /home/jonnzen/home/username/Desktop/image.dd." – LifeIsATest Dec 09 '18 at 00:12
  • @sudodus I am not sure how can I mount this from your point of view "sudo mount -o loop image.dd /mnt/pt1 cd /mnt/pt1 ls -l *" – LifeIsATest Dec 09 '18 at 00:13
  • @sudodus I have tried and it still says -------"mount: /mnt/pt1: failed to setup loop device for /home/username/home/jusername/Desktop/image.dd." – LifeIsATest Dec 09 '18 at 00:32
  • I think the path to the image file is wrong. It is easier if you change directory to where you have the file, something like cd ~/Desktop/image.dd and then sudo mount -o loop /media/disk if /media/disk exists, or sudo mount -o loop /mnt/pt1 if /mnt/pt1 exists. – sudodus Dec 09 '18 at 00:33
  • Sorry, there was an error in the previous comment. I forgot the image file. Please try sudo mount -o loop image.dd /media/disk if /media/disk exists, or sudo mount -o loop image.dd /mnt/pt1 if /mnt/pt1 exists. – sudodus Dec 09 '18 at 01:05
  • @LifeIsATest, does it work according to my latest comments? – sudodus Dec 09 '18 at 14:24
  • Heyyy sorry late reply. Haven't been on my laptop for a while...I will get back to it in the next 6 hours. @sudodus thanks again for your help. – LifeIsATest Dec 10 '18 at 01:42