Linux: file recovery

I desperately need some help regarding problem I am facing now. While creating a softlink for a very important file I gave the reverse command by mistake. Instead of giving it "ln target linkname" I have given it 'ln linkname target'. This has resulted in references pointing to target files are now pointing to links and the actual refernces to target files are lost. How can I recover the files back.

"/home/user/data1" was original file location. "/home/user/db2" was the desired softlink for this data.

I haveto give "ln data1 db2" but I have given 'ln db2 data1'.

This has resulted in 'data1' being now pointing towards 'db2' and the actual data in 'data1' can not be retrieved.

Some one please help.

Thanks in advance.


Solution 1:

Whatever you do, remount that partition read-only, right now. Other writes to the disk might well overwrite your precious file.

After that, try some recovery tools from the other answers.

Solution 2:

You might try using TestDisk:

TestDisk can

  • Undelete files from FAT, NTFS and ext2 filesystem
  • Copy files from deleted FAT, NTFS and ext2/ext3 partitions.

and maybe you will be in luck...

Solution 3:

What filesystem are you using? if EXT3 or EXT4 there is no way (at least i have this info) to restore those files.