i removed all my folders in External disk with cp command

i have a usb external disk mounted as /dev/mdxi . when i type cp ubuntu.iso /dev/mdxi, all my data in my external disk is removed and ubuntu.iso is extracted int my disk.how can i recover my data. i try to use TestDisk with photorec but it can’t find my files.

Hello Devjava - and welcome to the Forum.

I think you are out of luck.
Extracting your ISO files over your data probably means your data is lost…and PhotoRec is really designed for image recovery, anyway.


Hi devjava,

I’m guessing you have an external disk referenced as /dev/mdxi mounted on your filesystem as something like /mnt/mdxi (?!)
(“df” should confirm this)
Copying ubuntu.iso to the mount point should have copied the file to the filesystem on the device and left other files on the device in-tact.
Copying ubuntu.iso to the “device file” effectively copies the contents of ubuntu.iso block for block to your usb device. (rather than unpacking it as-such)
As .iso files are “mountable”, your device (which now sounds like an image copy of ubuntu.iso) should also be mountable, and a copy of ubuntu.iso, block-for-block.

  • as Keith says, I think you may be out of luck …

can i recover the data with on OS LInux live , i think there is a OS used for Forenisc computing . do you kniw a good one.

Ok, so if you accidentally delete a file, what this effectively does is to remove the file name from the file index and mark the space associated with the file as available for use. If you stop using the system at “that” point, i.e. before the space is used up by something else, it’s is generally possible to recover the data. However. What you have done is to replace your data, block for block, with new data, so on the face of it, there is nothing to recover as the data itself has been overwritten - at least for the first couple of G of data,

In terms of “how to the FBI do it?”, overwriting a block on the disk could be analogous with writing something with pencil, erasing it with a rubber, then writing something new on top. What was there has gone, however with the right tools (maybe with some graphite powder etc) it may be possible to see an imprint of what was there and deduce what had previously been written. Now this relates to magnetic storage, not sure how it applies to solid state media, but either way I think it would likely require specialised (physical) tools, be expensive, and unlikely to produce very much that’s usable. As far as I’m aware standard hardware can’t recover overwritten blocks from any type of media.

If you think there may be data you want on the device “after” the first couple of G’s, i.e. the size of the ubuntu ISO, you will need a tool that will scan your device at block level looking for valid file / directory entries … the tool you need really depends on the filesystem that “was” on the device before it was overwritten. Were you using extfs, fat, or something else?

my disk has 320 Go but the iso file has just 1.2 Go so how can i get my other 318 Go data, do you know any software please


You might try using TestDisk recovery software which is free. Look at How to Recover Deleted Files Using TestDisk in Linux for downloading and using it.

In desperation, you could use a professional company such as fieldsdatarecovery. It might not be expensive and their URL is:
Fields Data Recovery - the data recovery experts

I hope it helps you. I’ve not tried either method, so can’t advise on the detail.

hi with TestDisk i find my disk with a good size 320Go . i can get image.dd but all my folders and files name are new it s very hard to reorganize 300 Go. :frowning:

Do you mean that all your files are present but their names have been changed?
And what operating system do you have on your computer?