Page 1 of 3 123 LastLast
Results 1 to 10 of 26

Thread: Catastrophe - Used dd command for wrong drive

  1. #1
    Join Date
    Jan 2013
    Location
    India
    Posts
    316

    Unhappy Catastrophe - Used dd command for wrong drive

    I had booted into openSUSE 42.2 and used dd command to create live usb

    Code:
    sudo dd if=/path/to/file of=/dev/sdb
    But it turns out that sdb was the Hard Disk and the Pen Drive was sda. So in a way I've overwritten my internal hard disk.

    After rebooting my system, it boots into live mode.

    The Current Partition Structure


    As you can see only first 1.5 GB has been over-written. The remaining disk is unallocated. (Total size of Hard Disk is 1 TB)

    How do I recover the remaining Hard Drive?

    The previous partition structure was (as far as I can remember)
    Few Hundred MBs of Windows Recovery Partition
    EFI Partition
    150 GB C Drive - Windows Partition - NTFS
    450 GB D Drive - Data Drive (Common for all OS installed) - NTFS
    8 GB swap volume
    80 GB - cent os root partition - ext 4
    60 GB - openSUSE root partition - ext 4

    I'm interested to recover 450 GB Data Drive (which has got very important files)

    I'm planning to use GParted Live Disc and ddrescue to recover data. Any other method?

    This thread https://bbs.archlinux.org/viewtopic.php?id=102642 talks about using ddrescue to rescue data.

    I don't have any backup
    6 years of using linux, countless number of installations and I've done such a blunder.
    Acer V3-571G - openSUSE Leap 42.2; Windows 10 Pro

  2. #2
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    22,131

    Default Re: Catastrophe - Used dd command for wrong drive

    I do not know where you got that "Current Partition Structure" from (it would be better to boot from some live/rescue system and do and
    Code:
    fdisk -l
    instead of showing some window of an unknown tool).

    But that picture doesn't show what you say it should show. You say you have 6 partitions, there are only 2 in the picture.

    Of course the partitions table is overwritten. thus how did the tool find those 2 partitions?
    When this is a GPT partitioned disk (which I assume, because you using EFI and those two often are connected), then there is a rescue partition table at the end of the disk. And that may explain why the tool sees something. But what it sees is not what you say.

    OTOH the dd has overwritten the partition table with the first block of /path/to/file. And it might be possible that that is interpreted by the tool into what it shows.

    All very confusing.

    When you are mainly interested in the contents of the 450 GB partition, you could create a partition table that points exactly to the start end end points of that partition. That would make it usable again. But, taking into account your laziness in making even data backups, I guess you do not have a backup (or manual notes) about your partition tables.

    WHEN (and mark what I say, WHEN) the partition information you show is in fact that from the file (and thus fake) and WHEN this is GPT, then there might be some tool to recover the partition table from the one at the end of the disk (I guess there is such a tool, else having that backup is useless). In that case you would afterwards be able to mount the important NTFS on a rescue system and copy files from it.

    6 years of using linux, countless number of installations and I've done such a blunder.
    I think at least two blunders. The first one when you decided not to make backups of material you now classify as "very important files" and the second by not check and re-check your dd statement.
    Last edited by hcvv; 16-Apr-2017 at 08:01.
    Henk van Velden

  3. #3
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    22,131

    Default Re: Catastrophe - Used dd command for wrong drive

    I ventured a bit further.

    Again WHEN this is a GPT disk, tthe tool to be used to recover your GPT from the "secondary GPT" seems to be gdisk (not a surprise).

    From the "recovery & transformation menu" (to be reached with the r command from the main menu) there is the b command:
    b
    Rebuild GPT header from backup. You can use the backup GPT header to rebuild the main GPT header with this option. It's likely to be useful if your main GPT header was damaged or destroyed (say, by sloppy use of dd).
    (the bold is mine, pun as intended).
    Henk van Velden

  4. #4
    Join Date
    Jan 2013
    Location
    India
    Posts
    316

    Post Re: Catastrophe - Used dd command for wrong drive

    Quote Originally Posted by hcvv View Post
    I do not know where you got that "Current Partition Structure" from
    it's from gparted while booting into livecd

    But that picture doesn't show what you say it should show. You say you have 6 partitions, there are only 2 in the picture.
    There were 6 partitions before performing dd operation. The partition structure you are seeing right now is result of dd.

    Actually I was trying to create a live usb using command. The mistake I did was that sda will be hard disk by default and sdb will be pen drive. But this time it was other way around.

    The command I used
    Code:
    dd if=/run/media/avish/DATA/Softwares/OS/Linux/openSUSE.iso of=/dev/sdb bs=2M
    Acer V3-571G - openSUSE Leap 42.2; Windows 10 Pro

  5. #5
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    22,131

    Default Re: Catastrophe - Used dd command for wrong drive

    Quote Originally Posted by vishy View Post
    it's from gparted while booting into livecd


    There were 6 partitions before performing dd operation. The partition structure you are seeing right now is result of dd.
    As I suggested above.
    Quote Originally Posted by vishy View Post
    Actually I was trying to create a live usb using command. The mistake I did was that sda will be hard disk by default and sdb will be pen drive. But this time it was other way around.
    You already explained that in your first post.
    Quote Originally Posted by vishy View Post
    The command I used
    Code:
    dd if=/run/media/avish/DATA/Softwares/OS/Linux/openSUSE.iso of=/dev/sdb bs=2M
    Also from another removable mass-storage device mounted on /run/media/avish/DATA?
    Having several removable devices on your system at the same time makes human confusion more likely


    The important thing is if it is a GPT disk. In that case I offered you a path that may lead to recovery of the partitions untouched by the overwriting.
    Henk van Velden

  6. #6
    Join Date
    Aug 2010
    Location
    Chicago suburbs
    Posts
    9,164
    Blog Entries
    3

    Default Re: Catastrophe - Used dd command for wrong drive

    My "for the record" comment.

    When I plan on writing the install iso to a USB:

    (1) ls -ltr /dev/sd?

    The last line should be the most recently plugged in USB. On this computer, it is usually "/dev/sdd".


    (2) fdisk -l /dev/sdd

    That's an additional check to make sure that I am looking at the device that I think I am looking at.

    And then, finally, I copy

    (3) dd_rescue iso-file-name /dev/sdd
    opensuse Leap 42.3; KDE Plasma 5;
    opensuse tumbleweed; KDE Plasma 5 (test system);

  7. #7
    Join Date
    Nov 2009
    Location
    West Virginia Sector 9
    Posts
    14,533

    Default Re: Catastrophe - Used dd command for wrong drive

    Never rely on /dev/sdX syntax order it can and does change with drive additions/subtractions. I always use fdisk -l to be sure of the drive order before doing any mass copy operation.

  8. #8
    Join Date
    Jan 2013
    Location
    India
    Posts
    316

    Post Re: Catastrophe - Used dd command for wrong drive

    Quote Originally Posted by hcvv View Post
    Code:
    fdisk -l
    instead of showing some window of an unknown tool
    Code:
    sudo fdisk -l
    Disk /dev/loop0: 1.5 GiB, 1553670144 bytes, 3034512 sectors
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    
    
    Disk /dev/sda: 698.7 GiB, 750156374016 bytes, 1465149168 sectors
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 4096 bytes
    I/O size (minimum/optimal): 4096 bytes / 4096 bytes
    Disklabel type: dos
    Disk identifier: 0x1a18f9d9
    
    Device     Boot   Start     End Sectors  Size Id Type
    /dev/sda1  *          0 3175391 3175392  1.5G  0 Empty
    /dev/sda2       3117376 3121983    4608  2.3M ef EFI (FAT-12/16/32)
    
    
    
    
    Disk /dev/sdb: 14.8 GiB, 15854469120 bytes, 30965760 sectors
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disklabel type: dos
    Disk identifier: 0x1b571474
    
    Device     Boot   Start     End Sectors  Size Id Type
    /dev/sdb1  *          0 3142655 3142656  1.5G  0 Empty
    /dev/sdb2       3118960 3123567    4608  2.3M ef EFI (FAT-12/16/32)
    What do I do now?
    Acer V3-571G - openSUSE Leap 42.2; Windows 10 Pro

  9. #9
    Join Date
    Jan 2013
    Location
    India
    Posts
    316

    Post Re: Catastrophe - Used dd command for wrong drive

    Quote Originally Posted by hcvv View Post
    Also from another removable mass-storage device mounted on /run/media/avish/DATA?
    Having several removable devices on your system at the same time makes human confusion more likely
    Not another removable mass storage media, it's a partition of internal hard disk.

    [
    Quote Originally Posted by hcvv View Post
    The important thing is if it is a GPT disk. In that case I offered you a path that may lead to recovery of the partitions untouched by the overwriting.
    Yes the internal hard drive is GPT disk
    Acer V3-571G - openSUSE Leap 42.2; Windows 10 Pro

  10. #10
    Join Date
    Jan 2013
    Location
    India
    Posts
    316

    Post Re: Catastrophe - Used dd command for wrong drive

    Quote Originally Posted by vishy View Post
    Code:
    sudo fdisk -l
    Disk /dev/loop0: 1.5 GiB, 1553670144 bytes, 3034512 sectors
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    
    
    Disk /dev/sda: 698.7 GiB, 750156374016 bytes, 1465149168 sectors
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 4096 bytes
    I/O size (minimum/optimal): 4096 bytes / 4096 bytes
    Disklabel type: dos
    Disk identifier: 0x1a18f9d9
    
    Device     Boot   Start     End Sectors  Size Id Type
    /dev/sda1  *          0 3175391 3175392  1.5G  0 Empty
    /dev/sda2       3117376 3121983    4608  2.3M ef EFI (FAT-12/16/32)
    
    
    
    
    Disk /dev/sdb: 14.8 GiB, 15854469120 bytes, 30965760 sectors
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disklabel type: dos
    Disk identifier: 0x1b571474
    
    Device     Boot   Start     End Sectors  Size Id Type
    /dev/sdb1  *          0 3142655 3142656  1.5G  0 Empty
    /dev/sdb2       3118960 3123567    4608  2.3M ef EFI (FAT-12/16/32)
    What do I do now?
    To avoid confusion in the above code, sda is internal hard disk and sdb is external usb running Ubuntu live (didn't opensuse live right now)
    Acer V3-571G - openSUSE Leap 42.2; Windows 10 Pro

Page 1 of 3 123 LastLast

Tags for this Thread

Posting Permissions

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