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 was playing around with zip and accidentally deleted my /home/ folder (i wanted to delete home/ which got created by unzipping an archive).

I used rm -r /home/instead of rm -r home/ as root...

Is there anything i can do to restore my /home/ dir?

I am using Debian 6 as a VM on VMWare Player.

Unfortunately I have no backups.

(Obviously I did everything wrong, no backups, root, and using rm -r)

Any help is greatly appreciated!

share|improve this question
    
possible duplicate of Recovering deleted files on fedora –  Mat Sep 25 '12 at 10:50
    
@Mat That duplicate is for an individual file and won't help much for a directory situation. –  Caleb Sep 25 '12 at 11:27
    
@Caleb: yeah, maybe not the best but the answers do list quite a few tools that could do the job. There are quite a few duplicates for this type of question, all in a rats nest of duplicate links. –  Mat Sep 25 '12 at 11:29
    
Hopefully you have learned your lesson - watch what you type and make frequent backups! –  jw013 Sep 25 '12 at 15:19
    
yep i just threw vmplayer away since it does not have a backupfunction while virtualbox has it. everything has been fixed. –  Wandang Sep 26 '12 at 13:57
add comment

2 Answers

up vote 6 down vote accepted

First off - stop the VM or remount the volume as read only:

 mount -o remount,ro /home/

Presuming you are using ext[3,4], you are not lost, but it's not an easy task. The data blocks themselves are not cleared, but the pointers (inodes) are. Most files can be recovered using tools such as photorec . It will identify a file based on it's magic number. ASCII and obscure file formats are thus harder.

Similar software exists, but I haven't tested them:

If you are successful, this link might help you to get files back into order.

Good luck!

share|improve this answer
3  
Also, be very careful with installing new software inside the VM. Anything that writes to the (logical) partition that held the now deleted files is extremely risky, even if it only creates temporary files which are subsequently deleted. –  Michael Kjörling Sep 25 '12 at 11:28
    
thank you very much. i found an old backup (1 month old) on an external hdd which i may be able to use. i will try to backup my actual VM and then recover the work i did in this month. after that i will backup the recovered parts and add them with the old /home/ to get everything mashed together. –  Wandang Sep 25 '12 at 12:07
    
ro /home/ wont work because he cannot find home. am i supposed to set it read only after the remount? –  Wandang Sep 25 '12 at 12:17
    
It might be a different partition setup. Do a 'mount' to see which partitions are in use. You might have to remount root as read only. 'mount -o remount,ro /' –  Tommy Sep 25 '12 at 13:04
    
mount: / is busy maybe i am too dumb. i used it just as you wrote it down with the comma : mount -o remount,ro / –  Wandang Sep 25 '12 at 13:12
add comment

By and large I'm afraid the unix paradigm is that you're expected not to make mistakes like that, or to have backups in place.

You can try recovering some of the files with foremost but I've never had cause to work with it so I don't know how much help it'll be.

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.