Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Thu 18 Sep 2014, 13:46
All times are UTC - 4
 Forum index » House Training » HOWTO ( Solutions )
How to get rid of bad blocks on a drive
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [11 Posts]  
Author Message
PaulBx1

Joined: 16 Jun 2006
Posts: 2308
Location: Wyoming, USA

PostPosted: Thu 12 Feb 2009, 12:59    Post subject:  How to get rid of bad blocks on a drive
Subject description: Or, perhaps, erase a drive
 

I had a drive from some old computer that was reporting bad blocks. I was about to toss it when I had the bright idea of finding where the bad blocks were, and then just making a partition around them with a single file named "Don't use this partition! Bad blocks here!"

So, I had this drive in a USB box, and started fiddling around with gparted and e2fsck, and chkdsk on a windows box too. I found out the reporting doesn't tell you the location, so I was trying to localize it by moving partition boundaries. Perhaps with some research I could have found a tool with more detailed reporting, or maybe it was a switch I missed, I don't know. But after a while, I noticed bad blocks were not being reported any more!

Turns out most modern drives have enough intelligence to remap bad blocks to some spare sectors they have in reserve, and according to one article I read, the way to trigger this behavior is to attempt to write the bad sector. Not sure how that would do it, but SOMETHING worked.

I finally ran this command on the disk:
Code:
badblocks -svw /dev/sdc

This code writes the entire disk, from start to finish, with some alternating bit patterns, all ones and all zeros, and verifies after each write. Needless to say, there is no data left after this is done, no partitions, not even an mbr. You might want to back up any data on the drive before doing this. Wink

It took half a day for this 150GB USB drive, but now I am confident the bad blocks are mapped out and the drive is good.

(Edit: I added the "s" flag to the above command because it gives progress information, something useful to have for a command that might take many hours to finish.)

Last edited by PaulBx1 on Fri 11 Dec 2009, 20:57; edited 1 time in total
Back to top
View user's profile Send private message 
Flash
Official Dog Handler


Joined: 04 May 2005
Posts: 11066
Location: Arizona USA

PostPosted: Thu 12 Feb 2009, 15:46    Post subject:  

Puppy has this command? If so, it would be a simple and easy way to erase a hard disk drive.
Back to top
View user's profile Send private message 
r__hughes

Joined: 13 Apr 2006
Posts: 342
Location: Canada

PostPosted: Thu 12 Feb 2009, 18:21    Post subject:  

I get this with a frugal pup411

~#
~# which badblocks
/sbin/badblocks
~#
~#
~# badblocks --h
badblocks: invalid option -- -
Usage: badblocks [-b block_size] [-i input_file] [-o output_file] [-svwnf]
[-c blocks_at_once] [-p num_passes] [-t test_pattern [-t test_pattern [...]]]
device [last_block [start_block]]
~#

I will bravely leave it to others to verify if this can be used to completely erase a disk Smile

_________________
--- quad booting pup431, Slacko55PAE, Slacko56NPAE (with OO3/LO4, devx, Gimp) & WXP on DELL Dimension 2400 PC & DELL Latitude 630 Laptop using grub.
---USB-Flash booting same on Samsung N110 WXP Netbook and Lenovo q100 WXP netPC.
Back to top
View user's profile Send private message 
DMcCunney

Joined: 02 Feb 2009
Posts: 897

PostPosted: Wed 18 Feb 2009, 11:17    Post subject: Re: How to get rid of bad blocks on a drive
Subject description: Or, perhaps, erase a drive
 

PaulBx1 wrote:
I had a drive from some old computer that was reporting bad blocks. I was about to toss it when I had the bright idea of finding where the bad blocks were, and then just making a partition around them with a single file named "Don't use this partition! Bad blocks here!"

Nice thought, but unfortunately, the bad blocks may not all be localized in a single area.

Quote:
So, I had this drive in a USB box, and started fiddling around with gparted and e2fsck, and chkdsk on a windows box too. I found out the reporting doesn't tell you the location, so I was trying to localize it by moving partition boundaries.

If you can access the drive from a Windows box, and it was previously formatted as FAT or NTFS, CHKDSK /F /R /X in a command window will do a surface scan of the drive and map bad blocks. /F is fix file system errors, /R is the surface scan, and /X dismounts the drive so CHKDSK gets exclusive access.

You can then reformat it with whatever file system you like.

Your solution is a good one if you only have Linux available.
______
Dennis
Back to top
View user's profile Send private message 
Flash
Official Dog Handler


Joined: 04 May 2005
Posts: 11066
Location: Arizona USA

PostPosted: Wed 18 Feb 2009, 15:08    Post subject:  

DMcCunney, um, thanks, I guess. For what it's worth, this is a forum for Linux users. Smile
Back to top
View user's profile Send private message 
Billwho?


Joined: 06 Dec 2005
Posts: 570
Location: still "In The Dog House" East Coast Oz Trialing 4.20

PostPosted: Thu 19 Feb 2009, 08:18    Post subject:  

Ahh but some of us have to maintain window$ boxes for less enlightened family members. So why not kill two canaries with one rock and run the scan on the D drive while you are downloading all the windows and virus scanner updates.
_________________
Linux = Learning through doing Shocked Confused Very Happy
The learning curve may be steep but there is a light at the end of the tunnel.
You just have to pass the occasional oncoming train to get there.
Back to top
View user's profile Send private message 
Sylvander

Joined: 15 Dec 2008
Posts: 3444
Location: West Lothian, Scotland, UK

PostPosted: Sun 13 Mar 2011, 13:50    Post subject:  

1. The HDD on my sons Dell Inspiron 6400 had [has?] a "bad block" somewhere on his Windows XP NTFS partition holding Windows XP [and 4 varied Puppy pupsaves+SFS] on his internal HDD [ATA Hitachi HTS54106].
I found this because Lupu-520 was [very suspiciously] showing about 50% CPUusage...
SO...

2. I rebooted with the...
puppy pfix=ram
Command.
And used GParted to "check" the partition.
But it reported it couldn't complete the check/fix.
SO...

3. I booted "FalconFour's UBCD v2.0"...
And ran a diagnostic [HDtune?]...
Which reported a single faulty "block"...
ERROR at 3190MB (LBA 6534312)
Then...

4. Ran...
chkdsk /r c:
I believe /r includes /f
So no need to use...
chkdsk /f /r c:

5. HDtune still shows the faulty block [how come?] but both Lupu and Windows seem to be working well.

6. I'd like to be sure the faulty block has been taken out of use.
And if it hasn't, to find a program that will do it.
Hopefully it will then no longer be displayed as faulty by HDtune.
Back to top
View user's profile Send private message 
pemasu


Joined: 08 Jul 2009
Posts: 5463
Location: Finland

PostPosted: Mon 14 Mar 2011, 17:26    Post subject:  

Well, you can feed the badblocks info to fsck so that bad blocks are not used:
http://linuxpoison.blogspot.com/2008/01/howto-check-disk-drive-for-errors-and.html
Back to top
View user's profile Send private message 
Sylvander

Joined: 15 Dec 2008
Posts: 3444
Location: West Lothian, Scotland, UK

PostPosted: Mon 14 Mar 2011, 18:10    Post subject:  

1. Could you explain the various parts of those 2 command lines, so I may gain some level of knowledge and understanding of what is being done? Smile
Back to top
View user's profile Send private message 
pemasu


Joined: 08 Jul 2009
Posts: 5463
Location: Finland

PostPosted: Tue 15 Mar 2011, 02:17    Post subject:  

Sylvander. I just found that possibility when someone else asked the same question in irc.
The mechanism is simple. You execute the badblocks and create textfile to have the findings. Then you feed that information to fsck so that those found badblocks are not used.
However I havent used it myself. I think you should search the net for right options for both commands. I wanted to inform you of one way I found when researching the same question.
I am sure the net offers a lot references.

Oh, and the partition you check needs to be unmounted. You probably knew that, but as safety measure, I remind it.
Back to top
View user's profile Send private message 
Sylvander

Joined: 15 Dec 2008
Posts: 3444
Location: West Lothian, Scotland, UK

PostPosted: Tue 15 Mar 2011, 03:29    Post subject:  

OK, thanks. Very Happy
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [11 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » House Training » HOWTO ( Solutions )
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0725s ][ Queries: 12 (0.0048s) ][ GZIP on ]