It's an unfortunate fact of life: occasionally segments of disk space goes bad. A lot of times it's just a few bytes, but occasionally it ends up being a large region of the disk surface. Who knows, you might win the lottery and end up with a b0rked drive! you better have a backup.

really, it's more common than you think. these days, mosts hard disks are made for space quantity, not quality-- unless you get one made for an enterprise environment. and this should be no suprize, think of that 200GB disk you've been drooling over: would you pay twice as much for a high-quality disk with half the capacity?

why don't we see these errors too often? well, a lot of systems are setup so that when a block, sector, or what have ya goes bad, it is eventually detected and data will not be saved there. but Bob forbid that a system file was saved there when that block goes bad.

the specific scope of this thread is in regards to checking for bad regions before making a new filesystem on a partition. i won't talk at great length about error checking in an existing partition, for the simple fact that i don't know whether Gentoo/Linux handles that fine on its own.

now, if you are going to use ext2 or 3, this is as simple as setting the "-c" flag (as well as for the command, mkswap). however, mkreiserfs suprizingly doesn't have this functionality built in. this no doubt has led to many cases where one's partitions became pretty much a mine field... let's hope that that system file doesn't land on this bad block. this is more of a risk with older computers (since disks degrade with time), but even with newer computers there is an insurance policy most of us are willing to pay for in terms of time.

what we will need are three tools: badblocks, your favorite partition tool, and of course mkreiserfs. both badblocks and mkreiserfs are available on the LiveCD. badblocks is used, as the name implies, to find bad blocks. that is, we will use this to find areas on a partition which are unusable. then, those get fed to mkreiserfs, which silently thanks you for the heads up and makes sure those "blocks" are not used. now, when i say "blocks," i mean a predefined, continuous section on the disk. (the default block size for ReiserFS is 4096 bytes. you can, howerver set it to use any even value between 512-8192.)

The first step, if you haven't already, is create your partition (or partition scheme), using your favorite partitioning tool. I assume you already know how do to that.

Second, we need to create a file which will store a list of bad block locations, which mkreiserfs will later use. my suggestion is using an intuitive name, like:

Code:

/sbin/badblocks -b 4096 -o ~/hda1-badblocks /dev/hda1

relax, grab a drink, because this will take while.

if you plan to use a block size other than the default for ReiserFS, then change the "-b" setting accordingly. i cannot stress enough that the block size must be the same throughout this process. the example above will create a file in your root folder called "hda1-badblocks." you can actually open it and read it yourself: if it's empty, then that's a good thing as that means your partition is in perfect shape. if you have bad blocks, you will see a series of numbers.

finally, you are ready to create a reiser filesystem. sticking with our example, here this is the command:

Code:

# mkreiserfs -B ~/hda1-badblocks /dev/hda1

assuming you didn't do anything silly, that should take care of it for ya.

for more information, check the man page for badblocks(8 ). BTW, you can also use this utility to check partitions you are already using. just make sure you don't set the "-w" flag, and it is probably a good idea to avoid the "-n" flag too. also, i don't know much about other filesystems (e.g. XFS), but this might help out with those too. but again, if you are using mke2fs it's "strongly recommended" by the docs to use its built-in checking feature instead of badblocks.

The first step, of course, is to create your partition, if it's not created already. If you don't know how to do that, give me your address so i can send you a mallet to hit yourself over the head with repeatedly

I don't see how this has a place in a tutorial or tip.
Please either explain it or give a link._________________>>> emerge (3 of 7) mcse/70-293 to /
Essential tools: gentoolkit eix profuse screen

The install was going onto a ReiserFS. I /sbin/badblocks -b 4096 -o ~/hda4-badblocks /dev/hda4 (3-4 hours of "chugging") like Sheepdogj15 suggested. This listed heaps of badblocks. Then I mkreiserfs -B ~/hda4-badblocks /dev/hda4. When I unpacked stage3 I still came up with the same bzip error.

Then I tried mke2fs -c -j /dev/hda4. This took ages too. Stage3 then unpacked without error.

The problem is badblocks is dangerous - These days, all hard disks are full of spare sectors which get swapped in when the drive firmware detects a damaged sector.

If badblocks finds a bad sector, it will mark it bad but the HD will often remap the sector anyway to one that works.
If it runs out of spare sectors, then the badblocks detected will stay, but by then the disks is probably about to die.

My personal opinion is that if the HD is developing badblocks anyway, it should be replaced/RMA'd.

Using smartmontools to do a surface scan (The long test) will refresh the surface and map out any defects in hardware. If any more develop after this is done, the drive should be replaced.

Unfortunately, there are no Linux tools AFAIK that can do the oem-specific smart diagnostics, just the generic ones.