ReiserFS Filesystem Recovery
The this is a description of a method for recovering ReiserFS filesystems from failed disks with bad blocks, when other recovery methods (reiserfsck) will not work. For this example, the failed server is called node1 and the bad drive is /dev/hda1
Connect to the server and create an image of the affected disk on the /destination_fs filesystem. Note: the destination filesystem must bebig enough to fit all the data from the affected hard drive.
ssh node1 dd if=/dev/hda1 conv=noerror,sync > /destination_fs/hda1.img
Assign the created image to a virtual device:
losetup /dev/loop0 hda1.img
Re-build the superblock:
reiserfsck --rebuild-sb /dev/loop0
Find contents of missing directories:
reiserfsck --rebuild-tree /dev/loop0
Alternatives to try:
reiserfsck -S --rebuild-tree /dev/loop0
reiserfsck --check --rebuild-tree /dev/loop0
reiserfsck -S --check --rebuild-tree /dev/loop0
Verify contents:
reiserfsck –-check /dev/loop0
Mount the virtual device:
mount /dev/loop0 /mnt
View recovered data:
ls /mnt/lost+found
How to understand the lost+found
filenames. They are numbers of the form XXXXX_YYYYY and I found out
that the first part (i.e.) XXXXX is for the directory inode.
That is, let’s suppose we find a file called 3003_4004 in
/home/lost+found. And we have a user called “foo”, whose files we want
to recover. If we do
ls -i /home
it will show […] 3003 foo […]; gladly telling us that the directory
/home/foo has the inode 3003 and that file 3003_4004 once belonged to
that directory.
Now for an advanced situation: we have a 5005_42 file in
/home/lost+found and there is also a directory called 3003_5005. Well,
from the last paragraph we learned that 3003_5005 belongs to /home/foo.
But WAIT! 5005_42 belongs to the directory 5005! So u can copy 5005_42
into 3003_5005 and then 3003_5005 to /home/foo then, after crawling
into the files/dirs, rename them properly.
I formatted a disk that was reiserfs to fat32 by mistake! Is there any way I can get the data back!!! I am using linux so don’t suggest windows software! PLEASE HELP ASAP!!!
No, formatting a disk just resets the mbr and tells the disk nothing is on it. The data is there. I just am asking for a good program to get it back. Maybe if you used linux you’d notice sometimes devices change like sdc becomes sdd in some caseds when you unplug/plug in devices. So it was trying to format a flash drive but accidentially formatted my hard driive.