Monday, July 12, 2010

Linux fixes what Windows breaks

The youngest son had malfunctioning Free Agent external hard drive that had been acting flaky (I will never buy another Seagate drive). Did he pull it without "safely ejecting?" Hell, I don't know.

All I do know is the problems started when he started using it with his Windows Vista laptop.

Finally it got to the point where his machine and my Windows XP box refused to acknowledge it. Plugging it in would, 3 out of 4 times, cause my machine to freeze.  It had, in fact, become useless.

So I offered to try and fix it, and recover the files if possible. The worst that  could happen would be the drive would be unusable. Like it already was.

I plugged it into my Linux box (Kubuntu 9.04) and fired up gparted.  Using this I was able to identify the correct device -- /dev/sdb1. Inserting it automatically created a mount point in /media, although it did not automount it. I mounted the drive on /media/FreeAgent using the command:

    sudo mount -t /dev/sdb1 /media/FreeAgent
Now I could view the contents of the drive. If you have trouble, make sure you have package ntfs-3g. While you're at it, install ntfsprogs (you'll need this for some operations. To install, run:
    sudo apt-get install ntfs-3g ntfsprogs
I may have been able to move the files off the hard drive using the file manager window but instead chose to go in on the command line.  After creating a temp directory, I used the mv command to pull things over as a series of directories.

Once I'd copied everything, I started gparted again, and this time, after selecting the correct drive, deleted and recreated the partition, then reformatted to NTFS. I did some minor testing but things looked okay. Your mileage may vary.

To wrap up this process, I copied the files back from the Linux temp directory to the newly formatted drive. Son now reports the drive no longer locks up the system.

One caveat: many external drive manufacturers now include a very small maintenance partition with some tools. Copy these if they are important or use them. Otherwise, kiss them good-bye. I've never put much faith in these myself..

No comments: