Score:0

Accidentally used "cp /file /dev/sdb1"

gq flag

I'm about to cry, in need of your help... I'm new to linux. I was trying to copy a Windows10 iso to my external HDD. I wanted to use cp command. I saw that my external HDD was sdb1. So I just used

cp /file /dev/sdb1

Now my 1 TB external Hard disk is messed up.. It looks like a drive size of 5.7 GB with the contents of iso...

I had almost 800GB data on my drive... When I plug it into windows, it is not readable by Windows.. I tried to convert it to NTFS again with convert command in Windows, so I wouldn't lose data, but the convert command said it wouldn't support UDF format...

Can you please, please help me...

ChanganAuto avatar
us flag
The copy command wouldn't do that. `dd` on the other hand would do exactly what you describe. Anyway now you need recovery tools. That is, if you haven't messed with the drive further but you did... Data is most likely lost.
ChanganAuto avatar
us flag
Correction to the above: `cp`*might* have done that because you used device instead of the mount point thus likely replacing it with ISO itself.
sudodus avatar
jp flag
Please run `ls -l /dev/sdb1` and edit your original question to show the result. Indent each line of the output 4 spaces to render it as `code`.
SEWTGIYWTKHNTDS avatar
cn flag
I have used a free data recovery application in situations like this and managed to recover a lot of the data. It runs under ubuntu and I think it was called testdisk. I would connect your disk to a system with lots of space and run this testdisk application. The help in the application is reasonable. I am sure it will recover your data files, although the names of the files will not be recoverable, they will have odd numbers as names.
Score:4
cn flag
raj

With the command you used, you have overwritten the beginning of your external hard disk partition with the copy of the Windows ISO, because you copied directly to device instead of the directory the device was mounted on. Thus you have destroyed the important filesystem structures on your HDD. A specialized data recovery software might help you to recover something from the part of the disk that hasn't been overwritten, but it is not guaranteed in any way. Sadly, your data may be lost.

In the future, never use device names in regular file management commands like cp. If you use a desktop Ubuntu installation, there's rarely need to use device names directly anywhere. When you plugged in your HDD (while it was still OK), it probably got automounted under some directory, something like /media/userid/something. This directory usually should be also automatically opened in a File Manager window. You should have copied the ISO file there and not to /dev/sdb1.

lemnlover avatar
gq flag
I see.. Well, this is how I will learn I guess.. Big mistakes will bring me large amount of experience... Thank you all for your help. This is a great community <3
SEWTGIYWTKHNTDS avatar
cn flag
I have used a free data recovery application in situations like this and managed to recover a lot of the data. It runs under ubuntu and I think it was called test disk. I would connect your disk to a system with lots of space and run this test disk. The help in the application is reasonable. I am sure it will recover your data files, although the names of the files will not be recoverable, they will have numbers.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.