Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


[SOLVED] Wiped out MBR accidentally, what to do now?
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

[SOLVED] Wiped out MBR accidentally, what to do now?

sanmax88sanmax88 Member
edited August 2016 in Help

Update: Used testdisk to restore partition table and re-installed grub. Now bootable again! yay!

Kind of a long story, I just wiped out my MBR (and unfortunately on two servers, one is luckily fresh) with


dd if=/dev/zero of=/dev/sda bs=512 count=1000

and I'm afraid to restart my server. Fortunately, this is a backup server (and this server has no RAID)...

What are my options? :(

PS: I sleepily and lazily copy-pasted my command line from my private wiki and foolish of me not to read properly :(

Comments

  • Subscribed ...

    Lets see if anyone comes with a solution....You may never know when you make the same error :-)

  • if your server is still running and you can access your data probably make backups of the content to another server first I know it depends on how much data there is, but that would really be my first thing to do.

    If you need space to put your data to have a look into that lot of storage vps offers around or just ask here with the size of space you need, someone probably can help you out.

    after that probably fill us in with more detail of the used os/bootloader/filesystem etc. ;-)

    has /dev/sda been your root filesystem or /boot only or something like that?

    what is fdisk -l giving?

    was it MBR or GPT?

    parted is very capable of rescuing, at least if you know or can guess the first and last sector...

    Thanked by 1sanmax88
  • That's not just MBR, you probably knocked out inodes from your first partition. Backup whatever you can. DONT USE FDISK - it might force the kernel to flush cache and re-read the partition table.

    http://unix.stackexchange.com/questions/35681/accidentally-deleted-the-partitions-on-my-boot-disk-the-system-is-still-running

    If you are lucky, then your first partition is a /boot with the rest in a separate partition. You could then reconstruct your MBR by copying it from a similar working system, and then rewrite the partition table.

  • ehabehab Member

    after backing up you might be lucky to recreate the mbr and not loose anything

    lsblk

    create the mbr as per-values above or

    cat /proc/partitions

    i use parted.

    Thanked by 2sanmax88 netomx
  • LiteServerLiteServer Member, Patron Provider
    edited August 2016

    In most cases the first part of the drive is being used for the "/boot" partition. In such case the rest of the data should still be fine.
    In case the /boot partition is indeed the first partition on the drive; try if you can copy the data stored on this partition to a temporarily directory on another partition.
    If you're able to copy the content of /boot, recreate the filesystem on this partition (usually ext4) and copy the files back. Reinstall grub afterwards again on the MBR of your HD.

    Before you reboot; make a backup of all other data first

    And as already mentioned. Do not use fdisk or parted at this stage. Reloading the partition tables may knock the partition out.

  • First off, I am puzzled on how one can "accidentally" fill the MBA with useless data.

    Backup everything, don't take chances.

    Thanked by 1sanmax88
  • FranciscoFrancisco Top Host, Host Rep, Veteran

    If you have a boot partition as /dev/sda1 then you're pretty lucky since at most you ate up a few megs and blew out your boot, but you can work from that.

    You can load up testdisk and run a recovery against /dev/sda to find partition boundries and then have it write them in place.

    Now if you have a single fat root drive where /boot also is, then you're likely in a bit of a mess and should just pull backups.

    Francisco

    Thanked by 2sanmax88 netomx
  • First, thank you guys for these information!

    Server is using Centos 6.x with 2x2TB disks with GRUB bootloader, ext4 filesystem and using LVM.

    Partitions as follow:


    NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
    sda 8:0 0 1.8T 0 disk
    ├─sda1 8:1 0 250M 0 part /boot
    └─sda2 8:2 0 1.8T 0 part
    ├─vg-root (dm-0) 253:0 0 3.6T 0 lvm /
    └─vg-tmp (dm-2) 253:2 0 91G 0 lvm /tmp
    sdb 8:16 0 1.8T 0 disk
    └─sdb1 8:17 0 1.8T 0 part
    ├─vg-root (dm-0) 253:0 0 3.6T 0 lvm /
    ├─vg-swap (dm-1) 253:1 0 7.8G 0 lvm [SWAP]
    └─vg-tmp (dm-2) 253:2 0 91G 0 lvm /tmp

    /boot is still there, files are intact and yes it's on a separate partition (/dev/sda1).

    Now, I'm checking how to move forward the best :)


    @FlamesRunner quite a funny story, I was trying to do a simple i/o check on the other server which is new. i copy-pasted my command line from my wiki (AND WITHOUT READING sadly, searched "dd" on my wiki pages) and used it. I wondered why an SSD drive only returned 55mb/s and decided to try on another server to compare (with HDD). Then I realized, I was on my wiki page on how to reset MBR for when server has conflicting grub prompt issues. I regret not being fully aware. And so here we are.

  • Update: Used testdisk to restore partition table and re-installed grub. Now bootable again! yay!

  • FranciscoFrancisco Top Host, Host Rep, Veteran

    :)

    Francisco

Sign In or Register to comment.