2

I have a few systems I want to shrink the primary (and only) partition to about half of the disk and then create a new partition in the newly available space. The disks are 500GB. I want to script it, so I am using diskpart; however, I have issues with using desired=[n] and minimum=[n] with the diskpart command.

Follow the progression below to get an understanding of what I am talking about.

DISKPART> shrink

Will shrink the partition by about 230GB. Which would work, however, I want to ensure that I have enough space on partition 1 (I don't want it to shrink more than half). So I run the following command:

DISKPART> shrink desired=250000

I receive an error about shrink size is too big. After reading Microsoft's guide on diskpart, I decide to add the minimum=[n] option to the same command and receive the exact same error.

DISKPART> shrink desired=250000 minimum=100000

Virtual Disk Service error:
The specified shrink size is too big and will cause the volume to be
smaller than the minimum volume size.

We already know that the partition is capable of shrinking by 230GB, which means the minimum command isn't working. According to Microsoft documentation, it will attempt the desired size and if that fails, adjust to at least the minimum size. However, the minimum statement does not seem to be working as intended as 100GB is less than 230GB. If I use the minimum=[n] option without the desired=[n] option it will shrink by the number specified.

DISKPART> shrink minimum=100000

Gives me ~100GB shrink.

What am I doing wrong? I want it to shrink by 250GB and if can't make 250, then shrink by anything else as long as it is larger than 100GB.

Aaron
  • 21
  • 1
  • 2

1 Answers1

1

Have/Had similar issues/question, so documenting my findings.

From https://docs.microsoft.com/en-us/windows-server/storage/disk-management/shrink-a-basic-volume

When you shrink a partition, certain files (for example, the paging file or the shadow copy storage area) cannot be automatically relocated, and you cannot decrease the allocated space beyond the point where the unmovable files are located

This is probably not the case in the above scenario but might be worth remembering.

desired is "how much smaller" you want the device to be, so in this case making it 250000 smaller than what it currently is, would make it smaller than the tested and ok 230GB.

I know it is confusing that desired is not the desired final size, but the shrinkage.

Example: shrink desired=100 minimum=10 Should try to make the volume 100MB smaller, but it will still shrink it if it can only reclaim 10MB.

Or for the specific question, maybe shrink desired=230000 minimum=100000 would have been the answer.

More detailed explanations of errors do show up in the Windows Event Application log.

NiKiZe
  • 1,189
  • 7
  • 17