Aaron S. Hawley ([info]aaronhawley) wrote,
@ 2007-12-15 23:14:00
Previous Entry  Add to memories!  Tell a Friend!  Next Entry
Entry tags:free software, howto

Digging through Windows with GNU+Linux
A friend gave me an old hard drive. I threw it in the ancient computer I recently installed Debian 4.0 on (see previous entry). The hard drive originally had Windows 98 on it. He wanted to get a lot of his university course work and personal files off it. Unfortunately, Windows -- even newer versions -- are awful at finding files. Connecting the drive to a GNU+Linux operating system really showed the sleuthing powers of free software systems.

First I mounted the disk as read-only at /mnt (as the root user):

# mount -t vfat -o ro /dev/hdb2 /mnt

Then you can sick the GNU findutils on the hard drive (as a non-administrative user):

$ updatedb --output=./lose98-hd.locatedb --localpaths=/mnt

Let's see what we have after about a minute of listening to the sound of spinning hard drive disks?

$ locate -S --database=./lose98-hd.locatedb 
Database ./lose98-hd.locatedb is in the LOCATE02 format.
Locate database size: 210363 bytes
Filenames: 18694 with a cumulative length of 1045772 bytes
	of which 6385 contain whitespace, 
	0 contain newline characters, 
	and 1 contain characters with the high bit set.
Compression ratio 79.88%


Then it's easy to list all the files with a .doc extension:

$ locate --database=./adam-hd.locatedb -i *.doc

To find JPEG images that aren't in a browser cache folder.

$ locate --database=./lose98-hd.locatedb -i -r '.jpe?g$' | grep -vie cache

The locate command is not only more powerful than Windows "Find files...", they're also really fast because they benefit from indexing the file system and you get the benefit of the rest of the Unix toolbox, including find and file, that provide even more meta data about the file system and help fine tune your searches.

I'm sure you could easily get deeper and deeper if you knew even more subtleties about the FAT filesystem (using dd) or say the W32 platform and system files (I'm sure there are Perl libraries for W32). The downside is that GNU+Linux is a monolithic kernel. Mounting drives and their images can be done, but is a bit of a chore. In an idealized microkernel environment -- like GNU/Hurd, it would provide a better experience and safer sandbox.

When I was done playing and couldn't find any more files for my friend, I formatted the drive (as root user):

cfdisk -z /dev/hdb
mke2fs -j -L /backup /dev/hdb1
mkdir /backup
echo -e "/dev/hdb1 /backup ext3 defaults 0 2" >> /etc/fstab
mount /backup


If I wanted to be a computer forensic investigator, the tools in a GNU+Linux system would provide a pretty good base to build a larger tool for cataloging hard drives. I'd probably write the package in shell script or maybe Perl. Fortunately, I already have a day job. But others are working on developing free forensic tools.

Yeah, this was just an excuse to try posting to the Debian community in Live Journal.


(Post a new comment)


[info]simbab
2007-12-16 04:40 am UTC (link)
I'm sure you could easily get deeper and deeper if you knew even more subtleties about the FAT filesystem (using dd) or say the W32 platform and system files (I'm sure there are Perl libraries for W32). The downside is that GNU+Linux is a monolithic kernel. Mounting drives and their images can be done, but is a bit of a chore. In an idealized microkernel environment -- like GNU/Hurd, it would provide a better experience and safer sandbox.


This doesn't make any sense. The only difference between a monolithic kernel and a microkernel is whether the file system and block device code lives in kernel mode or user space.

(Reply to this)(Thread)

right
[info]aaronhawley
2007-12-16 06:35 am UTC (link)
yeah. read more about implemented microkernels to get an idea of the benefits of the architecutre, more specifically the Hurd for applications to the Unix-like operating system.

(Reply to this)(Parent)(Thread)

Re: right
[info]simbab
2007-12-16 06:52 am UTC (link)
I fail to understand how "mounting drives and images" has anything to do with micro vs. monolithic kernels. It's only tangentially a kernel mode task. User space is going to look the same, especially if you're talking about a user on the command line.

And I don't think you exactly know what you're talking about either, so don't try that RTFM crap on me. That little step was rather revealingly sophomoric.

(Reply to this)(Parent)(Thread)

Re: right
[info]aaronhawley
2007-12-16 05:29 pm UTC (link)
I meant no disrespect, I just assumed by your comments that you have only theortetical understanding of microkernels.

(Reply to this)(Parent)


(Anonymous)
2007-12-16 01:01 pm UTC (link)
I think your mention of micro-kernels was lethal. Good article, but all of your responses are people sucked in by the flamebait of micro vs. monolithic kernel. best to avoid the eternal flame-wars. Nobody changes their mind, and your life, which is very finite, gets wasted.

(Reply to this)


[info]babbage
2007-12-16 09:45 pm UTC (link)
In current Debian, the upstream source package "findutils" is split into "findutils" (which is Essential) and locate (which is not). This means that some people will need to install the locate package as well as findutils.

Also, instead of using --database, you can just set the LOCATE_PATH environment variable.

(Reply to this)(Thread)

re: findutils
[info]aaronhawley
2007-12-17 12:13 am UTC (link)
Upstream source package appears to still contain both:

http://ftp.gnu.org/pub/gnu/findutils/

It appears Debian is splitting the package starting with Debian 4.1.

http://packages.debian.org/lenny/findutils
http://packages.debian.org/lenny/locate

Thanks for telling me this.

(Reply to this)(Parent)(Thread)

Re: findutils
[info]babbage
2007-12-17 12:47 am UTC (link)
Well, I know what the upstream package contains, since I'm the maintainer :)

(Reply to this)(Parent)


[info]darth_nater
2007-12-16 09:53 pm UTC (link)
That's funny. I've never had an issue finding files in Windoze.

(Reply to this)(Thread)


[info]cowsandmilk
2007-12-17 06:42 pm UTC (link)
yeah, seriously...
and if for some reason I needed to use freetools, wait, cygwin has me all set.

(Reply to this)(Parent)(Thread)

re: cygwin
[info]aaronhawley
2007-12-17 07:32 pm UTC (link)
Yeah you can use Cygwin and even Emacs on Windows, but having done both quite extensively I can say there both offer a rather neutered experience. Granted even if they worked out the bugs, I'm pretty sure I'd stick with a free operating system.

(Reply to this)(Parent)(Thread)

Re: cygwin
[info]aaronhawley
2007-12-17 07:32 pm UTC (link)
typo: s/there both/they both/

(Reply to this)(Parent)


Create an Account
Forgot your login?
Login w/ OpenID
English • Español • Deutsch • Русский…