LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (https://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   Undeleting /home/$username on ext3 (https://www.linuxquestions.org/questions/linux-hardware-18/undeleting-home-%24username-on-ext3-567653/)

Sangaho 07-08-2007 03:56 PM

Undeleting /home/$username on ext3
 
Hi,

I have the following problem: I wanted to create a kde-devel account on a different partition than the one my system (Ubuntu Feisty) is installed on. So I mounted the partition as /media/dev7, and then did a
Code:

sudo mount /media/dev7 /home --bind
Not knowing what I just did, I added a new user "kde-devel" and created the new home dir in /home/kde-devel, not noticing that my own one (/home/joh) was gone...
So, after some time, I did notice it, and looked for a tool to recover folders on ext3. Apparently, it's not possible since ext3 completely zeroes out the files and folders, instead of just marking them as free space on the hdd.
But in my case, I did not use "rm".
I could figure out the inodes of all the (now invisible) folders, including /home/joh, and all the subdirs using a little tool called "giis", even though it's only able to recover files deleted after the installation.

Is there a way to undelete/recover a folder if I know its inode?

Joh

macemoneta 07-08-2007 05:02 PM

Restore from backup. If you don't take backups, now you know why you need to.

jay73 07-08-2007 05:24 PM

I guess all you can do is get photorec. If it's your personal data you're after, you should find it quite reliable (although far from perfect with multimedia files as I found out). It doesn't recover folders, only individual files. The original names are lost so there will be quite a bit of sorting if you had many files; on the other hand, photorec allows specifying the exact sort of files you need to recover. And yes, ext3 is a bit problematic in such a case but it's usually not as bad as it sounds.

rupertwh 07-08-2007 06:21 PM

Quote:

Originally Posted by Sangaho
Is there a way to undelete/recover a folder if I know its inode?

The way I understand you, your files have not been deleted at all. You just mounted another partition on top of them. If you unmount your current /home, the old files will be accessible again. Move them to a temporary directory (outside /home obviously), then remount /home.

stress_junkie 07-08-2007 06:52 PM

Quote:

Originally Posted by rupertwh
The way I understand you, your files have not been deleted at all. You just mounted another partition on top of them. If you unmount your current /home, the old files will be accessible again. Move them to a temporary directory (outside /home obviously), then remount /home.

I think you're right. It sounds like the original /home directory contents are hiding under the mounted partition.

jschiwal 07-08-2007 07:10 PM

Yes, rupertwh is correct. The kde-devel account doesn't need to have its home directory under /home. You could have a /home2 directory and use that. As long as the /etc/passwd entry has /home2/kde-devel as the homepage, it would be fine.

Sangaho 07-09-2007 08:12 AM

You were all right. I just rebooted the computer and everything was fine again. Puhh.. :D
Thanks for your help!


All times are GMT -5. The time now is 05:24 PM.