I want to know if I have badblocks on my sdb5 HDD.

Gene Heskett gene.heskett at verizon.net
Thu Nov 20 22:22:36 UTC 2008


On Thursday 20 November 2008, Steven Vollom wrote:
>Gene Heskett wrote:
>> On Thursday 20 November 2008, Steven Vollom wrote:
>>> I did the following in the Shell:
>>> steven at Studio25:~$ e2fsck -c
>>> Usage: e2fsck [-panyrcdfvstDFSV] [-b superblock] [-B blocksize]
>>>               [-I inode_buffer_blocks] [-P process_inode_size]
>>>               [-l|-L bad_blocks_file] [-C fd] [-j external_journal]
>>>               [-E extended-options] device
>>>
>>> Emergency help:
>>> -p                   Automatic repair (no questions)
>>> -n                   Make no changes to the filesystem
>>> -y                   Assume "yes" to all questions
>>> -c                   Check for bad blocks and add them to the badblock
>>> list -f                   Force checking even if filesystem is marked
>>> clean -v                   Be verbose
>>> -b superblock        Use alternative superblock
>>> -B blocksize         Force blocksize when looking for superblock
>>> -j external_journal  Set location of the external journal
>>> -l bad_blocks_file   Add to badblocks list
>>> -L bad_blocks_file   Set badblocks list
>>> steven at Studio25:~$
>>>
>>> The following was included in a search:
>>>
>>> *Important note:* If the output of *badblocks* is going to be fed to the
>>> *e2fsck* or *mke2fs* programs, it is important that the block size is
>>> properly specified, since the block numbers which are generated are very
>>> dependent on the block size in use by the filesystem. For this reason,
>>> it is strongly recommended that users *not* run *badblocks* directly,
>>> but rather use the *-c* option of the *e2fsck* and *mke2fs* programs.
>>>
>>>
>>> Does the size of the blocks show here:
>>>
>>> 255 heads, 63 sectors/track, 24792 cylinders
>>> Units = cylinders of 16065 * 512 = 8225280 bytes
>>> Disk identifier: 0x47a447a3
>>>
>>>  Device Boot      Start         End      Blocks   Id  System
>>> /dev/sda1   *           1        1824    14651248+  83  Linux
>>> /dev/sda2            1825       24792   184490460    f  W95 Ext'd (LBA)
>>> /dev/sda5           16523       24792    66428775   83  Linux
>>> /dev/sda6            1825        2006     1461852   82  Linux swap /
>>> Solaris
>>> /dev/sda7            2007       16522   116599738+  83  Linux
>>>
>>> Partition table entries are not in disk order
>>>
>>> Disk /dev/sdb: 81.9 GB, 81964302336 bytes
>>> 255 heads, 63 sectors/track, 9964 cylinders
>>> Units = cylinders of 16065 * 512 = 8225280 bytes
>>> Disk identifier: 0xffffffff
>>>
>>>  Device Boot      Start         End      Blocks   Id  System
>>> /dev/sdb1               1        2591    20812176   83  Linux
>>> /dev/sdb2            2592        2856     2128612+  82  Linux swap /
>>> Solaris
>>> /dev/sdb3            2857        9964    57095010    5  Extended
>>> /dev/sdb5            2857        9964    57094978+  83  Linux
>>> steven at Studio25:~$
>>> If there are badblocks and they are identified on the HDD, can the HDD
>>> still be used?  If I format the HDD, will the badblocks be wiped and
>>> usable after format?  TIA.
>>>
>>> Steven
>>
>> You cannot format a recent hard drive, with recent being defined as nearly
>> 20 years now.  The drives are factory formatted, and require
>> instrumentation we don't have, so they just spin for a bit and return with
>> no error. All we do is write the filesystems logical structure when we
>> mke2fs a partition.
>
>I am confused, what if you were trying to get rid of a virus or
>something like that, how would you clean the drive of infections?

With a new filesystem, like mke2fs.  The structure that allowed the virus to 
find itself is destroyed, the sectors it occupied are free'd for use.  The 
data in those sectors is immaterial from that point onward.  This is the 
equivalent of a 'logical format' as all data is lost.  Only recoverable by 
some pretty Sofi$ticated recovery programs.

>And 
>if you want to change the OS, do you just install it over existing
>data.

That is essentially correct.  When the new file system structure is written to 
the drive in that OS's way of doing things, there is simply no concern for 
whatever may have been there in the past.

>When I use Gparted, it says that it formats a drive or partition 
>when instructed.  Isn't it doing that when I click on format?

The only hard drive I ever actually physically formatted was an ST-238r, 20-30 
meg mfm interface Seagate, about 20 years ago.  It took about 30 minutes to 
do the physical format on that 30 megs, about a minute to install the logical 
format data of the OS9 (microware) operating system, and another 11 hours to 
do a read verify, which marks the unusable sectors out in the allocation 
table.

How quick did Gparted return again? :)

>> I believe badblocks can work in that asked about mode, if e2fsck tells it
>> where to start and stop the scan at the partition boundaries.  That would
>> tend to automate the process for a beginner, at the expense of having to
>> run it on all the individual partitions in order to cover the whole disk.
>
>I don't understand what this does, or how to understand and then utilize
>the resultant information.
>
First, I would query the drive using 'smartctl -a /dev/sdwhatever' the drive 
is.  Somewhere in that rather lengthy report will be a line that resembles 
this, under this header line:

ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  
WHEN_FAILED RAW_VALUE

  5 Reallocated_Sector_Ct   0x0033   100   100   036    Pre-fail  
Always       -       0

That is all one line, and the last 0 is the count of defective and 
re-allocated sectors, which may not be 0 for any given drive, even new ones.

Have badblocks make the file for starters, see its man page for that.  Then 
look at the file.  If is empty, no drive problem.  If it has content, which 
is a number per line, then that file should be fed to e2fsck using the -l 
option. I see that e2fsck prefers one should do the -c -k option instead, but 
its something I have not personally done.  See the e2fsck man page, its 
clearer than I am I believe.  And my argument against that is that e2fsck 
should not be run on a mounted filesystem,  badblocks however can be, I've 
done it.

>> >From the badblocks manpage, it can generate a file in the correct format
>> > to
>>
>> send back to mke2fs or e2fsck and do it automatically from what I read.
>
>Would I be able to understand what happened and the information that was
>'send back to mke2fs'.  What is the result of the task?  Does it update
>something?  Does it fix something?  If it fixes something, what is
>damaged?  Is it physical damage or digital?

Its mapping around physical damage.  both the 'fs' utilities know how to 
access the drives own internal tables to add to the drives own bad block 
list, and which are then re-allocated from spares on the drive that we never 
see, but are there.
>
>> So I would run it to generate the file, (on a usb key
>
>is this the same as a thumb drive or USB memory chip?

Yes.

>>  or someplace not on that
>> drive) and then feed that file to e2fsck
>
>Is this like cutting and pasting the file to e2fsck?  How do I find
>e2fsck to open and paste the file?

No, again see the e2fsck man page, you follow the -l option with a full path 
to the file it is to use.  No cut-n-paste involved, it reads the file 
directly from that path.

>>  as a separate operation, which would
>> check (and repair if it can) the whole drive in only 2 operations.  The
>> first run is a lengthy procedure timewise, so expect an hour or more
>> dependent on the hardware.
>
>This partition is on an 80gb HDD.
>
>>   The 500Gb Maxtor that just failed for me was about 11 hours to
>> check it all.
>>
>> I have now zeroed the bootable flag on it using fdisk,
>
>What does zeroing the bootable flag do,

It prevents the bios from trying to boot from that drive.
>and is using fdisk just typing 
>fdisk into a shell?

yes, "fdisk /dev/device"

>If so, then what happens after you click enter, and 
>how do you use the information?

fdisk is a text only utility, once running hit m for help, p for the drives 
present geometry, yadda yadda.
q to quit without changes, w to quit after committing the changes.

>>  so I can re-install the
>> card
>
>What is 'the card'

In my case, this mobo only has one pata/ide port, so I have to use a pci card 
to access more than 2 drives.  Most mobo's have two ports and can handle 4 
drives.

>>  and drive,
>
>by drive, do you mean the partition sdb5 or the 80 gb drive?

When I say drive, its the whole thing.  If the drive has more than one 
partition, then I would refer to the partition on that drive, which is not 
the whole thing.

>>  and will see if its salvageable in the next day or so.
>
>I found out  something important yesterday.  Because I am an artist, I
>have been using only the right side of my brain for over 60 years.  I am
>not easily capable of understand a logical thing, unless it is visual or
>explained in those terms.  I talked with someone who had to learn to use
>the other side of his brain.  Another artist.  We just don't see thing
>in a Logical way like a computer guru.  It isn't that we won't be able,
>I am doing what I need to do now to exercise my left brain by learning
>from people like you.  It is why it is so difficult for you to help me,
>I think.  But I can absorb enormous amounts of visual information that
>you could not see unless taught, unless you teach your right-brain
>activity to become more important to you.  Do you notice how I have to
>break down the pieces of what you say?  Logic to Logic can communicate
>in a few words.  Visual to logic takes a lot of additional information.
>Logic to Visual also takes more information than a logical person thinks
>necessary.  If you don't lose patience with me, I am having
>breakthroughs.  I am getting able to understand how to ask questions in
>a way that you can understand me.  I am starting to learn how to process
>what is said.  It is glorious.  I didn't think I was stupid, but for me
>the way a computer specialist talks is about the same as trying to
>understand Chinese.  Until I learn the language it is babble to me.
>Every answer given to me creates new questions, and I have to take that
>information and figure out what you mean.  Please don't give up on me.
>Things are changing.  It is like coming from a dark room into the light.

Good, later, dinner calls.


-- 
Cheers, Gene
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
It has long been known that one horse can run faster than another --
but which one?  Differences are crucial.
		-- Lazarus Long




More information about the kubuntu-users mailing list