You are not logged in.

#1 2012-07-21 00:01:42

gogi-goji
Member
From: Canada
Registered: 2009-10-20
Posts: 73
Website

[Resolved] Checking CF card with badblocks causes kernel panic

I recently purchased a 128GB compact flash card to replace the hard drive in an old iPod mini.  I thought that it would be prudent to make sure the card was in working order before I started to use it.  I'm still pretty unfamiliar with solid state memory in general, but I thought that a good way to do this check would be with badblocks.  However, when I run

# badblocks -nsv /dev/sdb2

I get a kernel panic about 3% of the way into the check.  The kernel panic ends with:

[ 2298.915662 ] Kernel panic - not syncing: Fatal exception in interrupt

If more information from the output of the kernel panic would be useful, I can type it out here.  I've never had to deal with kernel panics before, so I'm not really sure what information is even relevant, or any method of grabbing the output other than manually retyping it.  I ran the same command twice, and both times failed after approximately the same amount of time. 

Any ideas as to what's going on, what other tests I should do, or in general what I should do next?

Last edited by gogi-goji (2012-07-31 01:14:02)


My (sporadically updated) blog
My miscellaneous dotfiles

Offline

#2 2012-07-31 01:13:14

gogi-goji
Member
From: Canada
Registered: 2009-10-20
Posts: 73
Website

Re: [Resolved] Checking CF card with badblocks causes kernel panic

It's been a little bit of time since I posted this, but I'm marking it resolved now.  I never figured out exactly what was the problem that was causing badblocks to bring down my entire system, but the problem seemed to "magically" resolve when I ran exactly the same test with exactly in a Ubuntu Live CD, I had no issues whatsoever.  I'm now suspicious that my problems could have been due to something funky in the custom kernel I'm running, but I'm not worried enough to spend the days that these tests take to run on a drive this size experimenting with different kernel versions and configurations.  So I'm not that worried about this, as in the end badblocks would successfully run for me and I found that there's really no issues with the compact flash card.

But if somehow this helps anybody out, here's an outline of the troubleshooting I did in my efforts to figure out what was wrong before things "magically" worked after updating my system.

I've run a couple more tests now (and man do some of these take a long time to run).  The read test I did with dd came out totally clean.

# dd if=/dev/sdb2 of=/dev/null bs=1k
125002525+0 records in
125002525+0 records out
128002585600 bytes (128GB) copied, 8225.31 s, 15.6 MB/s

The read/write test that I did with dd also came out fine.  I initially tried this with /dev/random, but that takes excessively long and was going nowhere fast (I didn't understand how it worked until looking into it after letting it run overnight), so I did it again with frandom.  That worked a lot better, since instead of trying to generate some real random data from a now-empty entropy pool, frandom uses a small bit of entropy to quickly generate a whole bunch of essentially random data.

# dd if=/dev/frandom of=/dev/sdb2 bs=1k
125002526+0 records in
125002526+0 records out
128002585600 bytes (128GB) copied, 9598.12 s, 13.3 MB/s

However, from my understanding (now) of what I just did, these tests with dd would catch errors if a block cannot be read or written to, but I haven't done anything to check if the reading and writing is accurate or if the data gets corrupted.  Now, this is going to be an important factor in the integrity of the drive.  Badblocks checks this, but since it doesn't seem to want to work on the drive (sending the computer into a kernel panic is quite disconcerting, but something other than bad sectors making badblocks go crazy could be the issue), so my next best idea is to make a checksum of the drive now that it's been filled with random data.  I'm theorizing here, but the issue could potentially be an inconsistency in how problem blocks read the data.  If this in fact is the case, it should be impossible to regenerate the same hash twice, as the input will be different.

# sha256sum /dev/sdb2 >> ~/hash.txt

Both times I ran it generated the same hash.  This would mean one of two situations: a) the card is just fine and there's really no problems with it, or b) the card's bad blocks aren't failing in the way I previously hypothesized.  If situation b is the case, that means that the issue with the bad blocks is that while they report that they have been successfully written to, that is not the case.

Badblocks is the only test I'm aware of to test this.  It was sending my computer into a kernel panic before, but that was with the non-destructive read/write test.  Perhaps the kernel panic problem would be limited to the non-destructive test I was running previously.  The badblocks man page tells me the -w flag tells badblocks to do four tests, writing the entire card with 0xaa, 0x55, 0xff, and 0x00 and reads the card to ensure that the correct pattern is actually being written.

# badblocks -wsv /dev/sdb2
Checking for bad blocks in read-write mode
From block 0 to 125002524
Testing with pattern 0xaa: done
Reading and comparing: 73.31% done, 4:16:21 elapsed. (0/0/0 errors)

It was at this point that my entire computer froze (with no kernel panic)  I had to manually power it down. 

Trying again on a different machine (Ubuntu 12.04 Live USB, Kernel 3.2.0), I had absolutely no issues running

# badblocks -wsv /dev/sdb2

and it shows that my compact flash card is just fine.  Go figure.  I'm thinking that my issues were likely caused by something funky in the custom kernel that I'm running, but I'm not worried enough about these issues to run a bunch of tests on different kernel versions and configurations.


My (sporadically updated) blog
My miscellaneous dotfiles

Offline

Board footer

Powered by FluxBB