Tuesday, February 17, 2009

Don't Panic Filesystem, It'll Be Okay

"Ouch! My G1 isn't reading my microsd card! Nooooo! I need to listen to something on the train! Oh wait, let me just use iMeem for now."

That's not a good way to start off the first day back from a long weekend. But unfortunately, that's how I started it off. So now, as I'm finally having time to sit down and troubleshoot why my microsd card was not reading, I can tell you all about how I fixed it!

So, I plug in my G1 to my laptop here at work. Here's my dmesg output:

acruz@acruz:~$ dmesg | tail
[28938.531732] sd 6:0:0:0: [sdc] Attached SCSI removable disk
[28938.531824] sd 6:0:0:0: Attached scsi generic sg3 type 0
[28938.969366] FAT: Filesystem panic (dev sdc1)
[28938.969387] fat_get_cluster: invalid cluster chain (i_pos 0)
[28938.969392] File system has been set read-only
[28941.483468] FAT: Filesystem panic (dev sdc1)
[28941.483493] fat_get_cluster: invalid cluster chain (i_pos 0)
[29038.322352] FAT: Filesystem panic (dev sdc1)
[29038.322365] fat_get_cluster: invalid cluster chain (i_pos 0)
[29038.322372] File system has been set read-only


Whoa...a panic is never any good in linux. Hmmm...all of my data is intact. Okay, no problem then. All I need to run is a quick fsck.vfat -a.


acruz@acruz:~$ sudo fsck.vfat -a /dev/sdc1
dosfsck 2.11, 12 Mar 2005, FAT32, LFN
FATs differ but appear to be intact. Using first FAT.
/albumthumbs
Contains a free cluster (4). Assuming EOF.
/music/P/mp3/Pimsleur01.mp3
Contains a free cluster (43543). Assuming EOF.
Reclaimed 1552 unused clusters (50855936 bytes) in 17 chains.
Performing changes.
/dev/sdc1: 1105 files, 127709/244416 clusters


Well, seems like I had a few files that were probably corrupted when I transferred them last. Sheesh! Well, at least now fsck fixed it! Now, all I needed to do was umount/mount and then all looked better again!

Here's the healthy dmesg output:

acruz@acruz:~$ dmesg | tail
[30213.598301] sd 7:0:0:0: Attached scsi generic sg3 type 0
[30222.667142] sd 7:0:0:0: [sdc] 15659008 512-byte hardware sectors (8017 MB)
[30222.669098] sd 7:0:0:0: [sdc] Write Protect is off
[30222.669107] sd 7:0:0:0: [sdc] Mode Sense: 03 00 00 00
[30222.669112] sd 7:0:0:0: [sdc] Assuming drive cache: write through
[30222.673118] sd 7:0:0:0: [sdc] 15659008 512-byte hardware sectors (8017 MB)
[30222.675136] sd 7:0:0:0: [sdc] Write Protect is off
[30222.675147] sd 7:0:0:0: [sdc] Mode Sense: 03 00 00 00
[30222.675151] sd 7:0:0:0: [sdc] Assuming drive cache: write through
[30222.675164] sdc: sdc1


That looks much better! w00t!

Cheers!

No comments: