Yeah I’m an idiot, let’s get that out of the way first. I’m taking full ownership of this particular screwup. Also, this post may contain obscenities…
So… My computer’s been running slowly recently. I’d installed a whole bunch of stuff, such as gnome, lubuntu and other stuff to try to make it more lightweight. It also had some weird redraw crappiness happening and as I sometimes use this machine for work, where I often need to debug display issues, it wasn’t ideal.
“Fuck it”, thought I, “I’ll do a fresh installation. My /home directory is on another disk anyway so it’ll be as easy as pie.”
(My /home directory is on it’s own disk because I often screw up the OS and need to reinstall, this way I don’t lose anything)
…or so I thought.
Except that I changed computers about a year ago and moved all my old stuff from my other computer onto this one. I never got round to actually doing a /home partition, I just pulled over all my files and wiped the old computer to give to my daughter. I’d forgotten this important fact!
So I grabbed the latest Ubuntu and used the startup disk creator to stick it on a USB stick for the installation. Rebooted and was greeted with the grandness of the Ubuntu installer. This comes with about 5 options such as, install beside existing O/S, upgrade existing to newest(which keeps all files and settings), do a clean install (which overwrites everything on the disk) or something else (which lets you set up your own partitions etc.
I chose, foolishly believing my files were on another disk, clean install.
Bish-bash job done. Ubuntu reboots and I have a nice shiny new, zippy fast O/S. Brilliant! Time to map the /home partition to the right place…
Realisation hits me like a bag of hammers. I’ve not only wiped my entire hard drive, featuring *ALL* of my youngest daughter’s pictures/videos etc as well as about every handy little snippet of code I’ve ever written and my entire localhost apache stuff but I’ve also gone and written to the partition! Any security person will tell you if you want to recover your files, don’t make any changes to the disk, the more you change the more you lose, loosely speaking.
I was impressed by how responsive my computer was though and, being as I’m not a soppy sod I came to terms with the loss fairly quickly. It’s only pictures right. I then made what was possibly the biggest mistake, or at least it felt it at the time, as is often the case time proved this not to be true and it may be the biggest benefit… I told my girlfriend…
Three words were all I needed to hear, three words changed the course of my life for the foreseeable future, three words made it all better…
GET. IT. BACK.
My girlfriend is also a computery person. She writes programs for oil rigs and, since I know I can’t feed her bullshit about how it’s impossible and being that as she’s in oil, she’s rich and powerful and I do what she says… I get it back.
So the first thing I do is stop writing to the disk. I still have the USB disk with the installer on it but this also has a fully functional Ubuntu install on it. One of the gems of Ubuntu this. Rebooting with the USB (after tinkering with the BIOS boot order / hard disk order) had me in that instead. Now I could begin.
First thing needed was some sort of recovery software. I develop web stuff, not low level, disk cylinder reading stuff. I wouldn’t know where to begin. To the googles!
A few searches later and I had the page I needed, thanks to what else but the Ubuntu forums. Well, all but one small issue. I didn’t actually want to rewrite my MBR (what’s explained in that post) I just wanted to get my files back and leave my new Ubuntu install speedy fast. Plus, I was pretty sure that if I did try to get the whole thing back it’d get even more broken than it was at the moment. I’d not just deleted the disk to be recovered but I’d written a new OS to it too! No, I needed something else. Reading on, I found the next post in the thread which said as the guy mentioned, try testdisk and photorec a try. Photorec hmm, what is that?
It’s a little bit of software genius that I’ll forever be indebted to, is what it is.
Essentially it does exactly what I want it to do. It gets files from a scrapped drive and saves them somewhere. I know some of you can already see the flaw here. Where do I save the files? I’m using a USB stick here and I can’t write to the disk being ‘saved’ or it’ll corrupt more stuff! Step in my girlfriend’s 1Tb external hard drive.
I plug that in, unmount it, mkdir a folder on the USB drive called ‘bigdisk’ (easy now!) and mount the disk to that…
I then make a folder on the bigdisk called ‘recoveryhope’ and start up photorec in a terminal…
I clicked through to choose the disk to save (I selected free space only – essentially anything that’s not already been overwritten by the new OS install) and where to save the files found, it’s easy as pie really.
At the time of writing this it’s saved over 850,000 files from the apparently wiped disk and been running for nearly 12 hours. That’s over 850,000 potential security holes just reformatting your disks would leave to a potential purchaser of an old computer etc. Makes you think how easy it is to get data.
I’m not sure how much I’ve lost with my own stupidity or indeed what’s been saved. At this time though it’s looking good that at least *some* potential nights on the couch might now be spent in my bed!
I’ll pre-emptively call this a WIN!