Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have a Sony VIAO laptop setup as dual boot (Ubuntu 12.10/Windows 7). Since I wanted to try Archlinux, I installed VirtualBox in Ubuntu. To create a bootable USB stick (from the ISO image on my hard drive), I followed the instructions from archlinux installation guide. However, accidentally gave the following command:

sudo dd bs=4M if=/path/to/archlinux.iso of=/dev/sda && sync

Note /dev/sda instead of /dev/sdb. So the MBR was overwritten here. BAD mistake. Did not realise the mistake at that time and tried to install archlinux in the virtualbox (allocated 8GB of disk space), couldn't complete the process and shutdown.

Now, after booting, I get the first screen of the archlinux installation process. df only shows various partitions made during the archlinux installation process of 8GB of the total 320 GB harddisk.

I had not taken any backup of the MBR. Is there a way to restore the MBR or salvage some data?

Devendra

share|improve this question

1 Answer 1

up vote 3 down vote accepted

Sorry, but you had a Sony VIAO laptop set up as dual boot. Here's why: dd didn't overwrite just the MBR (i.e. the first 512B sector) - that would be quite annoying, but still fixable. It also took good part of at least the first partition on your hard drive. Unless you had a very interesting setup with system partitions not at the beginning of the dish, it means that at least one of your OSs is gone, since tha file system structures on its system partition are gone and, what's worse, some data as well. Hence even if you managed to reconstruct the partition layout to the original state and the MBR, you would end up with one working system at most.

Now the imminent question is: "What to do next?" and I take the liberty of giving some suggestions.

If you haven't had any important data on the laptop or have a backup (the first lesson of this Q&A), you may skip to number 2.

  1. Recover data

    A lot depends on whether you were actually using MBR or GPT which has a backup at the end of the disk. In the first case, you'll have to resort to a partition recovery with e.g. Parted Magic probably making use of TestDisk. For GPT the situation should be easier due to the second copy of GPT at the end of the disk. Recovery should be possible with just a (GPT-enabled) partition editor.

    If you can mount all the needed filesystems, then you're done. If not, the other tools shipped with Perted Magic come in handy to help you with recovery.

  2. Re-installation

    There are two main points here.

    1. Do you really need dual-boot? In other words: do you need Windows installed natively, or would a VM do? The main reason I can think of for booting Windows natively is anything GPU and/or memory hungry, typically any 3D software, games and anything that can make use of GPU for something else (these days for example Adobe Photoshop). Unless you are often using these, virtualized Windows should give you the same (or better) overall experience (since you can easily snapshot the system, and if you are concerned with security this gives you one more layer of separation between Windows and the world out there).

    2. No matter what the setup is going to be, always have separate partitions for any user data. If you already had it like this, you had much less to worry about when recovering the data. In any case it is the second lesson anybody should take from this Q&A.

  3. Virtualisation

    If you already have an ISO image on your disk, the easiest way to boot it is to boot a VM with an empty drive and the ISO file as a CDROM. No need to copy anything anywhere.

share|improve this answer
    
I was able to recover my linux data completely. Since Windows partition was at the beginning of the hard disk, I lost all data in that partition. Using testdisk worked like a charm, however, the process was slow and manual. I recovered multiple copies of same files in some instances with the directory structure all mangled up. However, I am amazed at the fact that I was able to rescue 100% of the data using the method outlined in this answer. Needless to say, I have also moved to virtualised windows using virtualbox. –  devendra Nov 22 '13 at 6:56
    
@devendra good to hear that you managed to salvage all important stuff, congratulations! The multiple copies might be explained by the files in question being re-written completely on updates (instead of just being updated in changed places). –  peterph Nov 25 '13 at 23:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.