This article introduces how to resize partition with powershell in Windows Server 2016, step by step to shrink and extend Server 2016 volume with powershell.
Many administrators want to resize disk partitions after running the server for a period of time. Some people want to shrink a large volume to create new, some people want to extend C drive when it is running out of space. To repartition hard drive, powershell is one of the choices. This article introduces how to shrink and extend partition with powershell in Windows 2016 server, the shortages and better way to resize partition with 3rd-party tool.
How to shrink partition with powershell in Windows Server 2016
- Press Windows and R together on the keyboard to open Run, type powershell and press Enter.
- Type diskpart and press Enter in pop-up Windows PowerShell window.
- Type list volume and press Enter, then you'll see all single partitions with some parameters.
- Type select volume D and press Enter. (D is driver letter or number of the partition that you want to shrink.)
- Type shrink desired=20480 and press Enter. (20480 is the amount of free space to shrink in MBR, maximum amount will be used if you did not specify a value.)
In a short time, PowerShell reports that Diskpart successfully shrunk the volume by 20GB. Type list volume again, my D: drive is shrunk from 70GB to 50GB.
How to extend Server 2016 partition with PowerShell
Before extending volume with PowerShell, you must delete its contiguous partition on the right. If there's no right adjacent volume or you cannot delete it, you cannot extend partition with powershell in Windows Server 2016.
You cannot extend a partition by shrinking any other one. If you extend C: drive with powershell after shrinking D, you'll receive Virtual Disk Service error: The size of the extend is less than the minimum.
Steps to extend partition (C:) with powershell in Windows Server 2016:
- Transfer all files in the right contiguous partition D: (in some server is E:) to other place.
- Type diskpart and press Enter in PowerShell window.
- (optional) Type list volume and press Enter.
- Type select volume D and press Enter.
- Type delete volume and press Enter.
- Type select volume C and press Enter.
- Type extend and press Enter.
In a short time, my system C drive is increased from 40GB to 110GB. (There's 20GB Unallocated space behind D drive, this type of space won't be listed.)
Better way to resize partition in Windows Server 2016
There are many shortages while resizing partition with powershell in Windows 2016 server, for example:
- Only NTFS partitions can be shrunk and extended, FAT32 and any other types are not supported.
- Unallocated space can only be generated on the right side while shrinking partition.
- If there are some "unmovable" files in a partition, powershell can only shrink little free space although there's large amount.
- Unallocated space can only be used to create new volume, it cannot be moved or extended to any other partition.
- Any operations will be executed immediately.
With NIUBI Partition Editor, there are no such limitations. You just need to drag and drop on the disk map. Unallocated space can be made on either side and extended to any contiguous or non-adjacent partition volume on the same disk.
Download NIUBI Partition Editor and follow the steps in the video to shrink and extend volume in Windows 2016 server.
- If you want to shrink partition and extend another non-adjacent volume, there's an additional step to move Unallocated space.
- Steps are the same no matter you run physical server with SSD, HDD, RAID or virtual server in VMware/Hyper-V.
- If there's no available free space in a disk, you can copy entire system disk or single data volume to another disk, and extend partition(s) with additional space.
Better than other software, NIUBI Partition Editor has innovative technologies to protect system and data.
- Virtual Mode - all operations will be listed as pending for preview, real disk partitions won't be changed until click Apply to confirm.
- Cancel-at-well - if you applied incorrect operations, it doesn't matter, you can cancel the ongoing operations without causing damage.
- 1-Second Rollback - if anything goes wrong while resizing partition, it automatically reverts server to original status in a flash. If it happens, your server could back online rapidly without damage.
- It is also 30% to 300% faster because of the advanced file-moving algorithm.
Besides shrinking, extending, moving and copying disk partitions, it helps merge, convert, defrag, wipe, hide partition, scan bad sectors and much more.