Tuesday, November 25, 2008

usb storage - corrupted e2fs

I don't know how it happened, since I verify each time when I disconnect my external 350G USB drive. I wait for hal to indicate "OK to disconnect" each time. Nevertheless, it's corrupted. I found the list of superblock backups easily
# dumpe2fs /dev/sdb1 |grep superblock
Then, I attempted a customary
# fsck -b 32768 /dev/sdb1
with a backup block from the list, 32768. However, several attempts netted the the same response, that the device was busy
# umount /dev/sdb1
# fsck -b 32768 /dev/sdb1
fsck 1.40.8 (13-Mar-2008)
e2fsck 1.40.8 (13-Mar-2008)
/sbin/e2fsck: Device or resource busy while trying to open /dev/sdb1
Filesystem mounted or opened exclusively by another program?
Making sure, I ran
# umount /dev/sdb1
umount: /dev/sdb1: not mounted
But yet, again, if I tried to fsck, I got
# fsck -b 32768 /dev/sdb1
fsck 1.40.8 (13-Mar-2008)
e2fsck 1.40.8 (13-Mar-2008)
/sbin/e2fsck: Device or resource busy while trying to open /dev/sdb1
Filesystem mounted or opened exclusively by another program?
What was going on? I verified the blocksize
# dumpe2fs /dev/sdb1 |grep -i "block size"
dumpe2fs 1.40.8 (13-Mar-2008)
Block size: 4096
and proceeded with
# mke2fs -S -b 4096 -v /dev/sdb1
to restore the superblocks without touching the data. Unfortunately, this move resulted in stale file handles and the drive wouldn't mount. Another move would be
# e2fsck -y -f -v -C 0 /dev/sda3
# tune2fs -j /dev/sd3
This makes the file system into a Ext3 system, and so the blocks are off if I started with ext2 on the drive in the first place. So I lost everything. Years of data, photos, passwords, tax records, the lot. If I knew a little more about e2fsck, I might have been able to get there, but all I could find was what to do with e3 file systems.

No comments: