My System Center Configuration Manager 2012 SP1 server is a VM running on Hyper-V 3.0. I’ve started the VM with a dynamic disk of 50GB and installed almost everything in the default location. But after a few weeks, the freespace on the system partition decreased to 9GB. The ConfigMgr started logging warnings and alerts:
Basically I had 3 options: I could either
- move some components (SQL,…) to my second drive that has 30GB freespace
- or decrease the thresholds so that the ConfigMgr stops logging warnings
- or extend the partition of the system drive
I chose the later because moving the SQL Database can have some undesired consequences. Although it doesn’t apply to ConfigMgr 2012 SP1, I could have had the following issue: After moving the System Center 2012 Configuration Manager SQL Site Database to another drive, creating a new Software Update package or a new application fails
Here’s what I did
- Backup the VM
$BackupShare = "\\mytarget.fqdn\myBackupShare$" $cred = (Get-Credential) $pol = New-WBPolicy Get-WBVirtualMachine | ? VMName -eq "myCM2012ServerName" | Add-WBVirtualMachine -Policy $pol $targetvol = New-WBBackupTarget -NetworkPath $BackupShare -Credential $cred -NonInheritAcl:$false Add-WBBackupTarget -Policy $pol -Target $targetvol Set-WBSchedule -Policy $pol -Schedule ([datetime]::Now.AddMinutes(10)) Start-WBBackup -Policy $pol
If you want to read more on how to backup a VM in Hyper-V 3.0 you can read my post https://p0w3rsh3ll.wordpress.com/2013/03/06/backup-hyper-v-with-powershell/
Do not perform actions (resize, shrink, convert,…) on virtual hard disk associated with a virtual machine that has snapshots, has replication enabled, or associated with a chain of differencing virtual hard disks. Otherwise, data loss is likely to occur.
Resize-VHD is an offline operation; the virtual hard disk must not be attached when the operation is initiated.
I only have one IDE drive on my VM so I can do:
Get-VMHardDiskDrive -VMName "myCM2012ServerName" -ControllerType IDE | Remove-VMHardDiskDrive
Resize-VHD -Path D:\VM\HDD\myVMName_DRIVE_C.vhdx -SizeBytes 65GB
Add-VMHardDiskDrive -VMName "myCM2012ServerName" -ControllerType IDE -ControllerNumber 0 -ControllerLocation 0 -Path D:\VM\HDD\myVMName_DRIVE_C.vhdx
Although I could have done it with the following PowerShell cmdlets,
Resize-Partition -DiskNumber 0 –PartitionNumber 2 -Size ( Get-PartitionSupportedSize –DiskNumber 0 –PartitionNumber 2).SizeMax
I did it with the classic brave old diskpart command:
I’ve also filled-in a documentation bug as the last example of the Resize-partition uses the MaximumSize property instead of the SizeMax property returned by the Get-PartitionSupportedSize cmdlet.
Total downtime a few minutes (I didn’t count) and my freespace issue is fixed 🙂