1 (edited by Palleman 2013-02-25 10:11:04)

Topic: Dynamic Disk NTFS Resize Problem

Hi!

I've tried to avoid writing this post, since I guess you guys have enough to do without me (and since I think I should manage this on my own), but I'm now stuck at this and have given up. Feel free to move this to a new thread if that is more appropriate.

It started with a Windows 2008 R2 Hyper-V dynamic-sized disk that got filled with nonsense, ending up with 1 TB in size. Deleting the files was easy, but then it took days to finally get the MFT et al defragmented and moved enough to step by step shrink it down to a reasonable size.

After each shrink I tried booting, which worked fine all the way including the next to last one. After the last one, I get "BOOTMGR is missing". Looking at the numbers, it seems that the partition table and the NTFS volume don't agree on the size - one says 30 GB, the other says 77 GB. The whole disk "is" 100 GB.

I've tried several partition tools, both commercial and open source. Some say 30 GB, others say 77 GB, none of them can fix it. Windows rescue tools are fine "fixing" the MBR (which is already fine), but doesn't find any Windows installation to fix BCD and things on. Some tools can even browse the files, but not fix the error.

The disk _should_ be one 100 MB "System Reserved", one 29.8 GB (where my files are) and the rest of the disk unallocated.

I have two copies of the VHD - one I keep read-only and one I have messed with. The one I have messed with is... messed up, but Below is the info from the original one (saved after the last shrinking).

I'm working on a Hyper-V virtual machine where I add the disks as VHDs and the CDs as ISO images.

Image of Paragon Hard Disk Manager, showing what it believes it is seeing on the original disk:
http://ithora.pal.pp.se/shared/paragon.png

At the bottom you got the partitions. HDM sees it as 77 GB.

At the top left you have the volumes. (I think) they are:

1, 100 MB: No idea.
2, 29.8 GB: After the last shrinking.
3, 99.9 GB: Before the next to last shrinking.
4, 9.9 GB: No idea.
5. 77.9 GB: Before the last shrinking.
6. The System Reserved volume.

Only #5 and #6 contain files - the first four are empty (according to HDM). #5 contains the files that should exist in #2.

I think the above includes a couple of deleted volumes?

At the top right you see the result of a "File integrity check" on the 77.9 GB partition. Note the size, roughly correlating to the 29.8 GB Volume #2.

I am dividing this into several posts - for readability, and since I can only have one link/image per post.

2

Re: Dynamic Disk NTFS Resize Problem

Using gparted-live-0.14.1-6-i486.iso:

Here's a picture of Gparted showing about the same things as HDM:
http://ithora.pal.pp.se/shared/gparted.png

Fdisk sees the 29.8 GB partition:

fidsk -l -u

root@debian:~# fdisk -l -u /dev/sda

Disk /dev/sda: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders, total 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x7b02b3af

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1              63        2047         992+  42  SFS
/dev/sda2   *        2048      206847      102400   42  SFS
/dev/sda3          206848    61646847    30720000   42  SFS
/dev/sda4        61646848   209713151    74033152   42  SFS

Parted agrees with fdisk:

parted /dev/sda unit s print

root@debian:~# parted /dev/sda unit s print
Model: Msft Virtual Disk (scsi)
Disk /dev/sda: 209715200s
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start      End         Size        Type     File system  Flags
 1      63s        2047s       1985s       primary
 2      2048s      206847s     204800s     primary  ntfs         boot
 3      206848s    61646847s   61440000s   primary  ntfs
 4      61646848s  209713151s  148066304s  primary

Testdisk 6.13 too:

testdisk:

Disk /dev/sda - 107 GB / 100 GiB - CHS 13054 255 63
Current partition structure:
     Partition                  Start        End    Size in sectors

 1 P W2K Dynamic/SFS          0   1  1     0  32 32       1985
 2 * W2K Dynamic/SFS          0  32 33    12 223 19     204800
 3 P W2K Dynamic/SFS         12 223 20  3837  86 25   61440000
 4 P W2K Dynamic/SFS       3837  86 26 13054  10 12  148066304

Testdisk quicksearch can find two volumes, but now it's not 29.8 GB any more.. now it's about 82 (why? I would have understood 77...):

testdisk quicksearch:

     Partition               Start        End    Size in sectors
>* HPFS - NTFS              0  32 33    12 223 19     204800 [System Reserved]
 P HPFS - NTFS             12 223 20 10189 229 17  163493881 [System]

Testdisk deeper search find some more (deleted) volumes:

testdisk deeper search:

>D HPFS - NTFS              0  32 33    12 223 19     204800 [System Reserved]
 D HPFS - NTFS             12 223 19    25 159  5     204800
 D HPFS - NTFS             12 223 20  3837  86 25   61440000 [System]
 D HPFS - NTFS             12 223 20 10189 229 17  163493881 [System]
 D HPFS - NTFS             12 223 20 10189 229 24  163493888 [System]
 D HPFS - NTFS             12 223 20 13053 167 42  209500160 [System]

Hey, my 29.8 GB volume is in there! But it is marked as deleted (why?). They're all marked as deleted?

Windows 2008 R2 diskpart can see this:

diskpart finds one disk:

Disk ###  Status   Size   Free  Dyn  Gpt
Disk 0    Online   99 GB  21 GB    *
Disk M0   Missing   0 B    0 B    *
Disk M1   Missing   0 B    0 B    *
Disk M2   Missing   0 B    0 B    *

I don't know what those missing disks are?
diskpart finds four partitions on disk 0:

Partition ###  Type          Size    Offset
Partition 1    Dynamic Data  992 KB    31 KB
Partition 2    Dynamic Data  100 MB  1024 KB
Partition 3    Dynamic Data   29 GB   101 MB
Partition 4    Dynamic Data   70 GB    29 GB

diskpart finds volumes:

Volume ###  Ltr  Label        Fs    Type     Size     Status   Info
Volume 0         System Rese  NTFS  Simple    100 MB  Healthy
Volume 1       System       NTFS  Simple     77 GB  Healthy
Volume 2                          Simple      9 GB  Healthy
Volume 3                          Simple     99 GB  Healthy
Volume 4                          Simple     29 GB  Healthy
Volume 5                          Simple    100 MB  Healthy
Volume 6    D  GRMSXFRER_E  UDF   DVD-ROM  2857 MB  Healthy

Next post will be after changing the size in the PBR at 206848.

3 (edited by Palleman 2013-02-25 10:11:18)

Re: Dynamic Disk NTFS Resize Problem

I ran dd if=/dev/sda of=palleman.pbr bs=512 count=1 skip=206848 and the size says F8B7BE09.
echo "ibase=16;09BEB7F8"|bc gives 163493880, which correlates with ~82 GB volume that testdisk found (and with one of the deleted ones).

echo "obase=16;61439999"|bc gives 3A97FFF, so it should be FF7FA903. So I change it to that, and the "BOOTMGR is missing" gets replaced by "0xc000000e - The boot selection failed because a required device is inaccessible" when I try to boot on the disk.

Here's what Windows 2008 R2 diskpart thinks now:

diskpart finds one disk:

Disk ###  Status   Size   Free  Dyn  Gpt
Disk 0    Foreign  99 GB  0B    *

Note that it is "foreign", and the missing disks are now… missing.

So I have to run import (which seems to go fine), and the foreign disk comes online.

diskpart finds partitions (same as before) on disk 0:

Partition ###  Type          Size    Offset
Partition 1    Dynamic Data  992 KB    31 KB
Partition 2    Dynamic Data  100 MB  1024 KB
Partition 3    Dynamic Data   29 GB   101 MB
Partition 4    Dynamic Data   70 GB    29 GB

diskpart finds volumes, same as before:

Volume ###  Ltr  Label        Fs    Type     Size     Status   Info
Volume 0    D  GRMSXFRER_E  UDF   DVD-ROM  2857 MB  Healthy
Volume 1         System Rese  NTFS  Simple    100 MB  Healthy
Volume 2       System       NTFS  Simple     77 GB  Healthy
Volume 3                          Simple      9 GB  Healthy
Volume 4                          Simple     99 GB  Healthy
Volume 5                          Simple     29 GB  Healthy
Volume 6                          Simple    100 MB  Healthy

My volume is there, but failed. The 77 GB volume is there, seems healthy (but won't boot). And all those volumes can't be healthy, since they occupy the same space.

The HDM shows no difference at all - all the numbers are the same. The disk editor in HDM confirms that the value is now FF7FA903:
http://ithora.pal.pp.se/shared/paragon2.png

The gparted GUI is also the same as before the change.

fdisk -l -u (no change):
root@debian:~# fdisk -l -u /dev/sda

Disk /dev/sda: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders, total 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x7b02b3af

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1              63        2047         992+  42  SFS
/dev/sda2   *        2048      206847      102400   42  SFS
/dev/sda3          206848    61646847    30720000   42  SFS
/dev/sda4        61646848   209713151    74033152   42  SFS

parted /dev/sda unit s print (no change):

root@debian:~# parted /dev/sda unit s print
Model: Msft Virtual Disk (scsi)
Disk /dev/sda: 209715200s
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start      End         Size        Type     File system  Flags
 1      63s        2047s       1985s       primary
 2      2048s      206847s     204800s     primary  ntfs         boot
 3      206848s    61646847s   61440000s   primary  ntfs
 4      61646848s  209713151s  148066304s  primary

testdisk (no change):

Disk /dev/sda - 107 GB / 100 GiB - CHS 13054 255 63
Current partition structure:
     Partition                  Start        End    Size in sectors

 1 P W2K Dynamic/SFS          0   1  1     0  32 32       1985
 2 * W2K Dynamic/SFS          0  32 33    12 223 19     204800
 3 P W2K Dynamic/SFS         12 223 20  3837  86 25   61440000
 4 P W2K Dynamic/SFS       3837  86 26 13054  10 12  148066304

testdisk quicksearch (I can see my change!):

     Partition               Start        End    Size in sectors
>* HPFS - NTFS              0  32 33    12 223 19     204800 [System Reserved]
 P HPFS - NTFS             12 223 20  3837  86 25   61440000 [System]

Any idea where I go wrong? Or am I doing the right thing so far, and just need to do some more stuff to get it up and running? It definitely seems like a mismatch in size (and number) between the NTFS volume(s) and the partition table, but why doesn't changing the size fix it then? In testdisk it looks OK after the change?

I'm stuck. sad I will surely donate if you get me out of this.

Tip for future versions of the live CD: Add a "start sshd" script that removes the hosts.deny line, removes the non-working key line and negates the separation line in sshd_config, prompts for a password and then starts sshd. Makes it much easier to copy and paste to these kind of posts, and the temporary nature of the live CD should be enough security by obscurity. Should look very nice as a checkbox in the network dialogue.

4

Re: Dynamic Disk NTFS Resize Problem

Played around some more with diskpart (after the size change). Importing the disks did more than making the partitions accessible - it also made the missing disks come back.

Detailing the 77 GB volume (#2) gives this:

Disk 0  Online  99 GB  21 GB  *

Read-Only: No
Hidden: no
No Default Drive Letter: Yes
Shadow Copy: No
Offline: No
Bitlocker Encrypted: No
Installable: Yes

Volume capacity: 29 GB
Volume Free Space: 13 GB

The volume still have size 77 GB, but the capacity is 29 GB? Wtf?

Detailing the 29.8 GB volume (#4) gives:

Disk M0  Missing  0 B  0 B  *

Read-Only: No
Hidden: No
No Default Drive Letter: No
Shadow Copy: No
Offline: No
BitLocker Encryptable: No
Installable: No

Virtual Disk Service error:
The object is in failed status.

5

Re: Dynamic Disk NTFS Resize Problem

Hi Palleman,

I have split these posts into a separate thread.  For each instance of a problem we highly recommend that a new thread is created in an effort to reduce the chances of mistaking these posts with the other problem instances.

From my understanding, it appears that the drive is being treated as a dynamic drive (ID type = 42).  This is a proprietary format known to Microsoft and not disclosed to the free software community.  ;-(

See:  Bug 634668 - Resizing of NTFS fails if partition type is 42

However, if there is truly no fourth partition on the drive, then you might use sfdisk in an attempt to correct the situation.

My assumptions are that:

  • sda1 is a small system reserved partition (< 1 MB)

  • sda2 is a system partition (~100 MB )

  • sda3 is a data partition (~ 30GB) containing an NTFS file system (~ 77 GB) that is larger than the partion.

  • sda4 is an invalid partition.

Based on this you might try using sfdisk to fix the problem using the following steps:

  • Create a copy of the partition table in an editable file using sfdisk

  • Edit the file to remove the sda4 partition

  • Edit the file to extend the size of the sda3 partition to reach to the end of the disk

  • Save the file

  • Write the file representation of the partition table to the physical disk using sfdisk.

For instructions on how to use sfdisk to edit partition tables see How-to Fix Invalid MSDOS Partition Tables.  The section on "How to Fix Partition Outside the Disk" is the most relevant to your situation.

If you need help, step-by-step, then let me know.  The first step would be to capture a copy of the partition table in a file using sfdisk, and to post the file contents here.

NOTE:  We highly recommend having a backup of your data before editing partitions.

6 (edited by Palleman 2013-03-01 09:15:07)

Re: Dynamic Disk NTFS Resize Problem

It's VHD, so I can make numerous backups.

Your assumptions are close, but sda2 is actually a "System reserved" partition, and the OS is installed in the 30/77 GB partition.

sda4 is (or should be) unallocated empty space.

But it doesn't make any difference for your advice. I will try sfdisk. Thanks!

7 (edited by Palleman 2013-03-10 11:03:08)

Re: Dynamic Disk NTFS Resize Problem

I followed your advice, and something quite funny happened. After the partition was made 99 GB (rest of the disk), and I load the disk on another Windows machine, Windows suddenly found the NTFS volume - and it was 29 GB! I was expecting a 70 GB NTFS volume, and was not looking forward to trying to shrink it again. Now I will (hopefully) not have to do that.

I have to online and import the "foreign" disk in Windows disk management, but after that I can access the files perfectly fine. And diskpart shows the volume as 29 GB and healthy, and no 77 GB volume. If I assign a drive letter to the 100 MB system partition, I can read the boot files. So everything is fine! I thought...

But when I assign the disk as the first disk to the original server, it still won't boot. It can find the 100 MB system partition (where BOOTMGR is, so I pass that error), but then it complains about inaccessible boot device. The startup rescue feature on a Windows 2008 R2 SP1 setup DVD can't find any Windows installations, and when I look at with diskpart from the DVD (after importing the "foregin" disk), it gives the same kind of incorrect volume list as before, including the 77 GB volume.

The diskpart version differs - the Windows machine has Diskpart 6.1.7601 and the DVD has Diskpart 6.1.7600.

So I'm a much closer, but still not there. I will continue with this later. I would probably save a lot of time with a fresh install (all data is recoverable), but this is now personal.

8 (edited by Palleman 2013-03-10 11:01:57)

Re: Dynamic Disk NTFS Resize Problem

I might be running into this GUID issue? http://www.symantec.com/business/suppor … TECH125582

I'm travelling now, but I will check when I get to a hotel.

9

Re: Dynamic Disk NTFS Resize Problem

Thank you for reporting your findings so far.  If you find a solution, then that might help others in a similar predicament.