You are not logged in.

#1 2012-08-03 11:07:55

ytj
Member
Registered: 2010-11-14
Posts: 24

What should I do after clean first 200mb data in /dev/sda by mistake?

Hello, all:

Just right now, I intent to exec ``dd if=/dev/zero of=/dev/sdb`` to test the
speed of my new usb disk. However, I made a mistake, ran ``dd if=/dev/zero
of=/dev/sda``. When I realized what I have done, I typed Ctrl-C, it reported
that it written 200MB in /dev/sda. Now my partition table is missing, maybe MBR.
I get panic and dare not reboot my computer.
I remenber before I destroyed the partition table, the partitions are::

/dev/sda
/dev/sda1 ext2 100MB (mount on /boot)
/dev/sda2 ntfs 20GB (for Windows, have no important data)
/dev/sda3 ntfs 100GB (for windows, have no important data)
/dev/sda5 ext4 400GB (mount on /)
/dev/sda6 swap 5GB

I think the root directory have not got damage.
My system looks OK right now, Just no files in /boot.
How can I recover the partition table and /boot?

Last edited by ytj (2012-08-03 11:17:13)

Offline

#2 2012-08-03 11:50:41

DSpider
Member
From: Romania
Registered: 2009-08-23
Posts: 2,273

Re: What should I do after clean first 200mb data in /dev/sda by mistake?

Off the top of my head, I would use TestDisk (from, say, Parted Magic) to scan and try to recover the partitions - except for sda1 and sda2 which are probably toast. So I think you will need to create another 100 MB ext2 and another 20 GB NTFS in their place, reinstall Windows, chroot into Arch, reinstall the linux package, re-generate the initramfs then reinstall a bootloader (GRUB or Syslinux) along with its updated config file.

Have fun.


Heed the warnings next time.


"How to Succeed with Linux"

I have made a personal commitment not to reply in topics that start with a lowercase letter. Proper grammar and punctuation is a sign of respect, and if you do not show any, you will NOT receive any help (at least not from me).

Offline

#3 2012-08-03 11:50:46

Awebb
Member
Registered: 2010-05-06
Posts: 6,688

Re: What should I do after clean first 200mb data in /dev/sda by mistake?

Have a look at testdisk and photorec.

Offline

#4 2012-08-03 12:25:03

DSpider
Member
From: Romania
Registered: 2009-08-23
Posts: 2,273

Re: What should I do after clean first 200mb data in /dev/sda by mistake?

I used "dd" once to write the Syslinux "mbr.bin" file to an NTFS partition by mistake, (thus wiping the first 440 bytes) and if I remember correctly, TestDisk mentioned something about a backup BS (boot sector) for NTFS partitions at the end of the partition, something along the lines of "even if the partition doesn't have a bootloader installed, NTFS partitions still need a boot sector".

So you may be able to restore your Windows too... Of course, Windows may not boot anymore (or boot with unexpected consequences) because you overwritten some of the files from the beginning of the partition, but it may be enough to mount it and salvage something, for example, from the desktop, before reinstalling Windows.

Last edited by DSpider (2012-08-03 12:26:29)


"How to Succeed with Linux"

I have made a personal commitment not to reply in topics that start with a lowercase letter. Proper grammar and punctuation is a sign of respect, and if you do not show any, you will NOT receive any help (at least not from me).

Offline

#5 2012-08-03 12:41:44

ytj
Member
Registered: 2010-11-14
Posts: 24

Re: What should I do after clean first 200mb data in /dev/sda by mistake?

Thanks for replies, now I am trying to use TestDisk to recover my partition table.
It seems would take a long time.

I just umount /boot and comment /boot in /etc/fstab. So I could set /boot in my system disk.
But there is one issue, after I reinstall linux and grub-bios, I tried to fix MBR and I got::

[ytj@localhost ~]$ sudo grub-install  /dev/mapper/pdc_fedjgjhg
Path `/boot/grub' is not readable by GRUB on boot. Installation is impossible. Aborting.

One thing I didn't mention is that I use a RAID-0 (So I lost 400MB in fact smile
``modprobe dm-mod`` did not help.

Any suggestion?

Last edited by ytj (2012-08-03 12:42:17)

Offline

#6 2012-08-03 13:46:06

Awebb
Member
Registered: 2010-05-06
Posts: 6,688

Re: What should I do after clean first 200mb data in /dev/sda by mistake?

I just found this: http://linuxers.org/howto/how-recover-a-lost-partition
It uses parted.

Offline

#7 2012-08-03 18:22:11

piratebill
Member
From: Sol System
Registered: 2011-10-20
Posts: 145

Re: What should I do after clean first 200mb data in /dev/sda by mistake?

Recovery programs wont be able to recover the missing data in the partitions (they rely on the data still being on disk, dd wiped that out).  Testdisk may be able to see where the partitions were and recover the table, but the data in them are gone.  You will need to recreate /boot. I hope you had backups.


And Awebb, congrats on "1337" number of posts tongue

Last edited by piratebill (2012-08-03 18:28:09)

Offline

#8 2012-08-08 16:29:28

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,734
Website

Re: What should I do after clean first 200mb data in /dev/sda by mistake?

Beyond the suggestions already posted, I think you're FUBAR.  Let this be a lesson to others to have air tight backup strategy.

Offline

Board footer

Powered by FluxBB