Linux

How To Recover Files From Lost+found

Posted by Weston Ganger on August 05, 2015

My computer crashed and ran fsck but wouldn’t start up anymore. I could only access the tty console, so while trying to backup my files I couldnt find my home folder anymore! But I happened to notice this lost+found folder and got curious. I looked into it and you can restore your files from that folder fairly easily.


# Switch to root
sudo su

file /lost+found/* | grep directory > /tmp/list.dir

Now 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.

It should look something like this:


# /tmp/list.dir

set -v
ls -l \#10104455
ls -l \#10104531
ls -l \#10104536

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


# make it executable
chmod -x /tmp/list.dir

# run the script and redirect the output to a file
./list.dir 1> /tmp/list.out 2>&1

Now you can open /tmp/list.out and see what directorys are waiting to be restored.

If you are looking for your home folder search for ‘Desktop’ or ‘Downloads’ or any name of a folder within the folder you want to recover.

The entries will look similar to this:


# /tmp/dir.out

ls -l \#7733249
total 5704
drwxr-xr-x 2 1002 1002    4096 2010-06-05 13:24 Desktop
drwxr-xr-x 2 1002 1002    4096 2010-04-30 09:15 Documents
drwxr-xr-x 2 1002 1002    4096 2010-04-30 09:15 Downloads
-rw-r--r-- 1 1002 1002     179 2010-04-30 09:14 examples.desktop
drwxr-xr-x 2 1002 1002    4096 2010-04-30 09:15 Music
drwxr-xr-x 2 1002 1002    4096 2010-04-30 09:15 Pictures
drwxr-xr-x 2 1002 1002    4096 2010-04-30 09:15 Public
-rw-r--r-- 1 1002 1002 5794003 2010-05-15 11:00 my.txt
drwxr-xr-x 2 1002 1002    4096 2010-04-30 09:15 Templates
-rw-r--r-- 1 1002 1002    1265 2010-05-20 14:35 weston
drwxrwxr-x 2 1002 1002    4096 2010-05-23 14:57 Ubuntu One
drwxr-xr-x 2 1002 1002    4096 2010-04-30 09:15 Videos

So now I know that my home folder is the file /lost+found/#7733249

So to restore the home folder just mv the folder:


mv /lost+found/#7733249 /home/yourUsername


Related External Links:


Posted in Linux and Tagged with linux lost+found fsck data-recovery 


Need help on your next project or application?

I specialize in Ruby-on-Rails, AngularJS, Javascript, Bootstrap, and Hybrid Mobile Apps with Cordova & Ionic.

Contact Me

Recommended Posts