6

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.

Braiam
  • 35,991
Wandang
  • 271

2 Answers2

7

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!

Tommy
  • 521
  • 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. – user 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
0

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.