Andy Regan Ramblings of an Irish Sysadmin

28Feb/090

Recovering Files From an Unmountable USB Key

The other night, myself and Rory managed to recover his friend's thesis from a wonky USB thumb drive. We used PhotoRec on Ubuntu Linux. PhotoRec comes with the TestDisk utility. You can install TestDisk via:


$apt-get update
$apt-get install testdisk

The first thing we did was run dmesg in a terminal to get a bit of info on what was going on. We ran dmesg before and after we plugged in the drive and noted the relevant output. The device eventually settled and was given the device location sdb by the kernel, but no filesystem was found.
The partition was likely corrupted somehow.

TestDisk could be used to try to repair the partition on the disk, but it could also damage the data further. We decided to make an image to work with using dd:


$sudo dd if=/dev/sdb ou=./disk_image

Use dd with care! Consult the man page for more info.

This copied the contents of the usb key block-by-block to a file called "disk_image". The was a 2G image (the total capacity) of the wonky drive.

We then used photorec to try to recover any files from the image.


$photorec ./disk_image

Et voila! PhotoRec worked its magic and we recovered the thesis, along with all the other files.

26Feb/093

Webcam Motion Detection in Ubuntu Linux

I bought a cheap usb webcam to add to the list of devices for my fyp. The idea is to push presence updates when motion is detected. I'll be using Motion to handle motion detection. Detailed installation and configuration instructions can be found at InfectedProject.

You can set motion to run commands when certain events happen, such as an image is saved or a movie ends. For example, you could add the following to /etc/motion/motion.conf so that you get an email to you're email account when a movie ends.


# Command to be executed when a movie file (.mpg|.avi) is closed. (default: none)
# To give the filename as an argument to a command append it with %f
on_movie_end echo %f | mutt -s "[Motion]" -a %f joe@bloggs.com

25Feb/090

Installing Subclipse in Ubuntu Behind a Proxy

Took me ages to figure this out. I followed these instructions on how to install Subclise. After I added the remote site and hit "Finish" the installer just timed out.  I was working behind a firewall (IT LABS!) so I figured proxy settings had something to do with my problems.

Long story short, Eclipse doesn't use your global proxy settings.  In Ubuntu, the location of the settings in Eclipse is Window->Preferences->Install & Update.  From there you can specify your proxy host and port and successfully install Subclipse.

Subclipse is a Subversion plugin for eclipse.  Thanks to Nathan for helping me find the settings!