Disk Recovery Ubuntu Box

The Background

After years of having multiple floppies, SCSI, IDE, SATA, USB drives and sticks kicking around the office I’ve decided it can’t carry on like this. I’ve fallen into the habit of buying the biggest USB disk I could afford to shuffle data back and forth between new and old machines as I nuke and pave my way through life.

I’ve also had numerous requests from family and friends over the years to rebuild machines or recover data for them which has just added to my problem. I always like to have two copies of the data when doing anything like this for security against mistakes (of which there have been a few).

The end result is more disks and sticks kicking around with no order or structure. Every time I’ve started to have a sort out in the past, I’ve always ran out of space or needed the device I was loading disks in for real work.

Whilst having a sort out I have come across an old HP xw4600 workstation which has a ton of space inside, 4 SATA ports and even IDE It isn’t the most powerful on the processor front, but it will be perfect for a box I can use as a dedicated platform for this task.

So after digging through the old disks and finding an empty 120G SSD from some unknown source, I connected it up to SATA0 and started installing Ubuntu Server. Even though I’m planning on doing most of the work on the command line via SSH, I decided to install LightDM and LXDE just incase I needed some GUI tools later.

20 minutes later, I have a box which I can wake up remotely from a so called magic packet. In less than 25 seconds later, I can log in locally through the GUI or remotely via SSH, ideal. Now for some more interesting bits. Obviously as with all devices these days some precautions on the security front should be taken to protect against the evils on the Internet.

The Customisation Journey

I say Journey, as I never seem to get to a fully configured server, but once the basic ubuntu server build is there, I’ll add some tools etc I require. First off I’ll add the usb auto mount functionality as used in the ubuntu desktop variants along with support for NTFS as I know there will be some old MS Windows disks to go through. Finally here I’ll get the testdisk utilities installed which also provides PhotoRec.

jon@moe:~$ sudo apt update && sudo apt install usbmount ntfs-3g testdisk

Now when I plug a USB Device (disk or stick) it gets auto mounted under /dev/usb? somewhere. This just safes me the bother of doing it manually.

I decided to add a GUI as some of the tools I may use in the future may require it. I went for a simple default lxde core.

jon@moe:~$ sudo apt update && sudo apt install lightdm tasksel -y
<snip>
jon@moe:~$ sudo tasksel install Lubuntu-core
<snip>

Data Recovery Example

A grand total of 45 minutes since starting I’ve got a platform built, now with two extra drives connected. A blank data disk, and a drive which was inadvertently formatted that I need to recover data from. Some 3 hours later, and PhotoRec has already recovered 800+ jpg files.

PhotoRec 7.0, Data Recovery Utility, April 2015
Christophe GRENIER <grenier@cgsecurity.org>
http://www.cgsecurity.org

Disk /dev/sdb - 4000 GB / 3726 GiB (RO) - WDC WD40PURZ-85TUZV0
     Partition                  Start        End    Size in sectors
     No partition             0   0  1 486401  80 63 7814037168 [Whole disk]

Pass 1 - Reading sector  439340400/7814037168, 843 files found
Elapsed time 3h47m26s - Estimated time to completion 63h37m39
jpg: 843 recovered

It is now well past half way, according to the disk geometry, but I will let it run through to its conclusion. Just for the record, it didn’t take the estimated 63 hours, it completed overnight.