1 (edited by gedakc 2012-09-05 01:06:40)

Topic: Proposition of a tutorial for the NTFS size bug

Draft of the Tutorial, tell me if it's clear enough... and may be if it's quite right too ^^:
(inspiring from thread: http://gparted-forum.surf4.info/viewtopic.php?id=13879)

What is the issue?
Your version of parted have a bug that not wrote down the good new NTFS size in the PBR
Is that unrepairable?
No, just made little hexadecimal operation, follow the blue ribbon:

  • Know the right size of your new NTFS partition:

Make a parted /dev/sda unit s print ,
Write down the number of the size column, minus 1 (important cause: The NTFS volume size is always 1 sector less than the total number of sectors in the partition table entry because the NTFS backup sector is not considered part of the NTFS volume.).

Example:

I had a 160 GB NTFS partition. I would have now a 90GB, unfortunatly I have used the bad GParted version...
So I made parted /dev/sda unit s print:

    root@debian:~# parted /dev/sda unit s print
    Model: ATA Hitachi HTS72321 (scsi)
    Disk /dev/sda: 312581808s
    Sector size (logical/physical): 512B/512B
    Partition Table: msdos

    Number  Start  End         Size        Type     File system  Flags
    1      63s    169212644s  169212582s  primary  ntfs         boot

So my real NTFS size is 169212582 -1 = 169212581

  • Convert it in hexadecimal:

convert it in hexadecimal, and inverse the order.

Example:

My new NTFS Partition is  169212581
take bc or windws calc:
[root@P0030-H6530-Niji ~]#  echo "obase=16;169212581"|bc
A15FAA5

invert result: A5 FA 15 0A (yes there's a zero before A ^^)

  • Write your pbr:

*** EDIT by gedakc 2010-02-18:  The value 63 is the starting sector of the NTFS file system partition.  It might differ on your system.

Write your pbr in a file: dd if=/dev/sda of=/some/where/myCurrentPbr.pbr bs=512 count=1 skip=63
Make a backup cp /some/where/myCurrentPbr.pbr /some/where/myCurrentPbr.bak

  • Edit the pbr you saved:

*** EDIT by gedakc 2010-02-18: An alternative to vim for hexadecimal editing is hexedit.

Edit it with vim,

vim -b /some/where/myCurrentPbr.pbr
:set display=uhex
:%!xxd

Look for the row 00000020 (the third row), and replace the 3rd column with your inverted Hexadecimal value magic number!

The change I have made to the file is from a length of 312,560,568 sectors:
00000020   00 00 00 00  80 00 80 00  B8 4B A1 12  00 00 00 00
To a new length of 169,212,581 sectors:
00000020   00 00 00 00  80 00 80 00  A5 FA 15 0A  00 00 00 00

Save the file.

:%!xxd -r
:wq!

  • Write to your pbr:

NOTE:  Be extra careful when entering the commands.  Data loss could result otherwise.

dd if=/some/where/myCurrentPbr.pbr of=/dev/sda bs=512 count=1 seek=63

  • Reboot, enjoy and make donation to Master gedakc

2

Re: Proposition of a tutorial for the NTFS size bug

Hi greegthegeek.  This is a very good start to the tutorial.  From  smile

Following are a few suggestions for improvement.  Feel free to use or ignore these comments as you see fit.


1)  What is the issue?

There are a combination of factors that cause the issue to occur.  From a user perspective, the easiest way to identify the problem is the error message they see when trying to use the NTFS partition.

I suggest you might consider replacing the text:

Your version of parted have a bug that not wrote down the good new NTFS size in the PBR

with the following text:

You are experiencing problems with your NTFS file system (Windows will not boot, cannot mount file system), and the following error message can be seen using GParted when the partition is selected and the menu "Partition --> Information" is chosen:

ERROR: Current NTFS volume size is bigger than the device size!


2)  This suggestion is quite small (basically changing from a double negative into a positive).

Instead of saying:  "Is that unrepairable?"
I suggest: "Is this situation recoverable?"

And
Instead of saying:  "No, just made little hexadecimal operation, follow the blue ribbon:"
I suggest: "Yes the situation is recoverable.  Just use the following steps:"


3)  Add a step to find the location of the NTFS partition boot sector.

In this example, the start of the NTFS file system contained in partition 1 is at sector 63.  Hence the number 63 is used in both of the dd commands.  If the NTFS partition started at a different sector, such as 2048, then 2048 would need to be used with the "skip" and "seek" options of the dd commands.

3

Re: Proposition of a tutorial for the NTFS size bug

I would recommend using hexedit over vim.  I tried this vim method twice and both times ended up with a 2143 byte file that could have hosed my machine.

hexedit got it right the first time.  It's easier to make your changes, F2 to save and control+c to exit.

4 (edited by stern_1000 2010-01-22 10:01:02)

Re: Proposition of a tutorial for the NTFS size bug

I have sucessfull solved my problem with the info from this tutorial. And I confirm that hexedit is easier to use than vim (for with this tools untrained people like me) and produces the prober file size.

5

Re: Proposition of a tutorial for the NTFS size bug

I take the initiative to make this thread sticky, because it was already helpful to several members and GParted users, as reported in the forum sections.
We hope that newer stable versions of the livecd will fix this problem.

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

6 (edited by holka 2010-02-01 22:56:32)

Re: Proposition of a tutorial for the NTFS size bug

Hello, this tutorial is wonderful help. It solved my disaster:

I copied two partitions from an internal hdd to an external usb hdd. After gparted reported errors I was surprised that not the copied partitions were corrupted but the last existing partition on the usb hdd.

My geometry:

Die Anzahl der Zylinder für diese Platte ist auf 48641 gesetzt.
Daran ist nichts verkehrt, aber das ist größer als 1024 und kann
in bestimmten Konfigurationen Probleme hervorrufen mit:
1) Software, die zum Bootzeitpunkt läuft (z. B. ältere LILO-Versionen)
2) Boot- und Partitionierungssoftware anderer Betriebssysteme
   (z. B. DOS FDISK, OS/2 FDISK)

Befehl (m für Hilfe): p

Platte /dev/sda: 400.1 GByte, 400088457216 Byte
255 Köpfe, 63 Sektoren/Spur, 48641 Zylinder
Einheiten = Zylinder von 16065 × 512 = 8225280 Bytes
Disk identifier: 0xcac4ec68

   Gerät  boot.     Anfang        Ende     Blöcke   Id  System
/dev/sda1   *           1        9436    75794638+   7  HPFS/NTFS
/dev/sda2            9437       17700    66380580    7  HPFS/NTFS
/dev/sda3           17701       30510   102896325    7  HPFS/NTFS
Modell: Hitachi HDP725040GLA360 (scsi)
Festplatte  /dev/sda:  781422768s
Sektorgröße (logisch/physisch): 512B/512B
Partitionstabelle: msdos

Nummer  Anfang      Ende        Größe       Typ      Dateisystem  Flags
 1      63s         151589339s  151589277s  primary  ntfs         boot
 2      151589340s  284350499s  132761160s  primary  ntfs
 3      284350500s  490143149s  205792650s  primary  ntfs

Here the log:

GParted 0.4.7-git

Libparted 1.9.0
Create Extended Partition #1 (extended, 138.89 GiB) on /dev/sdb  00:00:01    ( SUCCESS )
         
create empty partition  00:00:01    ( SUCCESS )
         
path: /dev/sdb4
start: 490143150
end: 781417664
size: 291274515 (138.89 GiB)

========================================
Copy /dev/sda1 to /dev/sdb (start at 233.72 GiB)  00:00:09    ( SUCCESS )
         
calibrate /dev/sda1  00:00:00    ( SUCCESS )
         
path: /dev/sda1
start: 63
end: 129050144
size: 129050082 (61.54 GiB)
check file system on /dev/sda1 for errors and (if possible) fix them  00:00:01    ( SUCCESS )
         
ntfsresize -P -i -f -v /dev/sda1
         
ntfsresize v2.0.0 (libntfs 10:0:0)
Device name : /dev/sda1
NTFS volume version: 3.1
Cluster size : 4096 bytes
Current volume size: 66073641472 bytes (66074 MB)
Current device size: 66073641984 bytes (66074 MB)
Checking for bad sectors ...
Checking filesystem consistency ...
Accounting clusters ...
Space in use : 108 MB (0.2%)
Collecting resizing constraints ...
Estimating smallest shrunken size supported ...
File feature Last used at By inode
$MFT : 3222 MB 0
$MFTMirr : 1 MB 1
Ordinary : 3222 MB 6
You might resize at 3221491712 bytes or 3222 MB (freeing 62852 MB).
Please make a test run using both the -n and -s options before real resizing!
create empty partition  00:00:01    ( SUCCESS )
         
path: /dev/sdb5
start: 490143213
end: 619193294
size: 129050082 (61.54 GiB)
set partition type on /dev/sdb5  00:00:02    ( SUCCESS )
         
new partition type: ntfs
copy file system of /dev/sda1 to /dev/sdb5  00:00:05    ( SUCCESS )
         
ntfsclone -f --overwrite /dev/sdb5 /dev/sda1
         
NTFS volume version: 3.1
Cluster size : 4096 bytes
Current volume size: 66073640960 bytes (66074 MB)
Current device size: 66073641984 bytes (66074 MB)
Scanning volume ...
100.00 percent completed
Accounting clusters ...
Space in use : 108 MB (0.2%)
Cloning NTFS ...
100.00 percent completed
Syncing ...
ntfsclone v2.0.0 (libntfs 10:0:0)
update boot sector of ntfs file system on /dev/sdb5  00:00:00    ( SUCCESS )
check file system on /dev/sdb5 for errors and (if possible) fix them  00:00:00    ( SUCCESS )
         
ntfsresize -P -i -f -v /dev/sdb5
         
ntfsresize v2.0.0 (libntfs 10:0:0)
Device name : /dev/sdb5
NTFS volume version: 3.1
Cluster size : 4096 bytes
Current volume size: 66073641472 bytes (66074 MB)
Current device size: 66073641984 bytes (66074 MB)
Checking for bad sectors ...
Checking filesystem consistency ...
Accounting clusters ...
Space in use : 108 MB (0.2%)
Collecting resizing constraints ...
Estimating smallest shrunken size supported ...
File feature Last used at By inode
$MFT : 3222 MB 0
$MFTMirr : 1 MB 1
Ordinary : 3222 MB 6
You might resize at 3221491712 bytes or 3222 MB (freeing 62852 MB).
Please make a test run using both the -n and -s options before real resizing!
grow file system to fill the partition  00:00:00    ( SUCCESS )
         
run simulation  00:00:00    ( SUCCESS )
         
ntfsresize -P --force /dev/sdb5 --no-action
         
ntfsresize v2.0.0 (libntfs 10:0:0)
Device name : /dev/sdb5
NTFS volume version: 3.1
Cluster size : 4096 bytes
Current volume size: 66073641472 bytes (66074 MB)
Current device size: 66073641984 bytes (66074 MB)
New volume size : 66073637376 bytes (66074 MB)
Nothing to do: NTFS volume size is already OK.
real resize  00:00:00    ( SUCCESS )
         
ntfsresize -P --force /dev/sdb5
         
ntfsresize v2.0.0 (libntfs 10:0:0)
Device name : /dev/sdb5
NTFS volume version: 3.1
Cluster size : 4096 bytes
Current volume size: 66073641472 bytes (66074 MB)
Current device size: 66073641984 bytes (66074 MB)
New volume size : 66073637376 bytes (66074 MB)
Nothing to do: NTFS volume size is already OK.

========================================
Shrink copy of /dev/sda1 from 61.54 GiB to 3.02 GiB  00:00:06    ( SUCCESS )
         
calibrate copy of /dev/sda1  00:00:01    ( SUCCESS )
         
path: /dev/sdb5
start: 490143213
end: 619193294
size: 129050082 (61.54 GiB)
check file system on /dev/sdb5 for errors and (if possible) fix them  00:00:00    ( SUCCESS )
         
ntfsresize -P -i -f -v /dev/sdb5
         
ntfsresize v2.0.0 (libntfs 10:0:0)
Device name : /dev/sdb5
NTFS volume version: 3.1
Cluster size : 4096 bytes
Current volume size: 66073641472 bytes (66074 MB)
Current device size: 66073641984 bytes (66074 MB)
Checking for bad sectors ...
Checking filesystem consistency ...
Accounting clusters ...
Space in use : 108 MB (0.2%)
Collecting resizing constraints ...
Estimating smallest shrunken size supported ...
File feature Last used at By inode
$MFT : 3222 MB 0
$MFTMirr : 1 MB 1
Ordinary : 3222 MB 6
You might resize at 3221491712 bytes or 3222 MB (freeing 62852 MB).
Please make a test run using both the -n and -s options before real resizing!
shrink file system  00:00:03    ( SUCCESS )
         
run simulation  00:00:03    ( SUCCESS )
         
ntfsresize -P --force /dev/sdb5 -s 3240728063 --no-action
         
ntfsresize v2.0.0 (libntfs 10:0:0)
Device name : /dev/sdb5
NTFS volume version: 3.1
Cluster size : 4096 bytes
Current volume size: 66073641472 bytes (66074 MB)
Current device size: 66073641984 bytes (66074 MB)
New volume size : 3240722944 bytes (3241 MB)
Checking filesystem consistency ...
Accounting clusters ...
Space in use : 108 MB (0.2%)
Collecting resizing constraints ...
Needed relocations : 0 (0 MB)
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 ...
The read-only test run ended successfully.
real resize  00:00:00    ( SUCCESS )
         
ntfsresize -P --force /dev/sdb5 -s 3240728063
         
ntfsresize v2.0.0 (libntfs 10:0:0)
Device name : /dev/sdb5
NTFS volume version: 3.1
Cluster size : 4096 bytes
Current volume size: 66073641472 bytes (66074 MB)
Current device size: 66073641984 bytes (66074 MB)
New volume size : 3240722944 bytes (3241 MB)
Checking filesystem consistency ...
Accounting clusters ...
Space in use : 108 MB (0.2%)
Collecting resizing constraints ...
Needed relocations : 0 (0 MB)
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/sdb5'.
You can go on to shrink the device for example with Linux fdisk.
IMPORTANT: When recreating the partition, make sure that you
1) create it at the same disk sector (use sector as the unit!)
2) create it with the same partition type (usually 7, HPFS/NTFS)
3) do not make it smaller than the new NTFS filesystem size
4) set the bootable flag for the partition if it existed before
Otherwise you won't be able to access NTFS or can't boot from the disk!
If you make a mistake and don't have a partition table backup then you
can recover the partition table by TestDisk or Parted's rescue mode.
shrink partition from 61.54 GiB to 3.02 GiB  00:00:01    ( SUCCESS )
         
old start: 490143213
old end: 619193294
old size: 129050082 (61.54 GiB)
new start: 490143213
new end: 496472759
new size: 6329547 (3.02 GiB)
check file system on /dev/sdb5 for errors and (if possible) fix them  00:00:00    ( SUCCESS )
         
ntfsresize -P -i -f -v /dev/sdb5
         
ntfsresize v2.0.0 (libntfs 10:0:0)
Device name : /dev/sdb5
NTFS volume version: 3.1
Cluster size : 4096 bytes
Current volume size: 3240722944 bytes (3241 MB)
Current device size: 3240728064 bytes (3241 MB)
Checking for bad sectors ...
Checking filesystem consistency ...
Accounting clusters ...
Space in use : 106 MB (3.2%)
Collecting resizing constraints ...
Estimating smallest shrunken size supported ...
File feature Last used at By inode
$MFT : 3222 MB 0
$MFTMirr : 1 MB 1
Ordinary : 3190 MB 96
You might resize at 3221491712 bytes or 3222 MB (freeing 19 MB).
Please make a test run using both the -n and -s options before real resizing!
grow file system to fill the partition  00:00:01    ( SUCCESS )
         
run simulation  00:00:00    ( SUCCESS )
         
ntfsresize -P --force /dev/sdb5 --no-action
         
ntfsresize v2.0.0 (libntfs 10:0:0)
Device name : /dev/sdb5
NTFS volume version: 3.1
Cluster size : 4096 bytes
Current volume size: 3240722944 bytes (3241 MB)
Current device size: 3240728064 bytes (3241 MB)
New volume size : 3240722944 bytes (3241 MB)
Nothing to do: NTFS volume size is already OK.
real resize  00:00:01    ( SUCCESS )
         
ntfsresize -P --force /dev/sdb5
         
ntfsresize v2.0.0 (libntfs 10:0:0)
Device name : /dev/sdb5
NTFS volume version: 3.1
Cluster size : 4096 bytes
Current volume size: 3240722944 bytes (3241 MB)
Current device size: 3240728064 bytes (3241 MB)
New volume size : 3240722944 bytes (3241 MB)
Nothing to do: NTFS volume size is already OK.

========================================
Copy /dev/sda3 to /dev/sdb (start at 236.74 GiB)  00:13:47    ( SUCCESS )
         
calibrate /dev/sda3  00:00:00    ( SUCCESS )
         
path: /dev/sda3
start: 129050145
end: 265522319
size: 136472175 (65.08 GiB)
check file system on /dev/sda3 for errors and (if possible) fix them  00:00:02    ( SUCCESS )
         
ntfsresize -P -i -f -v /dev/sda3
         
ntfsresize v2.0.0 (libntfs 10:0:0)
Device name : /dev/sda3
NTFS volume version: 3.1
Cluster size : 4096 bytes
Current volume size: 69873750528 bytes (69874 MB)
Current device size: 69873753600 bytes (69874 MB)
Checking for bad sectors ...
Checking filesystem consistency ...
Accounting clusters ...
Space in use : 18919 MB (27.1%)
Collecting resizing constraints ...
Estimating smallest shrunken size supported ...
File feature Last used at By inode
$MFT : 35118 MB 0
Multi-Record : 38227 MB 47016
$MFTMirr : 34937 MB 1
Compressed : 38227 MB 71096
Sparse : 38786 MB 58632
Ordinary : 41252 MB 71585
You might resize at 18918674432 bytes or 18919 MB (freeing 50955 MB).
Please make a test run using both the -n and -s options before real resizing!
create empty partition  00:00:03    ( SUCCESS )
         
path: /dev/sdb6
start: 496472823
end: 632960999
size: 136488177 (65.08 GiB)
set partition type on /dev/sdb6  00:00:02    ( SUCCESS )
         
new partition type: ntfs
copy file system of /dev/sda3 to /dev/sdb6  00:13:29    ( SUCCESS )
         
ntfsclone -f --overwrite /dev/sdb6 /dev/sda3
         
NTFS volume version: 3.1
Cluster size : 4096 bytes
Current volume size: 69873750016 bytes (69874 MB)
Current device size: 69873753600 bytes (69874 MB)
Scanning volume ...
100.00 percent completed
Accounting clusters ...
Space in use : 18919 MB (27.1%)
Cloning NTFS ...
100.00 percent completed
Syncing ...
ntfsclone v2.0.0 (libntfs 10:0:0)
update boot sector of ntfs file system on /dev/sdb6  00:00:00    ( SUCCESS )
check file system on /dev/sdb6 for errors and (if possible) fix them  00:00:03    ( SUCCESS )
         
ntfsresize -P -i -f -v /dev/sdb6
         
ntfsresize v2.0.0 (libntfs 10:0:0)
Device name : /dev/sdb6
NTFS volume version: 3.1
Cluster size : 4096 bytes
Current volume size: 69873750528 bytes (69874 MB)
Current device size: 69881946624 bytes (69882 MB)
Checking for bad sectors ...
Checking filesystem consistency ...
Accounting clusters ...
Space in use : 18919 MB (27.1%)
Collecting resizing constraints ...
Estimating smallest shrunken size supported ...
File feature Last used at By inode
$MFT : 35118 MB 0
Multi-Record : 38227 MB 47016
$MFTMirr : 34937 MB 1
Compressed : 38227 MB 71096
Sparse : 38786 MB 58632
Ordinary : 41252 MB 71585
You might resize at 18918674432 bytes or 18919 MB (freeing 50955 MB).
Please make a test run using both the -n and -s options before real resizing!
grow file system to fill the partition  00:00:08    ( SUCCESS )
         
run simulation  00:00:05    ( SUCCESS )
         
ntfsresize -P --force /dev/sdb6 --no-action
         
ntfsresize v2.0.0 (libntfs 10:0:0)
Device name : /dev/sdb6
NTFS volume version: 3.1
Cluster size : 4096 bytes
Current volume size: 69873750528 bytes (69874 MB)
Current device size: 69881946624 bytes (69882 MB)
New volume size : 69881942528 bytes (69882 MB)
Checking filesystem consistency ...
Accounting clusters ...
Space in use : 18919 MB (27.1%)
Collecting resizing constraints ...
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 ...
The read-only test run ended successfully.
real resize  00:00:03    ( SUCCESS )
         
ntfsresize -P --force /dev/sdb6
         
ntfsresize v2.0.0 (libntfs 10:0:0)
Device name : /dev/sdb6
NTFS volume version: 3.1
Cluster size : 4096 bytes
Current volume size: 69873750528 bytes (69874 MB)
Current device size: 69881946624 bytes (69882 MB)
New volume size : 69881942528 bytes (69882 MB)
Checking filesystem consistency ...
Accounting clusters ...
Space in use : 18919 MB (27.1%)
Collecting resizing constraints ...
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/sdb6'.

========================================
Shrink copy of /dev/sda3 from 65.08 GiB to 17.63 GiB  00:00:20    ( ERROR )
         
calibrate copy of /dev/sda3  00:00:01    ( SUCCESS )
         
path: /dev/sdb6
start: 496472823
end: 632960999
size: 136488177 (65.08 GiB)
check file system on /dev/sdb6 for errors and (if possible) fix them  00:00:02    ( SUCCESS )
         
ntfsresize -P -i -f -v /dev/sdb6
         
ntfsresize v2.0.0 (libntfs 10:0:0)
Device name : /dev/sdb6
NTFS volume version: 3.1
Cluster size : 4096 bytes
Current volume size: 69881942528 bytes (69882 MB)
Current device size: 69881946624 bytes (69882 MB)
Checking for bad sectors ...
Checking filesystem consistency ...
Accounting clusters ...
Space in use : 18919 MB (27.1%)
Collecting resizing constraints ...
Estimating smallest shrunken size supported ...
File feature Last used at By inode
$MFT : 35118 MB 0
Multi-Record : 38227 MB 47016
$MFTMirr : 34937 MB 1
Compressed : 38227 MB 71096
Sparse : 38786 MB 58632
Ordinary : 41252 MB 71585
You might resize at 18918674432 bytes or 18919 MB (freeing 50963 MB).
Please make a test run using both the -n and -s options before real resizing!
shrink file system  00:00:14    ( ERROR )
         
run simulation  00:00:14    ( ERROR )
         
ntfsresize -P --force /dev/sdb6 -s 18934562303 --no-action
         
ntfsresize v2.0.0 (libntfs 10:0:0)
Device name : /dev/sdb6
NTFS volume version: 3.1
Cluster size : 4096 bytes
Current volume size: 69881942528 bytes (69882 MB)
Current device size: 69881946624 bytes (69882 MB)
New volume size : 18934555136 bytes (18935 MB)
Checking filesystem consistency ...
Accounting clusters ...
Space in use : 18919 MB (27.1%)
Collecting resizing constraints ...
Needed relocations : 1336804 (5476 MB)
Schedule chkdsk for NTFS consistency check at Windows boot time ...
Resetting $LogFile ... (this might take a while)
Relocating needed data ...
ERROR: Extended record needed (1752 > 1024), not yet supported!
Please try to free less space.
check file system on /dev/sdb6 for errors and (if possible) fix them  00:00:03    ( SUCCESS )
         
ntfsresize -P -i -f -v /dev/sdb6
         
ntfsresize v2.0.0 (libntfs 10:0:0)
Device name : /dev/sdb6
NTFS volume version: 3.1
Cluster size : 4096 bytes
Current volume size: 69881942528 bytes (69882 MB)
Current device size: 69881946624 bytes (69882 MB)
Checking for bad sectors ...
Checking filesystem consistency ...
Accounting clusters ...
Space in use : 18919 MB (27.1%)
Collecting resizing constraints ...
Estimating smallest shrunken size supported ...
File feature Last used at By inode
$MFT : 35118 MB 0
Multi-Record : 38227 MB 47016
$MFTMirr : 34937 MB 1
Compressed : 38227 MB 71096
Sparse : 38786 MB 58632
Ordinary : 41252 MB 71585
You might resize at 18918674432 bytes or 18919 MB (freeing 50963 MB).
Please make a test run using both the -n and -s options before real resizing!
grow file system to fill the partition  00:00:00    ( SUCCESS )
         
run simulation  00:00:00    ( SUCCESS )
         
ntfsresize -P --force /dev/sdb6 --no-action
         
ntfsresize v2.0.0 (libntfs 10:0:0)
Device name : /dev/sdb6
NTFS volume version: 3.1
Cluster size : 4096 bytes
Current volume size: 69881942528 bytes (69882 MB)
Current device size: 69881946624 bytes (69882 MB)
New volume size : 69881942528 bytes (69882 MB)
Nothing to do: NTFS volume size is already OK.
real resize  00:00:00    ( SUCCESS )
         
ntfsresize -P --force /dev/sdb6
         
ntfsresize v2.0.0 (libntfs 10:0:0)
Device name : /dev/sdb6
NTFS volume version: 3.1
Cluster size : 4096 bytes
Current volume size: 69881942528 bytes (69882 MB)
Current device size: 69881946624 bytes (69882 MB)
New volume size : 69881942528 bytes (69882 MB)
Nothing to do: NTFS volume size is already OK.

========================================
Copy /dev/sda2 to /dev/sdb (start at 254.37 GiB)

========================================
Shrink copy of /dev/sda2 from 63.31 GiB to 60.27 GiB

========================================
Create Logical Partition #2 (ntfs, 57.97 GiB) on /dev/sdb

========================================

The solution - thank you for the great tutorial:

I followed the steps. But i inserted the appropriated value for dd according to my geometry and used also another hex values - what a suprise ; )

205792650-1=205792649

echo "obase=16;205792649"|bc
resulted in: C442589

reverted: 8925440C

Backup:

dd if=/dev/sdb of=/mnt/tmp/theCurrentPbr.pbr bs=512 count=1 skip=284350500

Write:

dd if=/mnt/tmp/theCurrentPbr.pbr of=/dev/sdb bs=512 count=1 seek=284350500

7

Re: Proposition of a tutorial for the NTFS size bug

HELP, I downloaded Knoppix Linux on April 1 (jeez april fools day) and used GParted 0.4.8 to shrink my primary NTFS partition on XP from 500G to 125G.  I got the volume is bigger than the device error.  I followed the steps in the tutorial exactly while booted from CD in Knoppix, but after reboot GParted says file system unknown.  I do have a small FAT partition at beginning of drive as well, it is still recognized.  As someone noted, by start address was not 63, but 81920 and size was 257841654.  I used the seek=81920 on last step as well.

I really need to get drive back to be at least read able, please help.

8

Re: Proposition of a tutorial for the NTFS size bug

jhupp wrote:

HELP, I downloaded Knoppix Linux on April 1 (jeez april fools day) and used GParted 0.4.8 to shrink my primary NTFS partition on XP from 500G to 125G.  I got the volume is bigger than the device error.  I followed the steps in the tutorial exactly while booted from CD in Knoppix, but after reboot GParted says file system unknown.  I do have a small FAT partition at beginning of drive as well, it is still recognized.  As someone noted, by start address was not 63, but 81920 and size was 257841654.  I used the seek=81920 on last step as well.

I really need to get drive back to be at least read able, please help.

If you need help, please open a new forum post (not in this thread) and provide the information requested in the following link:
WARNING! Problem Resizing File Systems with GParted

9

Re: Proposition of a tutorial for the NTFS size bug

I just tried to shrink an NTFS partition with the gparted live 0.5.2-1 cd and had the resize bug.  Following the directions here got me back up and running.

Also, greegthegeek, if you do use vi to edit the file in xxd format, before saving, you need to convert it back with :%!xxd -r.

10 (edited by ilcorsaronero 2010-06-11 13:04:23)

Re: Proposition of a tutorial for the NTFS size bug

Please review your tutorial, when you say:

...
    To a new length of 169,212,581 sectors:
    00000020   00 00 00 00  80 00 80 00  A5 FA 15 0A  00 00 00 00

Save the file.

    :wq!

it should be:

    To a new length of 169,212,581 sectors:
    00000020   00 00 00 00  80 00 80 00  A5 FA 15 0A  00 00 00 00

Save the file.

    :%!xxd -r
    :wq!

Otherwise you will just get rubbery in your pbr, which ain't no good.

11

Re: Proposition of a tutorial for the NTFS size bug

Thanks oryan_dunn and ilcorsaronero for the suggested improvement to the tutorial.  This change has been made to the initial post.  smile

12

Re: Proposition of a tutorial for the NTFS size bug

Removed "NOT YET VALIDATED" from the thread title as this tutorial has been confirmed to work by  GParted users.

Thanks goes to greegthegeek for first proposing this tutorial, and also to all those who have tried the tutorial and noted updates and corrections needed.

13 (edited by nusrat432 2016-12-01 10:45:27)

Re: Proposition of a tutorial for the NTFS size bug

Thanks gedak for this nice discussion..
And also thanks to ilcorsaronero for the suggestion..

Nootropics

14

Re: Proposition of a tutorial for the NTFS size bug

big_smile I just want to thank all you guys for posting this great tutorial, I used UltraEdit on a Windows PC to edit my .pbr file, thats another alternative, but then again thank you!!!

15

Re: Proposition of a tutorial for the NTFS size bug

Hey there.
My girlfriend was thinking about switching to Linux since a few weeks and got to a decision yesterday finally. Choosing Sabayon we finally had a distro, too, and got to work. On the Desktop PC everything went fine. With GParted we partitioned the hard disk and fired up Sabayon install. Smooth, nice, good looking -> girldfriend happy.
She even was so happy that she decided to use Sabayon on her Notebook, too. Well, no problem and nothing easier than that. We fired up Parted Magic and used GParted again to partition the hard disk but had to shrink the Windows 7 C: partition this time.
And there we were stuck knee deep in the mess, GParted failed and we had the error message "Current NTFS Volume Size is bigger than the device size".
Because everything went way to fast for the notebook and no preparations were done, so finally no backup of important files, it now was up to me to find a solution and make C: accessable again.
Searching the net I found this threat and decided to give it a try. But ended up at "Write your pbr".
The problem was, that "dd if=/dev/sda of=/some/where/myCurrentPbr.pbr bs=512 count=1 skip=63" (skip, path and file name changed to according to the local setting) simply printed that there were a fault with BOOTMGR.
So back again and doing even more research on the net finally brought me to "TESTDISK", a tool put on Parted Magic, too, with which many different people fixed our problem very easely.
Just fire up TESTDISK in the terminal, than start with [ Analyze ], choose the appropriate disk and it's value ( [ intel ] in my case) and you become an overview about your disk partition table, which in my case told me that one partition is larger than the disk itself - we already had that, right?
So I went on with a backup.log of this partition table, just in case anything wents wrong a false partition table is better than no partition table. Then TESTDISK prints the partition table how it things it would be right. It looked right to me, so I decided to let TESTDISK write this partition table to disk.
And tadaaa, starting Windows 7 still needed Windows to do a auto repair, but after that everything was fine again. No data loss, nothing.

Just thought it would be nice to mention this and tell everybody that there maybe is an even easier way to recover the system!
Greetz

16

Re: Proposition of a tutorial for the NTFS size bug

Hello guys,

many thanks for this great tutorial!
My NTFS partition got broken by GParted and thanks to you, I was able to save my 45GB of valuable data!

Thanks!!!!!

Richard Gabriel alias DJ Dick from the Czech Republic

17

Re: Proposition of a tutorial for the NTFS size bug

oops
I managed to work out the new values to fix partition but just reversed the if and of and did not notice the seek instead of skip
dd if=/dev/sda of=sda1-ntfs.pbr bs=512 count=1 skip=31619072
Should have done
dd of=/dev/sda if=sda1-ntfs.pbr bs=512 count=1 seek=31619072
Now I have a hosed partition can I fix this

18

Re: Proposition of a tutorial for the NTFS size bug

pingnu wrote:

oops
I managed to work out the new values to fix partition but just reversed the if and of and did not notice the seek instead of skip
dd if=/dev/sda of=sda1-ntfs.pbr bs=512 count=1 skip=31619072
Should have done
dd of=/dev/sda if=sda1-ntfs.pbr bs=512 count=1 seek=31619072
Now I have a hosed partition can I fix this

No problem, because in such a case, you've only rewritten your (edited) file. Simply start again from the beginning...

19 (edited by pingnu 2011-01-17 17:57:41)

Re: Proposition of a tutorial for the NTFS size bug

dj_dick wrote:
pingnu wrote:

oops
I managed to work out the new values to fix partition but just reversed the if and of and did not notice the seek instead of skip
dd if=/dev/sda of=sda1-ntfs.pbr bs=512 count=1 skip=31619072
Should have done
dd of=/dev/sda if=sda1-ntfs.pbr bs=512 count=1 seek=31619072
Now I have a hosed partition can I fix this

No problem, because in such a case, you've only rewritten your (edited) file. Simply start again from the beginning...

Thanks I rewrote the unedited pbr using seek and I am back were I was I did try using the edited pbr with seek but it still failed. Perhaps I need to use hexedit rather than vi as previous post suggests. I also saved incorrectly  missing out the following two :%!xxd -r :wq! so ended up with 2k file which I wrote rather than a 512.

20

Re: Proposition of a tutorial for the NTFS size bug

If the file size grew then that would be a problem.  As dj_jick says, if you have your original copy of the PBR then you should be still be able to do the edit and then write the file to the correct location.

21

Re: Proposition of a tutorial for the NTFS size bug

Greetings, I have the same bug, yet I have to confirm before I make any unrecoverable mistakes big_smile

I do a parted /dev/sda unit s print
and get

Model: ATA WDC WD2500KS-00M (scsi)
Disk /dev/sda: 488397168s
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start       End         Size        Type      File system     Flags
 1      63s         20482874s   20482812s   primary   ntfs            boot
 2      20482936s   488396799s  467913864s  extended                  lba
 5      20482938s   448148345s  427665408s  logical   ntfs
 6      468772864s  487462911s  18690048s   logical   ext4
 7      487464960s  488396799s  931840s     logical   linux-swap(v1)

my broken HDD part is /dev/sda5 so I do a sudo dd if=/dev/sda5 of=~/Desktop/myCurrentPbr.pbr bs=512 count=1 skip=20482938

and with hexedit I get

00000000   2A 12 AC 60  69 93 91 35  14 C2 28 B9  03 48 A3 F2  *..`i..5..(..H..
00000010   37 52 C4 82  B8 B1 2F 48  20 64 B7 57  A0 3B 53 74  7R..../H d.W.;St
00000020   32 F0 C3 C2  69 C5 17 1E  57 84 73 2F  E7 63 46 78  2...i...W.s/.cFx
00000030   71 F7 23 32  94 4D 89 D3  EE F4 A8 7E  AC 15 CD 35  q.#2.M.....~...5
00000040   A5 52 FD 98  CD DC 39 73  6C E0 A2 7E  19 AE DF EA  .R....9sl..~....
00000050   00 ED 69 6A  E1 A1 DD 97  57 14 40 C9  76 CD 69 D6  ..ij....W.@.v.i.
00000060   12 F5 6C D0  7E 4D 6B BE  AC DC 31 EB  BC 4A 5F F6  ..l.~Mk...1..J_.
00000070   9B 92 50 37  D2 A8 3C 20  83 9D 5C 6C  C6 35 4F 8A  ..P7..< ..\l.5O.
00000080   E7 7C B4 F0  CC 3B 15 A9  84 EB 68 DD  F7 70 9E 07  .|...;....h..p..
00000090   EA 33 9B 5A  A9 2B BE E7  49 48 3C AA  25 C1 AB 9B  .3.Z.+..IH<.%...
000000A0   4C C8 1A C9  1A BE 22 E9  3B CE 99 A3  91 D1 DC 78  L.....".;......x
000000B0   55 A5 0C A6  AC 95 59 F6  5F EB B4 DE  71 19 4B FD  U.....Y._...q.K.
000000C0   F9 B8 FA 86  44 1F FA 7E  26 A4 D0 1C  2A 87 E6 EF  ....D..~&...*...
000000D0   10 30 D0 40  CF 8E 83 E9  53 43 B5 B1  F4 BE 01 AC  .0.@....SC......
000000E0   25 1D 69 4B  FE 05 9B B5  03 29 85 D1  F5 E4 1A 52  %.iK.....).....R
000000F0   15 F9 13 1B  B5 EB DD 55  EF 16 7B FD  AF 89 7C 25  .......U..{...|%
00000100   C7 ED 2B A4  6A 4D 64 2F  81 E4 6E E5  00 DB B1 87  ..+.jMd/..n.....
00000110   6E 19 E5 44  44 A3 CA 53  D9 93 18 CF  BF 7D E5 8E  n..DD..S.....}..
00000120   C8 0C 3B 4D  3F BF C6 8F  73 86 C5 E9  BF 22 F1 83  ..;M?...s...."..
00000130   ED 3C 71 9E  64 41 93 99  2F 05 9A 4D  F9 12 A4 B1  .<q.dA../..M....
00000140   BE B6 E2 E6  65 8B 08 61  11 9A 61 4F  E2 98 DC AD  ....e..a..aO....
00000150   75 9B 49 45  A9 34 59 68  7C 6D C2 B4  93 E7 42 84  u.IE.4Yh|m....B.
00000160   55 CC DD 7E  F7 B5 D6 13  45 5F 22 9B  65 B7 E6 7E  U..~....E_".e..~
---  myCurrentPbr.pbr       --0x0/0x200----------------------------------------

problem is, on 3rd column 3rd row the number I get is not same as the size of the disk.... Am I doing sth wrong? should I proceed with the operation and write the correct file size?

22

Re: Proposition of a tutorial for the NTFS size bug

messie, please create a new post to track your problem.  If many problems are in the same post then there is a greater likelihood of confusion and incorrect advice.

23

Re: Proposition of a tutorial for the NTFS size bug

I've been setting up windows VMs on KVM using an LVM partition and had to resize using a combination of lvresize and ntfsresize (sorry - not gparted so technically off thread) to expand the system disk of a Windows system volume.  Was using OTB Maverick (Ubuntu 10.10).  Everything worked OK until the guest Windows XP booted and explorer reported wrong disk size etc.

Your tutorial on tweaking the NTFS partition boot record saved me a lot of time.  I followed it (using vi), and now the Windows VM is now telling me everything matches!  Kudos mate!

This is no doubt something a lot of people will need to do in the near future with VMs etc.  I hear that fdisk still doesn't fix it in 2K8 and Windows 7.  I'm sure I'll be corrected if I'm wrong.

Thanks!

- slashdevnull

24

Re: Proposition of a tutorial for the NTFS size bug

Hello Wise and learned Guru,
I used the version of Gparted included with the Ubuntu 10.04 live CD. My ubuntu / Windows 7 dual boot wouldn't boot. I used my Grub rescue disk and was able to boot to Windows. I recovered all the partitions with a windows version of Testdisk.  I ran the Ubuntu live CD and discovered that Gparted saw the entire disk as unallocated. (The disk utility saw the partitions as did sudo fdisk -l (see below):
ubuntu@ubuntu:~$ sudo fdisk -l

Disk /dev/sda: 250.1 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x6b7bf252

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1         262     2097152    7  HPFS/NTFS
Partition 1 does not end on cylinder boundary.
/dev/sda2             262        5867    45028496+   7  HPFS/NTFS
/dev/sda3            5868       30402   197077387+   f  W95 Ext'd (LBA)
/dev/sda5            5868       25936   161204211    7  HPFS/NTFS
/dev/sda6           26007       29890    31198196   83  Linux
/dev/sda7           29891       30402     4103160   82  Linux swap / Solaris

After giving up trying to get my grub rescue disk to find ubuntu (and getting nothing but a Grub rescue> prompt without the rescue disk), I found my son successfully logged into Ubuntu the next morning! He reported that it just "worked".... Huh?
Gparted on the Ubuntu 10.04 live cd still doesn't see partitions though. I was hoping to repair this problem with your method as described on this page. (See below:)

ubuntu@ubuntu:~$ sudo parted /dev/sda unit s print
Error: Can't have a partition outside the disk!                           

I respectfully ask, "What now?"
Any help would be greatly appreciated.
hmm

25

Re: Proposition of a tutorial for the NTFS size bug

Would you be able to provide the output from the following command?

fdisk -l -u

where one of the options is a lower case "L" and not the number one.