Removing a bad sector from an NTFS partition. Badblocks gave me an output. now what?

30,417

Solution 1

...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:

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.

Solution 2

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:
30,417
Mina Michael
Author by

Mina Michael

Updated on September 18, 2022

Comments

  • Mina Michael
    Mina Michael over 1 year

    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.

  • Mina Michael
    Mina Michael over 10 years
    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
    Mina Michael over 10 years
    just executed those commands then opened gparted and it still shows the "red exclamation mark" that indicates that there's a bad sector... will running badblocks again make a difference?
  • Mina Michael
    Mina Michael over 10 years
    ...well my problem got solved. thanks for helping :) ... the 4 commands you told me to do, they delete the data on these 4 sectors, right?
  • FriendFX
    FriendFX over 10 years
    @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
    FriendFX over 10 years
    The question is, what can be done if the drive is not modern enough to be SMART?
  • Mina Michael
    Mina Michael over 10 years
    hmmm so this means that my drive is stupid XD I mean not modern XD and that's why it wasn't easy to deal with that bad sector! ...Well I hope other people find this question useful. Thanks a lot :) :)
  • bhathiya-perera
    bhathiya-perera almost 10 years
    bs=1024 is this a standard ?
  • Anish
    Anish almost 10 years
    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.
  • Sam Watkins
    Sam Watkins almost 10 years
    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
  • Ziyuan
    Ziyuan almost 5 years
    I have Input/Output errors on most of the found bad blocks
  • 16851556
    16851556 over 3 years
    I would guess (as a noob) that to mark block as reallocated causing OS to ignore it (as per my understanding) is needed to write to the bad block and i would guess that for this it was not necessary to "un-mark the bad clusters". You did writing in the dd command and i think that you could also use badblocks -vsw /dev/dbX command which also cause overwriting all data on the drive and then read written data to verify the block (and actually let the drive mark it offline uncorrectable?).