The time now is Sat 18 May 2013, 13:50
All times are UTC - 4 |
| Author |
Message |
PaulBx1
Joined: 16 Jun 2006 Posts: 2308 Location: Wyoming, USA
|
Posted: 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.
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
|
|
 |
Flash
Official Dog Handler

Joined: 04 May 2005 Posts: 9840 Location: Arizona USA
|
Posted: 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
|
|
 |
r__hughes
Joined: 13 Apr 2006 Posts: 335 Location: Canada
|
Posted: 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
_________________ --- triple booting pup421& pup431 (with OO3, devx, Gimp) & WXP on DELL Dimension 2400 PC & DELL Latitude 610 Laptop using grub.
---USB-Flash booting pup431 (with OO3, devx, Gimp) on Samsung N110 WXP Netbook and Lenovo q100 WXP netPC.
|
|
Back to top
|
|
 |
DMcCunney
Joined: 02 Feb 2009 Posts: 894
|
Posted: 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
|
|
 |
Flash
Official Dog Handler

Joined: 04 May 2005 Posts: 9840 Location: Arizona USA
|
Posted: 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.
|
|
Back to top
|
|
 |
Billwho?

Joined: 06 Dec 2005 Posts: 570 Location: still "In The Dog House" East Coast Oz
Trialing 4.20
|
Posted: 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
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
|
|
 |
Sylvander
Joined: 15 Dec 2008 Posts: 2852 Location: West Lothian, Scotland, UK
|
Posted: 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
|
|
 |
pemasu

Joined: 08 Jul 2009 Posts: 5165 Location: Finland
|
Posted: 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
|
|
 |
Sylvander
Joined: 15 Dec 2008 Posts: 2852 Location: West Lothian, Scotland, UK
|
Posted: 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?
|
|
Back to top
|
|
 |
pemasu

Joined: 08 Jul 2009 Posts: 5165 Location: Finland
|
Posted: 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
|
|
 |
Sylvander
Joined: 15 Dec 2008 Posts: 2852 Location: West Lothian, Scotland, UK
|
Posted: Tue 15 Mar 2011, 03:29 Post subject:
|
|
OK, thanks.
|
|
Back to top
|
|
 |
|
|
|
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
|