Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

By mistake, I ended up executing rm -rf / command from sudo on my laptop which erased many files before it stopped. Now when I restarted my system , it drops to this prompt:

GRUB rescue>_ 

I am having dual-boot with Ubuntu 12.04 and Windows 7.

I request help for the following questions:

  • How do I fix the currently installed Ubuntu without overwriting/erasing the left over files (from rm -rf command)?

  • Is using boot-repair safe?

  • Is there a way to directly go to Windows 7?

share|improve this question
    
u can try testdisk from a live cd to recover the deleted files –  Karthik T Nov 7 '12 at 3:48
    
Check with a live cd if home is still there. If so: copy those files over to a CD or DVD from the live session. If not you will need to use photorec or testdisk as suggested below. –  Rinzwind Nov 7 '12 at 8:26
    
Reinstallation seems to be your best and perhaps only option. I hope you backed all your data up. I am really sorry for your loss. –  drN Nov 7 '12 at 14:20
add comment

4 Answers

When recursively deleting files starting from the root directory / as sudo there is no way other to recover the state of your OS as it was before than restoring from a backup.

In case you don't have a recent backup at hand you will have to reinstall Ubuntu.

Personal data files from your $HOME directory can be recovered (e.g. with PhotoRec) but take note of the following:

  • Recover these files first. Do not use the drive before you had sucessfully recovered your data to an external storage device.
  • You will have to restore permissions, directories, and filenames manually.

See also:

share|improve this answer
1  
There is no difference between deleting files from your home directory or from the root directory. In both cases, the disk space used for the file is marked as unallocated, and there is a chance that future activity might overwrite the data. So there is the possibility of recovering that data using a tool like PhotoRec. –  Flimm Nov 7 '12 at 15:43
    
@Flimm: I may not have understood you comment correctly but I only posted this additional answer to make exactly the same point, i.e. if you plan to recover files you will have to do that first and you should not use the drive before you succeeded. –  Takkat Nov 7 '12 at 16:02
    
I disagree with the first sentence of your answer ("when recursively deleting files..."). What do you mean by "recover your OS"? –  Flimm Nov 7 '12 at 16:06
add comment

How do I fix the currently installed Ubuntu without overwriting/erasing the left over files (from rm -rf command)?

If you ran rm -rf from the root directory and let it run to completion, you will have a blank partition. Any chance to recover files (see Best tool to recover removed files) would have to be done while running from a LiveCD.

I am assuming you are talking about a ext4 partition. The biggest issue you will have is finding the exact files to restore, as the names of the files will be lost (unlike the FAT32 file recovery). Some of the recovery tools can search for patterns that certain files types have. For example, all jpg files have parts of the file that share a common binary pattern. You can tell a recovery tool to recover files with that pattern. You maybe successful at recovering some files that way, but as for restoring you entire system, your best bet is to reinstall, as you will not be able to provide file names for all of the files that were deleted.

Is using boot-repair safe?

I am not familiar with boot-repair, so I can not give you definitive answer here. Since you have deleted your entire Ubuntu install, I would go with the reinstall.

Is there a way to directly go to Windows 7?

Best way to do this quickly is reinstall Ubuntu, it will fix grub so you can boot windows.

share|improve this answer
add comment

To recover deleted files I recommended using foremost Install foremost.

share|improve this answer
add comment

If you need to recover your documents you can try using photorec or testdisk.

However, if you want to recover the operating system and make it functional again, a clean reinstall is by far the easiest and fastest option.

share|improve this answer
add comment

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.