The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Resize method of the MSFT_Partition class

Resizes the partition and any associated file system volume to the size specified by the Size parameter.


UInt32 Resize(
  [in]  UInt64 Size,
  [out] String ExtendedStatus


Size [in]

The new size for the disk. This parameter is required and cannot be zero.

ExtendedStatus [out]

A string that contains an embedded MSFT_StorageExtendedStatus object.

This parameter allows the storage provider to return extended (implementation-specific) error information.

Return value

Success (0)
Not Supported (1)
Unspecified Error (2)
Timeout (3)
Failed (4)
Invalid Parameter (5)
Size Not Supported (4097)
Access denied (40001)
There are not enough resources to complete the operation. (40002)
Cannot shrink a partition containing a volume with errors. (42008)
Cannot resize a partition containing an unknown file system. (42009)


This method resizes the partition and any associated file system to the size specified by the Size parameter. If the size is outside the bounds returned by the GetSupportedSize method, then this method will fail with a well-defined error code. The resize operation is supported only on NTFS-formatted partitions and RAW partitions.

If the specified size is smaller than the original size, this method will move files so that they are as close as possible to the beginning of the partition, to consolidate free space at the end of the partition. It then truncates the file system volume, reducing its size, and then truncates the partition.

In almost all cases, there will be some files that are immovable (that is, cannot be moved). For example, file system and storage driver metadata files are likely to be immovable. For this reason, the amount by which a partition can be shrunk is usually less than the total amount of free space on the partition.


Minimum supported client

Windows 8 [desktop apps only]

Minimum supported server

Windows Server 2012 [desktop apps only]





See also