Tuesday, December 03, 2013

USB drive blues

Not much more than a week ago, I wrote about the wonders of hibernation for my computer. Welll, I discovered that hibernation works great for my computer, but external USB drives don't like it on Linux. I have some research to do on why that is, but I would like to share one very nice tool to help out when the file system gets corrupted: e2fsk.

e2fsck is a file system utility that can be used to check and repair corruption on a disk. I ran it for a day and a half to check for errors on this computer after noticing that my backups were failing. It ran very slowly on a modern computer, yet, when I put the same drive on my older computer, it finished in about a day.

That may be because I wasn't using the older computer for anything else. I just set it running and let it run until it was done. Yes, it does take awhile to run on larger disks, but if you want your files back, patience is the key.

The command execution is very simple. In this case, I had to unmount the drive:

sudo umount /path/to/drive

"Sudo" means run as root using your own password. This is typically how we access root privileges on Debian based systems. umount is the command to unmount a partition. Unmounting the partition allows the system to work on the partition without interference from other processes on the system and prevents further corruption during the file system check process. Then I could run the e2fsck command as follows:

sudo e2fsck -y /path/to/drive

The "-y" is an option to answer yes to every question. This automates the repair cycle so that I don't have to sit around pressing Enter all day. Using this tool, I recovered all of my files and now I'm preparing to use that same disk as a backup storage device for my Rasberry Pi-based backup server.

I would love to write more this morning, but snow has covered the landscape and I want to get to work on time. In a future post, I will share how to set up a basic backup system for Linux machines. It's fun, and not all that hard to do. I hope you find this article useful.

Have a great day.
Post a Comment