After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 335595 - Resizing NTFS partitions with bad sectors
Resizing NTFS partitions with bad sectors
Status: RESOLVED OBSOLETE
Product: gparted
Classification: Other
Component: application
0.2.2
Other All
: Normal enhancement
: ---
Assigned To: gparted maintainers alias
gparted maintainers alias
Depends on:
Blocks:
 
 
Reported: 2006-03-23 00:04 UTC by Andy
Modified: 2013-05-04 11:24 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Andy 2006-03-23 00:04:26 UTC
Would it be possible for the call to NTFSresize to include the "-b" flag (or
have the option of including said flag) allowing ntfs sectors with bad sectors
to be resized?
Comment 1 Plors (Bart H) 2006-03-26 12:35:17 UTC
I don't think it's a good idea to include this by default.
From the ntfsresize manpage:
------------------------------------------
Prior  using  this  option,  it's strongly recommended to make a
backup by ntfsclone(8) using the --rescue option,  then  running
'chkdsk  /f /r volume:' on Windows from the command line.
--------------------------------------------------------------

As you suggested its best if these options were made optional to the user (maybe in an 'advanced' expander).

Actually a lot of commands (e.g. most of the mkfs.*) have options which should be available to the user, i don't think this is very difficult to do, but the amount of work involved would be considerable (including testing and everything, i'd say it would take a week).
At this moment i don't have the time to work on this, but maybe you feel up for writing a patch?

thanks!
Comment 2 Mantas Kriaučiūnas 2006-07-26 14:04:12 UTC
Plors, main problem currently is, that gparted doesn't even check if NTFS partition has bad sectors before resizing and this couses big problems for the users.
I just got this problem, when tried to enlarge NTFS partition - gparted created larger partition sucessfully, but when executed ntfsresize then I got an error message from gparted, that operation wasn't sucessfull. This error message don't contained any information about bad sectors, while ntfsresize command told me exact problem:

ubuntu@baltix-linux:~$ sudo ntfsresize -v /dev/hda1
ntfsresize v1.12.1 (libntfs 8:1:0)
Using locale 'lt_LT.UTF-8'.
Device name        : /dev/hda1
NTFS volume version: 3.1
Cluster size       : 4096 bytes
Current volume size: 8389751296 bytes (8390 MB)
Current device size: 15726703104 bytes (15727 MB)
New volume size    : 15726699008 bytes (15727 MB)
Checking filesystem consistency ...
100.00 percent completed
Accounting clusters ...
Space in use       : 5652 MB (67,4%)
Collecting resizing constraints ...
WARNING: The disk has bad sector! This can cause reliability problems!
Bad clusters:  1073652 - 1073652
ERROR: The NTFS volume has at least 1 bad sector.
****************************************************************************
* WARNING: The disk has bad sector. This means physical damage on the disk *
* surface caused by deterioration, manufacturing faults or other reason.   *
* The reliability of the disk may stay stable or degrade fast. We suggest  *
* making a full backup urgently by running 'ntfsclone --rescue ...' then   *
* run 'chkdsk /f /r' on Windows and rebooot it TWICE! Then you can resize  *
* NTFS safely by additionally using the --bad-sectors option of ntfsresize.*
****************************************************************************


So, Gparted should display not an simple error message, that operation wasn't sucessfull, but should detect if there are bad sectors in volume (by running ntfsresize -f --no-act -v --info /dev/xxxn ) and if so, then display at least this info from ntfsresize --no-act output:

WARNING: The disk has bad sector! This can cause reliability problems!
Bad clusters:  1073652 - 1073652
ERROR: The NTFS volume has at least 1 bad sector.

The best decision would be to display full warning info from ntfsresize output (for example to display button "More info..." on the error dialog and when user click's on this button, then full warning info from ntfsresize output should be displayed.

Btw, I succesfully resized that ntfs volume when passed switch --bad-sectors to ntfsresize :

ubuntu@baltix-linux:~$ sudo ntfsresize --bad-sectors -v /dev/hda1
ntfsresize v1.12.1 (libntfs 8:1:0)
Using locale 'lt_LT.UTF-8'.
Device name        : /dev/hda1
NTFS volume version: 3.1
Cluster size       : 4096 bytes
Current volume size: 8389751296 bytes (8390 MB)
Current device size: 15726703104 bytes (15727 MB)
New volume size    : 15726699008 bytes (15727 MB)
Checking filesystem consistency ...
100.00 percent completed
Accounting clusters ...
Space in use       : 5652 MB (67,4%)
Collecting resizing constraints ...
WARNING: The disk has bad sector! This can cause reliability problems!
Bad clusters:  1073652 - 1073652
The NTFS volume has at least 1 bad sector.
WARNING: Every sanity check passed and only the dangerous operations left.
Make sure that important data has been backed up! Power outage or computer
crash may result major data loss!
Are you sure you want to proceed (y/[n])? y
Schedule chkdsk for NTFS consistency check at Windows boot time ...
Resetting $LogFile ... (this might take a while)
Updating $BadClust file ...
Updating $Bitmap file ...
Updating Boot record ...
Syncing device ...
Successfully resized NTFS on device '/dev/hda1'.
Comment 3 Plors (Bart H) 2006-07-26 17:43:40 UTC
>The best decision would be to display full warning info from ntfsresize output
>(for example to display button "More info..." on the error dialog and when user
>click's on this button, then full warning info from ntfsresize output should be
>displayed.

All that kind of stuff is in the operationdetails, so that shouldn't be a problem.

I agree it isn't very neat to enlarge the partition and leave the filesystem in it's original size (Whatever the reason). I should probably think of a fix for that.
Also, i have to think about what to do in case of badblocks. Best would still be if the user could somehow pass arguments to the command (by means of checkboxes of course). 
Hopefully, next month i have some more time at my hands and i can start implementing stuff like this.

For the moment, thanks for the headsup! 
Comment 4 Roger Heathcote 2010-05-11 05:04:03 UTC
Hi there, this bugs been nibbling at me recenty (4 years later ;)

I think there should be a stern warning followed by an option to proceed. I dunno where ntfsresize gets it's info from but forcing it to press ahead with --bad-sectors seems to work fine for me. The warnings it issues are not even always factual - I think I tend to see them because I often clone my customers failing drives (which sometimes have a little corruption) onto fresh ones which are 100% healthy. Even after a good spinriting and a heavy dose of CHKDSK /R and despite them booting the OS just fine ntfsresize still reports phantom hardware errors on the drive. I know they are phantom as the drives are rand new, SMART is turned on and I can see there haven't been any read/write/seek errors at all yet.

Interestingly when the resizing fails for me in gparted it doesn't seem to leave the partition expanded as mentioned above, I have to expand it by hand (as per the man page) before running ntfsresize so, given how unpleasant most people will find fdisk, offering to ignore these warnings could be a massive usability win.

Cheers,

What lang is gparted in BTW, if it's Python I may be able to make a patch :)
Comment 5 Curtis Gedak 2010-05-12 17:05:56 UTC
(In reply to comment #4)
> What lang is gparted in BTW, if it's Python I may be able to make a patch :)

GParted is written in C++.  You can learn more about how to help with GParted and view the latest source code git repository at the GParted web site:
http://gparted.sourceforge.net
Comment 6 Phillip Susi 2013-05-02 15:27:45 UTC
I think this should be closed as wontfix as enabling this option is unsafe.  If you have bad clusters you need to address that problem first.  If it is the result of copying from a bad drive to a new one, you can run chkdsk /b in Windows to re-test those clusters and clear them from the bad cluster list if they are now ok.  You can also unconditionally clear the bad cluster list with ntfsfix -b.
Comment 7 Curtis Gedak 2013-05-03 16:17:01 UTC
I agree that including the "-b" (also known as "--bad-sectors") flag by default is not a good idea.

The other part of this request is to make it optionally available to enable the "-b" flag.

Currently the GParted code does not permit setting file system specific flags through the GUI.  This would involve a significant rewrite of the code and would add complexity to the interface.

I think that Phillip correctly points out in comment #6 that a person should address the bad clusters problem first before trying to resize a partition.

Mike,

I would be interested to hear your thoughts on this request.
Comment 8 Mike Fleetwood 2013-05-04 11:24:51 UTC
I agree with closing this bug with RESOLVED / WONTFIX.

GParted currently reacts safely.  Namely stopping and showing the error
to the user, which includes the recommended corrective actions.


(In reply to comment #4)
> Interestingly when the resizing fails for me in gparted it doesn't seem to
> leave the partition expanded as mentioned above, I have to expand it by hand
> (as per the man page) before running ntfsresize so, given how unpleasant most
> people will find fdisk, offering to ignore these warnings could be a massive
> usability win.

I have simulated the case of ntfsresize failing, for example because of
bad blocks.  When resizing NTFS GParted does:

1) Check file system for errors using "ntfsresize -P -i -f -v /dev/PTN"
2) Grow partition using libparted API
3) Check file system for errors using "ntfsresize -P -i -f -v /dev/PTN"
4) Simulate growing file system with "ntfsresize -P -f -f /dev/PTN -n"
5) Grow file system with "ntfsresize -P -f -f /dev/PTN"

As the check file system is performed using the ntfsresize executable
and it reports failure on bad blocks it would be expected to fail the
operation at step (1) before the partition had been grown in step (2).