Score:2

No bootable device after using dd on the wrong disk: how can I save the data

cn flag

When creating a Clonezilla live USB, I mistakenly entered the wrong device name in the dd command:

sudo dd if=/path/to/clonezilla-iso-file of=/dev/sda status=progress

where sda was the laptop's HDD (I was meaning to type sdb which was the USB drive. :(

Undestandbly, after rebooting I get a "No bootable device found".

I tried re-installing Ubuntu (by creating a new Ubuntu 20.04 bootable USB) and hoping that I could install the OS again while not losing any of the data from my HDD. When I go through the installation process I get a "This computer currently has no detected operating systems" and there is no "Reinstall" option which would potentially allow me to keep my data.

Is there a way to recover/access the data on my HDD (well, at least whatever was not overwritten by the dd command)?

Any help would be most welcome!


Update: Using an Ubuntu 20.04 bootable USB, I selected the "Try Ubuntu" option and on the terminal run sudo gdisk -l /dev/sda which gave the following output:

GPT fdisk (gdisk) version 1.0.5

Caution: invalid main GPT header, but valid backup; regenerating main header from backup!

Warning: Invalid CRC on main header data; loaded backup partition table.
Warning! Main and backup partition tables differ! Use the 'c' and 'e' options on the recovery & transformation menu to examine the two tables.

Warning! Main partition table CRC mismatch! Loaded backup partition table instead of main partition table!

Warning! One or more CRCs don't match. You should repair the disk!
Main header: ERROR
Backup header: OK
Main partition table: ERROR
Backup partition table: OK

Partition table scan:
    MBR: MBR only
    BSD: not present
    APM: not present
    GPT: damaged

Found valid MBR and corrupt GPT. Which do you want to use? (Using the GPT MAY permit recover of GPT data.)
 1 - MBR
 2 - GPT
 3 - Create blank GPT

Your answer: 
PonJar avatar
in flag
Most of your data is probably still there except for portions of the disk that have been physically overwritten by the clonezilla iso. I’m no expert on data recovery but it’s generally recommended to clone the drive and work on that copy. Photorec will recover files that still exist (not just photos) but it doesn’t know the original file name so that can be a slow process to find everything. Don’t touch the original disk and research data recovery.
oldfred avatar
cn flag
How large was your ISO file? That amount of data is not recoverable. And it probably overwrote the partition table. Is sda gpt partitioned which has a backup partition table at end of drive? If so, what does this show? `sudo gdisk -l /dev/sda` or does testdisk show any partitions? and as PonJar suggests best to work from a clone of drive.
Yannis avatar
cn flag
@oldfred the ISO file was 306 MB. Since I get a "No bootable device found" when powering on my laptop, I cannot access the terminal to run the gdisk command you suggest.
PonJar avatar
in flag
You need to boot into a live environment (usb or CD/DVD) to run the gdisk command
Yannis avatar
cn flag
@PonJar I run the gdisk command. See updated answer in the OP for the details.
Yannis avatar
cn flag
@oldfred I run the gdisk command. See updated answer in the OP for the details.
oldfred avatar
cn flag
If you have good backup, load the backup gpt partition table & see if it matches what you expect. You may be able to then restore gpt table & run repairs. You will not recover the first 306MB of data, nor restore booting, but then may be able to recover data. More repair info use p, v & w to write the partition table. If not correct just use q to quit. : http://askubuntu.com/questions/386752/fixing-corrupt-backup-gpt-table/386802#386802
Yannis avatar
cn flag
@oldfred According to the output, the backup header and partition table are "OK". I assume these are the ones you mean. How do I load them? The options listed on the link you provided do not have one. Also, how will I know if "it matches what [I] expect"? Also, assuming loading (if you tell me how) works, how will I be able to recover any left data?
oldfred avatar
cn flag
You select 2 per your data posted in question. That should load gpt data. You can always q or quit and nothing should change. You then will probably need to run fsck (e2fsck) on all ext4 partitions. If some other format, not sure which repair tools you may need. http://askubuntu.com/questions/642504/ubuntu-14-04-is-not-booting-normaly-after-a-manual-hard-boot/642789#642789
Yannis avatar
cn flag
@oldfred added more troubleshooting and output in a separate post for clarity: https://askubuntu.com/questions/1376645/retrieve-data-from-disk-after-dd
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.