Many administrators want to resize Windows server partition after running the server for a period of time. Some people want to shrink a large partition to create new volume, some people want to extend C drive when it is running out of space. To repartition hard drive in Windows server, you may try Powershell if you don't want to use any software. This article introduces how to shrink and extend partition with powershell in Windows Server 2016/2019/2022, the shortages of Powershell and better way to resize server partition with safe software.
How to shrink partition with powershell in Server 2016/2019/2022
- 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 partition with PowerShell in Server 2016/2019/2022
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 volume with powershell in Windows Server 2016/2019/2022.
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/2019/2022:
- 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 Server 2016/2019/2022, 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 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 other partitions.
- Any operations will be executed immediately.
With NIUBI Partition Editor, there are no such limitations. You can make Unallocated space on either left or right when shrinking NTFS and FAT32 partition. Extend partition with contiguous or non-adjacent Unallocated space 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 clone disk to a larger one or move a partition to another disk. When clone disk, you can extend partition with extra disk 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 you click "Apply" to confirm.
- Cancel-at-well - if you applied incorrect operations, you can cancel the ongoing operations without destroying partitions
- 1-Second Rollback - if any error is detected while resizing partition, it automatically reverts server to original status in a flash.
- Hot Clone - clone disk partition without server interruption. You can clone system disk regularly as backup and boot from the clone disk immediately whenever system disk is down.
Besides shrinking, extending, moving and copying disk partitions, NIUBI Partition Editor helps merge, convert, defrag, wipe, optimze, hide partition, scan bad sectors and much more.