Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I used badblocks to scan a partition on my hdd for bad sectors and it gave me the following output

output

...from what I understand it looks like "one scratch on the hdd" ... anyways I can't partition with gparted because of this bad sector (my previous question: I need help with increasing the size of the file-system partition. Partitioning-o-phobia!) gparted still gives me "a red exclamation mark" on the drive after the badblocks test. ...now what?

I have also tried chkdsk on windows but still gparted gives the red mark

How do I mark this bad sector so that gparted can do its work? :) ...plz exclude answers about "replacing the hdd" I know I can do that.

share|improve this question

Try writing to those blocks:

sudo dd if=/dev/zero of=/dev/sda6 bs=1024 count=1 seek=303975848
sudo dd if=/dev/zero of=/dev/sda6 bs=1024 count=1 seek=303975849
sudo dd if=/dev/zero of=/dev/sda6 bs=1024 count=1 seek=303975850
sudo dd if=/dev/zero of=/dev/sda6 bs=1024 count=1 seek=303975851

(or in your case, you could collapse that to a single dd call with count=4)

Then run badblocks again.

On a modern hard drive, the controller already knows the blocks are bad, and will remap them, but still cannot provide the data from the previous location (since it's bad). Writing to the blocks will cause everything to look good again, and then you don't have any need for the filesystem to take care of it.

If this does work, then the second run of badblocks should find no bad blocks.

share|improve this answer
    
ummm I really don't understand the tech part but I'll just do those commands ... I could use more knowledge though :D – Mina Michael Jan 10 '14 at 14:14
2  
@MinaMichael: No, they just (try to) write to these bad blocks. If the drive is SMART (modern), it will automatically detect that the write failed and that the blocks are bad and the drive will use new (spare) ones instead - making the disk look as if it was without bad blocks. – FriendFX Jan 13 '14 at 12:23
1  
The question is, what can be done if the drive is not modern enough to be SMART? – FriendFX Jan 13 '14 at 12:24
1  
badblocks defaults to 1024-byte blocks. This default is specified in the manpage. Thus, to match the block numbering used by badblocks, dd must use a matching block size with bs=1024 too. – Robie Basak May 4 '14 at 18:36
1  
Also if you find a bad sector in a certain file, you can just overwrite the file with zeros, which is safer than messing about with the block device. e.g. </dev/zero head -c $(stat -c %s bad-file) >bad-file – Sam Watkins Jun 14 '14 at 10:49
up vote 2 down vote accepted

...well now gparted says it's clean!! AT LAST!! ...anyways I'm not sure what exactly solved the problem but I'll list what I've done backwards:

sudo ntfsfix -b /dev/sda6 which gave out:

Refusing to operate on read-write mounted device /dev/sda6.
minow@mina-ubuntu:~$ sudo ntfsfix -b /dev/sda6
Mounting volume... OK
Processing of $MFT and $MFTMirr completed successfully.
Checking the alternate boot sector... OK
NTFS volume version is 3.1.
Going to un-mark the bad clusters ($BadClus)... OK
NTFS partition /dev/sda6 was processed successfully.

but before that I did:

sudo dd if=/dev/zero of=/dev/sda6 bs=1024 count=1 seek=303975848
sudo dd if=/dev/zero of=/dev/sda6 bs=1024 count=1 seek=303975849
sudo dd if=/dev/zero of=/dev/sda6 bs=1024 count=1 seek=303975850
sudo dd if=/dev/zero of=/dev/sda6 bs=1024 count=1 seek=303975851

and before that I did

sudo badblocks -nvs /dev/sda6 ... which took 2 whole days to finish!

anyways, lastly, before the last command, I opened windows 7 and used the chkdsk utility (right click the partition, properties, "tools"(or something like that), check for errors)

I hope this helps anyone.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.