1

Topic: Ignore bad sectors

I think there should be an "ignore bad sectors" option. it would really help people that have bad sectors on thier hard disks, like me.

2

Re: Ignore bad sectors

krzysz00 wrote:

I think there should be an "ignore bad sectors" option. it would really help people that have bad sectors on thier hard disks, like me.

Add one more vote for that suggestion.

3 (edited by rpremuz 2010-01-21 17:17:34)

Re: Ignore bad sectors

I also vote for that option in GParted Live.

I wanted to expand an NTFS primary partition but the resize operation was unsuccessful because of bad sectors on the partition. I checked the partition with "chkdsk c: /r" in Windows XP and restarted twice but the problem remained. I'd say that in the case of partition expansion the bad sectors could be safely ignored.

-- rpr.

4

Re: Ignore bad sectors

I checked the partition with "chkdsk c: /r" in Windows XP restarted twice but the problem remained.

Did you try

chkdsk c: /f /r

?

GParted in general uses the safer switches for the various tools. ntfsresize (the tool that performs the ntfs resizing operations) is a command line tool that is able to ignore bad sector alerts. It is possible to run it from the command line with the right options to ignore bad sectors. However this is not the safe choice, that's why GParted didn't give it in the GUI.

Another reason to not include all possible options in the GParted GUI, is that it would be overloaded with many features that many users could not understand and that could be easy to set erroneously. This could cause serious problems, especially for non-experienced users.

*** It is highly recommended to backup any important files before doing resize/move operations. ***

5 (edited by rpremuz 2010-01-21 17:17:00)

Re: Ignore bad sectors

class413 wrote:

Did you try

chkdsk c: /f /r

On Windows XP "chkdsk /?" says:
  /F Fixes errors on the disk.
  /R Locates bad sectors and recovers readable information (implies /F)
and so "chkdsk c: /r" is equivalent to "chkdsk c: /f /r".

GParted in general uses the safer switches for the various tools. ntfsresize (the tool that performs the ntfs resizing operations) is a command line tool that is able to ignore bad sector alerts. It is possible to run it from the command line with the right options to ignore bad sectors. However this is not the safe choice, that's why GParted didn't give it in the GUI.

Another reason to not include all possible options in the GParted GUI, is that it would be overloaded with many features that many users could not understand and that could be easy to set erroneously. This could cause serious problems, especially for non-experienced users.

I understand that I could use ntfsresize from command line but it is quite more complicated and hence I use the GUI.
I didn't ask for overloading the GUI with many features but just for "ignore bad sectors" option.

-- rpr.

6

Re: Ignore bad sectors

One way to get around this is to do the following:
PATH=.:$PATH
pushd /sbin; mv ntfsresize ntfsresize.orig; popd
cat > ntfsresize
#!/bin/sh

OUT="ntfsresize.out"
echo "Args: $*" >> $OUT
/sbin/ntfsresize.orig -b $* >> $OUT 2>&1
echo "Done" >> $OUT
Ctrl-d
chmod +x ntfsresize
Now run gparted from this shell and it will call the ntfsresize shell script created above which will add the ignore-bad-sector flag (-b) to arguments supplied and call ntfsresize.orig and redirect all output to ntfsresize.out.

7

Re: Ignore bad sectors

dnivras wrote:

One way to get around this is to do the following:
<stuff>
...which will add the ignore-bad-sector flag (-b) to arguments supplied and call ntfsresize.orig and redirect all output to ntfsresize.out.

The above is a dangerous approach, far better if possible (and it usually is) to at least attempt repairing the drive instead>
FWIW my own approach would be:
1) Cause the drive to attempt writing and thus remap such sectors, badblocks in non-destructive read-write mode can do this

sudo badblocks -svn /dev/sdXY

will do this, although it's possible you might lose any data that was written in them (it's probably lost anyhow in such a case)

That leaves you with a drive using only good sectors, though ntfs still has them marked bad, that too needs correcting:
2) Reboot into windows and run

chkdsk /b

on the affected partition ( implies /f & /r) this will retest the sectors marked bad and mark the freshly replaced sectors (by the drive firmware) good again.  If you still have sectors marked bad afterward, it's time for a new drive!


Be advised both commands can take hours each to complete on modern large drives.
I know it's a mixed OS approach, but I don't know a non-commercial Windows program that will cause the sector remapping after chkdsk marked a sector bad and made Windows avoid it, and I don't know a Linux tool I'd trust for retesting sectors chkdsk had marked bad, at least not one that would mark them good again in ntfs.  There's a reason GParted recommend letting Windows check ntfs file systems smile

Other points, some later combinations of Windows & chkdsk think they're being helpful trying to save you time and will skip running chkdsk on a reboot if Microsoft don't think you need to, in such cases you may have to use fsutil to mark the partition dirty so windows treats the chldsk *command* as a COMMAND rather than just a suggestion!