1 (edited by greegthegeek 2009-12-22 10:50:50)

Topic: [SOLVED] Again a "Current NTFS volume size ..." with PRB and MBR

Hello world,

First, i'm sorry for posting a new "ERROR: Current NTFS volume size is bigger than the device size!"  issue! But I installed gparted on my usb stick few months ago, and decided to resize only this morning... and... you know... I'm in a bad position right now ^^.

Here is my asset info:
HP 6530b
Hitachi HTS72321 (SCSI)
One 160 GB Microsoft Partition, tried to create a 70 GB GNU/Linux one.

fdisk -l -u

root@debian:~# fdisk -l -u

Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders, total 312581808 sectors
Units = sectors of 1 * 512 = 512 bytes
Disk identifier: 0x80d2f3ee

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *          63   169212644    84606291    7  HPFS/NTFS

Disk /dev/sdb: 128 MB, 128974848 bytes
8 heads, 32 sectors/track, 984 cylinders, total 251904 sectors
Units = sectors of 1 * 512 = 512 bytes
Disk identifier: 0xe8470ef3

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *          32      250623      125296    b  W95 FAT32

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

I forget the PBR & MBR files:
PBR: http://dl.free.fr/p5QPako14 (done by the usual dd with skip=63)
MBR: http://dl.free.fr/oszuJVKUw

Hope that not everybody on xmas holidays!

Cheers and thanks,
GreeG

2

Re: [SOLVED] Again a "Current NTFS volume size ..." with PRB and MBR

Since it appears that you were trying to shrink the partition,  we will decrease the NTFS volume size to fit within the partition.

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

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

To apply this change:

1) Download the new NTFS PBR: sda1-greegthegreek_new.pbr

2) Load the new NTFS PBR on your hard disk.
NOTE:  Be extra careful when entering the commands.  Data loss could result otherwise.

dd if=sda1-greegthegreek_new.pbr of=/dev/sda bs=512 count=1 seek=63

3) Reboot the computer

4) Check that the file system is recognized in GParted

5) If all seems fine then I would advise booting into Windows and running "chkdsk /f /r" multiple times, until there are no more faults.

3

Re: [SOLVED] Again a "Current NTFS volume size ..." with PRB and MBR

Hi,

Many thanks! You did the trick again "Mandrake" (cf. comics Mandrake, not the distro)!

Just for my info, I understood due to your other post that the row 20 of the PBR file contains the size in hexa... but could you explain how you made the conversion?

I mean, tell me if i'm right:

312,560,568 sectors (former NTFS partition size) == B8 4B A1 12
And 169,212,581 sectors (New NTFS partition size)  == A5 FA 15 0A

that's it?

gedakc wrote:

Since it appears that you were trying to shrink the partition,  we will decrease the NTFS volume size to fit within the partition.

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
[...]

4

Re: [SOLVED] Again a "Current NTFS volume size ..." with PRB and MBR

Yes, you are right.  To convert the numbers you perform the following steps:

1) You start with the decimal number:

169,212,581

2) Then you convert the decimal number to hexadecimal:

0A15FAA5

3) Then you reverse order the byte pairs:

0A5FA150A

Which looks like the following with a space between the byte pairs:

A5 FA 15 0A

Hope that helps.

5 (edited by greegthegeek 2009-12-22 23:51:20)

Re: [SOLVED] Again a "Current NTFS volume size ..." with PRB and MBR

Many thanks again, I understand better now!

But, one question remained: I tried to modify my original pbr file with vim (in hexadecimal editor mode of course), and i wrote down what I tought right, but as my conversion was wrong, so I had a beautiful BIOS error... Could you tell me if you made other modifs in the pbr you sent to me? or the modif at the line #20 is the only one?

Maybe a "tutorial topic" could save you so much time wink?

Thanks again!
GreeG

6

Re: [SOLVED] Again a "Current NTFS volume size ..." with PRB and MBR

To edit the file I use the "hexedit" command.  The changes listed above are the only changes I made to the file.

A tutorial topic would be useful.  Would you be interested in writing one?
You can start a new post and then you come back to edit it and update the post as you learn more.  :-)

7

Re: [SOLVED] Again a "Current NTFS volume size ..." with PRB and MBR

I would definitely appreciate a tutorial!

8

Re: [SOLVED] Again a "Current NTFS volume size ..." with PRB and MBR

Draft of the Tutorial, tell me if it's clear enough... and may be if it's quite right too ^^:

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:

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 it with vim,

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

Look for the row 20, and replace the 3rd colum with you 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.

: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