Sunday, November 30, 2008

Hail Photorec, the genius

One dangerous aspect of tabbed file exploring in konqueror is that the selected folder in the folder tree on the left pane, need not be the one whose contents are listed on the right.  A slight oversight, and a ton of mp3s got deleted. Luckily I froze in horror when I realised the mishap and this greatly improved the prospects of getting the data back. I quickly unmounted all concerned partitions to prevent accidental data writes.

The background is important in this case, and it is briefly thus : hda with an ntfs partition and hdb  with an ext2 partition were involved. Moving a folder from hdb to hda was interrupted due to lack of space in hda. After clearing additional space, the operation continued from that point onwards, after skipping one file. (This is a great feature missing in Windows, by the way.) Since the file was skipped, the folder structure in hdb was retained partially. Then intending to cleanup the partial folder structure in hdb, I deleted the folder in hda.

The first tool I looked up was testdisk. This great and versatile tool also has an option to recover files. In the ntfs partition, the option to recover files did not show up, so I assume testdisk can do its magic only in ext2 partitions. The partial directory structure left in the ext2 partition probably prevented the deleted files from being displayed, when I trained testdisk on that disk.

Next after googling a bit, I zeroed in on R-Studio. The demo version can scan for recoverable files in many file systems. Though, it is an exe and needs a proper Windows installation to work, since in my case under Wine or Crossover R-Studio had problems in detecting the partitons.

I had to revert to the windows installation which resided in the ntfs partition, and eventhough the page file was turned off, I was sure that Windows would muck up the scene. Running RStudio after installing it, I found, again, that the broken folder structure in ext2 probably acted as a screen, since after a 20 min scan I had no useful results. ( Now, it occurs to me that deleting the remnants of that folder would have helped).  In the ntfs partition, I could get about 100 MB of mp3s, when the original folder had 2 GB. I was surprised by the result, since there was no writing operation that had occured in the preceding few minutes.

A little more googling, and Photorec popped up. This is a testdisk twin, since they are distributed bundled. As I already had testdisk installed, I could launch Photorec using that command. The interface and working resembles testdisk.

One feature of Photorec which I found quite useful was it's ability to scan selective areas of the disk, which significantly cut down the scan time. This seems a pretty obvious feature to include, but since I haven't seen it in any other recovery software, I was willing to call it an act of genius.

To elaborate the genius of Photorec, consider the normal "deleted file" situation: A large hard disk chock full of data, and some files get deleted to make room. The bulk of the situations would therefore involve small unallocated disk space where the deleted file exists, and large allocated disk space. Photorec explicitly asks which of these areas - allocated or unallocated - to scan.

The other intelligent trick up Photorec's sleeve, is the ability to fine tune the scan to search for files of a specific type. There are about 50 such file types that Photorec recognises, and can specifically scan for. Since I was only after MP3s I disabled all the rest, which could speed up scan times.

A combination of these two features ensured that in about one fifth the time it took with R-studio, I had results. How much?  In all, bits and pieces included, the recovered content from the ntfs partition was close to 1.5 GB. Removing the chaff, I expect close to 1.2 GB of valid MP3s. The scan on the ext2 partition returned about 500 MB of mp3s, a few looked interesting. Does this say something about the suitability of ntfs for file recovery situations?

In the end, I am satisfied with what I have : Not a complete recovery, but substantially better than what I could have got with R-studio.

Ofcourse the file names were a mess, so now I need a media organiser than can batch rename MP3s based on their ID tags.

Photorec, like testdisk, is free.

Blogged with Flock

dd - deeeee deeeee

I did manage to clone the hard disk using dd. But, it took considerably longer than Ghost.
Using watch, I could check the progress, and was alarmed to see that the transfer speed was 10 MBps. For a SATA2 to SATA2 disk transfer, this is an extremely low value.

A look around the net revealed that the "block" argument could speed things up. Not sure what the default bloxk size is, but read somewhere that setting it to 1 MB would result in quicker transfer. Need to check this out.

Wednesday, November 26, 2008

dd - the silent but strong type.

In the years as an XP user, copying one disk to another, or making a mirror, involved using Norton Ghost. Since the version that I had was DOS based, I had to go through the bootable Win98 partition/floppy route to get the job done.

Today I faced a similar issue, and went hunting for the linux version of Ghost, and found the ridiculously simple dd command. After using it, I am reminded of the type of folks who are all business with hardly time to utter pleasantaries.

While dd can do much more, for the job at hand, all I needed to do was issue "dd if=/dev/hda1 of=/dev/hda2" where hda1 was the source and hda2 the destination. To correctly figure out which is which, use the fdisk - l command to list all detected hard drives. This step is important, since it is easy to overwrite the wrong disk, since dd does not offer a prompt before going about it's business.

In my case, inspite of the fdisk command, I ended up deleting the Puppy installation in a flash drive that I had used to run the dd command to copy from one hard disk to another. It took me a couple of seconds to figure out the mistake, but it was too late. Now with the installation wiped out, I cannot use the flash drive at the next boot. The problem with that situation is that it has been close to 90 mins and dd has been working without any feedback, another quirkiness of dd.

The solution to this silence is to use another console to poke, literally, dd to offer information about what it has achieved. The Control - F1 (to F7) key combination can be used to launch a second console and from there issuing the command " $ watch -n X kill -USR1 PIDXX" where PIDXX needs to be replaced with the PID number of the dd process that can be found by issuing the "top" command. The "X" here is the time interval in seconds where the progress info is provided, which can be set according to user preference. And the kill -USR1 command is the actual poking that starts dd into giving the info.
A more detailed explanation is offered here :
http://linuxcommando.blogspot.com/2008/06/show-progress-during-dd-copy.html

Oh, in my case the power company had other plans, and an impromptu power loss brought the transfer process to a stop.

Tuesday, November 25, 2008

AVI Editor, at last.

Besides games, the only reason I had to keep Windows in my system was the need to edit video files. The simplicity of virtual dub was too overwhelming. Especially when contrasted with the headaches that I had to go through to get AVI demux installed, by following the instructions on their website.

Now, finally, thanks to easgs at linuxquestions.org, I have taken out this nagging thorn in my side. It seems I had been looking at the wrong place all the time. I had been going out all over the Net searching for samples of successfully installed AVI demux, when the answer was all the while within the system. Hat's off to easgs for showing the path. Easgs, by the way, is the creator of a special package of all multimedia tools for Opensuse 11 details of which are available at linuxquestions.org. Such a package will save a user from the trouble I went through.

What is needed is the inclusion of the Packman and OSS repositories in YAST. Without the Packman repository, AVI demux did not show up in any of the searches in YAST (eventhough the OSS and Non OSS repositories were enabled), causing me to go outside looking for the package ( all the while thinking why it was not in the repositories, as a matter of fact). With Packman enabled, the job becomes a routine one, search for AVI Demux, select the relevant packages (including the GUI packages - GTK and QT) and let YAST do the download and install.

About 25 MB is downloaded, including about 11 MB of the core packages and about 8 MB of the GUI files ( I selected both QT and GTK though I think either would have sufficed). Post install, I have a new entry under Multimedia where AVI Demux resides. AVI Demux does live up to it's hyped image, as a versatile avi editing tool. I have merely, successfully, edited a few videos and there is a lot to explore. But, I am confident that I can, sadly, bid Virtualdub goodbye.

Blogged with Flock