Find the answer to your Linux question:
Results 1 to 5 of 5
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Repair partially overwritten partition (dd accident)


    Hi there,

    I made a stupid mistake tonight and dd'd roughly 500mg of the windows iso file I was trying to flash to my 900GB home partition instead of a usb drive.

    As a result, my home partition shows up as undefined in gparted (from a live cd). I was wondering if there is any hope of recovering my data? I believe (80% sure) that my home partition was originally ext4.

    Maybe there is a way to manually overwrite the first part of the partition with blank ext4 data so that we can recreate whatever headers or meta data is needed?

    Just to clarify, unlike some of the similar questions on this topic, I did not overwrite using dd from the beginning of my hard disk. The partition table, etc I think is fine so it is only the actual /home partition which is damaged.

    I have tried testdisk and fsck but I am a bit out of my depth on this!

    Thanks a lot,
    Max

  2. #2
    Linux Guru Segfault's Avatar
    Join Date
    Jun 2008
    Location
    Acadiana
    Posts
    2,185
    Quote Originally Posted by slidon View Post
    Hi there,

    I made a stupid mistake tonight and dd'd roughly 500mg of the windows iso file I was trying to flash to my 900GB home partition instead of a usb drive.

    500 milligrams of ISO file? Never seen this one before, mb (millibars) is quite usual illiteracy, but milligrams ...
    Anyhow, in Linux filesystems files are not written in one big piece, they are spread all over as it is optimized to the disk geometry. So you better restore from backup.

  3. #3
    Sorry for the confusion, I mean 500MB e.g. 500 megabytes of data. I was quite tired and frustrated at the tume :P

    I started copying data from the iso file to my hard drive before realising my mistake and killing the command (roughly 1/2 a gigabyte through the transfere).

    Are you sure that there is no way whatsoever of recovering? It is only partially backed up and I was hoping there was a chance to at least retrieve some of the data.

    Does this relate to the superblock? I am not sure how much of the meta data which I deleted is contained in the superblock but apparently copies are kept at the end of the partition.

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Guru
    Join Date
    Dec 2013
    Posts
    2,747
    sildon, it's quite literally fµcked.

    if you know 100% that only one partition is affected, do this:

    • clone the partition: unmount it first, then use dd (or cp) to copy it over: dd if=/dev/sdbroken1 of=/mnt/externalbackup - where externalbackup is a second storage that is at least as large as the aprtition to be cloned.
    • use testdisk to recover as much data as possible. the first 500MB are LOST, but beyond that there's hope. i know, testdisk is a little tricky to use (but they have a good wiki). that's why i STRONGLY recommend to work ONLY on the backup.

  6. #5
    -->
    Ok thanks for putting it concisely :P

    I guess I will start again from an older backup and hopefully learn my lesson about messing with dd.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •