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.).
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.
My new NTFS Partition is 169212581
take bc or windws calc:
[root@P0030-H6530-Niji ~]# echo "obase=16;169212581"|bc
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
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.
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