optimized procedure to expand disk size

This commit is contained in:
Greg Lindsay
2016-09-13 16:18:13 -07:00
parent cbacd73a46
commit 635c2c4e47

View File

@ -249,36 +249,20 @@ The lab architecture is summarized in the following diagram:
```
### Resize VHD
The second Windows Server 2012 R2 VHD needs to be expanded in size from 40GB to 60GB to support imaging tools.
The second Windows Server 2012 R2 VHD needs to be expanded in size from 40GB to 60GB to support imaging tools.
1. To add available space for the partition, type the following commands at an elevated Windows PowerShell prompt on the Hyper-V host:
```
Resize-VHD Path c:\VHD\2012R2-poc-2.vhd SizeBytes 60GB
Mount-VHD Path c:\VHD\2012R2-poc-2.vhd -passthru | Get-Disk | Get-Partition | Get-Volume
$x = (Mount-VHD Path c:\VHD\2012R2-poc-2.vhd -passthru | Get-Disk | Get-Partition | Get-Volume).DriveLetter
Resize-Partition -DriveLetter $x -Size (Get-PartitionSupportedSize -DriveLetter $x).SizeMax
```
2. Note the drive letter of the mounted VHD in the output of the second command. In the example below, the drive letter of the mounted VHD is E:
2. Verify that the mounted VHD drive is resized to 60 GB, and then dismount the drive:
```
DriveLetter FileSystemLabel FileSystem DriveType HealthStatus OperationalStatus SizeRemaining Size
----------- --------------- ---------- --------- ------------ ----------------- ------------- ----
E NTFS Fixed Healthy OK 32.66 GB 40 GB
```
If the Hyper-V host you are using has a single hard drive assigned the letter C, and a DVD drive assigned the letter D, then drive E is probably also assigned to the mounted VHD as shown above. The size of the partition for drive E is still 40 GB, but since the VHD was resized to 60 GB in the first step, there is an additional 20 GB of unallocated space available. This additional space will be allocated in the following step.
3. Replace **E** with the drive letter displayed in the previous command output, and type the following at an elevated Windows PowerShell prompt:
```
$MaxSize = (Get-PartitionSupportedSize -DriveLetter E).SizeMax
Resize-Partition -DriveLetter E -Size $MaxSize
```
4. Verify that the mounted VHD drive is resized to 60 GB, and then dismount the drive:
```
(Get-Disk -FriendlyName "Msft Virtual Disk").size/1GB
Get-Volume -DriveLetter $x
Dismount-VHD Path c:\VHD\2012R2-poc-2.vhd
```