Where did /home go?...

I must be cursed as a blogger. Every time I start writing articles, something stupid happens. This time, my distro-hopping ways have finally caught up with me.

Let's rewind a bit; about a week ago, I decided to change my Linux distro because I wanted to try out what's happening in KDE. I downloaded Neon as it's basically Ubuntu + the latest version of KDE. Upon installing it, I started receiving numerous errors that there were bad sectors on my disk. I could barely login let alone do anything useful. So I went back to the live USB and ran fsck on the drive.

It was at that moment that I knew I royally fscked up. Its solution was to essentially destroy my home directory. Everything I had; gone. No matter! I have a backup folder!... Or rather, had. At some point, I accidentally formatted the drive. After panicking for about 10-15 minutes, I realized I had a backup of my most important files on an external drive. Thankfully, my old backup was there and worked. I didn't regain everything, but I retained my most important files that I can't replace.

Once I calmed down, I learned something interesting. fsck doesn't exactly nuke everything; it tries to recover what it can and inserts the files it can recover into the lost+found folder on your hard drive root. Well, it's not exactly pretty. The folder names are mangled into unreadable names, but you can still recover a fair bit with some bash wizardry.

After learning about the existance of Lost+Found, I ran the following command:

foo@bar:~$ find ../lost+found/ > ~/derp

This basically created a file index for me to go through with vim. There are too many files to manually browse through in terminal, so I created a little index of everything there. And believe it or not, I'd say 98% of my home directory was there. I just had to dig down to the right folder and pick up my stuff.

So if you're ever in the same situation, have a dig down in the lost+found. You'll never know what you'll find. Honestly though, you don't want to end up in this position in the first place. Back up your stuff and make sure your stuff is being backed up on a semi-regular basis. If you don't do that, at least make sure to have copies of your most valuable files on a USB drive or an external drive.