LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-26-2015, 04:53 AM   #1
Hunty
LQ Newbie
 
Registered: Sep 2015
Posts: 17

Rep: Reputation: Disabled
Exclamation dd command


Hi All

I am a newbie and ran the dd backup command in windows 10 to backup a hard drive.After 5 min I pressed ctrl c
because I thought nothing was running.The whole file structure is wiped and when trying to recover I got fuse_hidden files but with completely different file names.Running photorec the files have been retreived but with 885 recup_directories and f112434.txt,f112434 etc.It is doing this now for every ectension .pdf.jpg.mp4 and there is almost 400g worth of data and trying to work through this is going to take months just to rename it to the right document.Is there a way I can maybe reverse the dd command to restore everything and the right file structures and naming conventions with regards to the file?
Any help will be highly appreciated.

Thanks
Hunty
 
Old 10-26-2015, 05:16 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,850

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
I'm afraid you did overwrite the content of the disk, there is no way to revert it back unless you have a copy or backup.
 
Old 10-26-2015, 05:33 AM   #3
Hunty
LQ Newbie
 
Registered: Sep 2015
Posts: 17

Original Poster
Rep: Reputation: Disabled
Hi pan.Sda1,sda2 and sda3 was on this drive.After running the dd if=/dev/sda of=/dev/sdb command I pressed control C as I was under the impression that nothing was running.sda1,sda2 are ok but sda3 are there but all the files are gone.
Tx
Hunty
 
Old 10-26-2015, 05:35 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,850

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
that will not help to go further. what will fdisk -l respond?
 
Old 10-26-2015, 05:41 AM   #5
Hunty
LQ Newbie
 
Registered: Sep 2015
Posts: 17

Original Poster
Rep: Reputation: Disabled
/dev/sda1 * 2048 206847 204800 100M 7 HPFS/NTFS/exFAT
/dev/sda2 206848 209717247 209510400 99.9G 7 HPFS/NTFS/exFAT
/dev/sda3 209717248 976756719 767039472 365.8G 7 HPFS/NTFS/exFAT
 
Old 10-26-2015, 05:49 AM   #6
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,850

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
dd if=/dev/sda of=/dev/sdb will copy the whole disk (not partitions) from the first one to the second one (if exists). I do not know what have you really tried because this command will not modify anything on sda1, sda2 and sda3 (not able to do that)
 
Old 10-26-2015, 06:17 AM   #7
Hunty
LQ Newbie
 
Registered: Sep 2015
Posts: 17

Original Poster
Rep: Reputation: Disabled
Is there any way I can sort of rebuild the partitions table and try to recover the files with its naming conventions in tact as all i get now is the fuse_hidden files and when running photorec i get alot of files back but with different naming conventions f1 f2 f3 etc.
Thanks for the help thus far
Hunty
 
Old 10-26-2015, 06:37 AM   #8
goumba
Senior Member
 
Registered: Dec 2009
Location: New Jersey, USA
Distribution: Fedora, OpenSUSE, FreeBSD, OpenBSD, macOS (hack). Past: Debian, Arch, RedHat (pre-RHEL).
Posts: 1,335
Blog Entries: 7

Rep: Reputation: 402Reputation: 402Reputation: 402Reputation: 402Reputation: 402
Nope, if you borked the filesystem's file table, then those filenames are probably gone.

[b]testdisk[/] MAY be able to restore the partition table from a backup.

Then, you MAY be able to use the filesystem's scanning and recovery tools (chkdsk for Win fsck for Linux) to restore a backup table .

I stress MAY, as in you MAY get LUCKY. Good luck, you'll need a lot of it.

Otherwise you're going to have to be content with photorec's recovery efforts. Now you've learned to be more careful with dd for sure. Don't worry we've all been there at some point or another. It's a painfil learning experience.

Last edited by goumba; 10-26-2015 at 06:39 AM.
 
Old 10-26-2015, 07:28 AM   #9
maples
Member
 
Registered: Oct 2013
Location: IN, USA
Distribution: Arch, Debian Jessie
Posts: 814

Rep: Reputation: 265Reputation: 265Reputation: 265
Quote:
Originally Posted by goumba View Post
Now you've learned to be more careful with dd for sure. Don't worry we've all been there at some point or another. It's a painfil learning experience.
The other day, I was messing with Conky and wanted to see how it responded to a higher CPU load. So I wanted to run "dd if=/dev/zero of=/dev/null", but I somehow ended up typing "of=/dev/sda". Thank God that normal users can't write to block devices...
 
Old 10-26-2015, 07:32 AM   #10
hortageno
Member
 
Registered: Aug 2015
Distribution: Ubuntu 22.04 LTS
Posts: 240

Rep: Reputation: 67
I still fail to see where your problem is. Did you mix up sda and sdb when running the dd command?

I think you're looking at the wrong disk. dd never writes to the source, it writes only to the destination. When you say that sda1 and sda2 are ok and the files on sda3 are gone, it sounds to me that this was the destination of your dd command. When you interrupted it, sda1 and sda2 were finished and sda3 was in progress. So look at the other disk, all your files should be there. If so, then re-run the dd command and let it finish. If you want to see the progress of dd, have a look here


Note: When you run dd you ALWAYS have to double check that you write to the right disk. the names can change depending on what SATA port they are connected to.
 
Old 10-26-2015, 07:38 AM   #11
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,128

Rep: Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121
Do not use dd.
End of discussion.

It's a good tool for what it is designed to do, but the user community just ain't up to the game. Making backups ain't what it should be used for - much better options exist.
 
Old 10-26-2015, 07:41 AM   #12
Hunty
LQ Newbie
 
Registered: Sep 2015
Posts: 17

Original Poster
Rep: Reputation: Disabled
Hi
Thanks for the information.
Appreciated.
Hunty
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] timestamp of command history doesn't show time command was executed? UprLftCstr Linux - Newbie 3 04-17-2014 12:31 PM
cygwin simple tar command fails when issues on command line deannad Linux - General 1 06-12-2013 10:22 AM
Command/Script required to send an email alert in case command will not respond rajaniyer123 Linux - General 1 05-19-2012 01:12 PM
Executing shell command from JSP file with command line arg from URL orcusomega Programming 2 01-13-2012 03:38 PM
Bash Command Line Editor, while typing run another command before executing current? gumaheru Linux - General 5 04-13-2010 11:21 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:56 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration