How to Restore files from lost+found - TechCult

How to Restore files from lost+found

How to Restore files from lost+found: The folder entitled /lost+found is where fsck puts fragments of files that it hasn’t been able to attach anywhere in the directory tree. The lost+found directory (not Lost+Found) is a construct used by fsck when there is damage to the filesystem. Files that would normally be lost because of directory corruption would be linked in that filesystem’s lost+found directory by inode number.

How to Restore files from lost+found

1.If you are unable to boot and seeing the screen “Continue to wait; Press S to skip mounting or M for manual recovery” due to file system error in / and /home partitions. Then select the recovery option.

2.Run fsck on both / and /home file systems.

3.If you are having trouble in getting fsck cleared for /home then use:

4.Now you would be able to pass /home from fsck successfully.

5.If you will try mount /home there won’t be any user files excpet lost+found directory. Run “df -h” and you will see that your file system will be using the same space as before the crash because all the files are in the lost+found directory and we are going to recover them.

6.Now in the lost+found folder, you will see that there are a large number of folders without a name and scrutinizing each one will waste so much of your time. So next we should run “file *” to know which type of file we are dealing with.

7.Now let’s filter out the result because we just want the directory to be included in our result. So run “file * | grep directory > /root/list.dir” command.

8.Next, edit /root/list.dir to make it a script to show the list of files in each directory. Edit the file to make it a script using vi, vim, nano. Add set -v to the first line and add ‘ls -l‘ to the beginning of every other line.

9.Now make the file executable then run it and redirect the output to a file:

10.Now search for the file e.g. Desktop in the dir.out output file. The result will be something like this:

11.The above output specified that the home directory is #7733249. Now to restore the home folder just mv the folder:

Linux installation.

Method 2: Use the script to automatically recover files

First, run “sudo -i” or a “sudo su –” and then run the below script which runs on filesystem /dev/sd?? and outputs to /tmp/listing:

That’s it you have successfully learned How to Restore files from lost+found but if you still have any question regarding this article feel free to ask them in the comment’s section.