Posted On August 18, 2022

Windows: How To Expand Disk Volumes That Are Not Adjacent the Intended Volume

kimconnect 0 comments
blog.KimConnect.com >> Windows >> Windows: How To Expand Disk Volumes That Are Not Adjacent the Intended Volume

Problem:

Here’s a scenario when a virtualized disk has been expanded in Hyper-V, Vmware, AWS, Azure, Google Cloud, etc. The intended disk to be expanded is C:\, but E:\ is blocking C:\ from being expanded using the Windows diskmgmt.msc. What to do?

Resolution:

Option 1: Windows 7/10/11 (Client OS)

Install AOMEI Partition Assistant Standard

Option 2: Windows Servers

Pay the licensing fee to be able to use the partitioning wizard on a Windows Server OS

Option 3: Change vDisk bus type

  • Clone the existing Guest VM as a full backup
  • While having target Guest VM powered off, edit its VHD file > change ddb.adapterType = “ide” to ddb.adapterType = “lsilogic”
  • Remove the drive from the Guest VM with the “DO NOT remove from virtual machine and delete files from disk” option
  • Add a new hard disk > choose the “Use an existing virtual disk” option > select the targeted hard disk

Option 4: Windows Server 2012 / 2016 / 2019 / 2022 as a Guest VM

Caveat: this have proven to work on volumes with files that are NOT constantly changing (e.g. NOT databases, OS, real-time applications with transient items)

  • Add a new volume
  • Take a VSS Snapshot of the volume to be moved
$targetVolume="E:\"
$vssAccessLink="C:\shadowcopy"

function createVssSnapshot{
[cmdletbinding()]
param(
[string]$targetVolume="C:\",
$vssAccessLink="C:\shadowcopy"
)
# Sanitation
if (!($targetVolume -like "*\")){$targetVolume+="\"}
if(Test-Path $vssAccessLink){(Get-Item $vssAccessLink).Delete()}

write-host "Initiating VSS snapshot..."
$shadowCopyClass=[WMICLASS]"root\cimv2:win32_shadowcopy"
$thisSnapshot = $shadowCopyClass.Create($targetVolume, "ClientAccessible")
$thisShadow = Get-WmiObject Win32_ShadowCopy | Where-Object { $_.ID -eq $thisSnapshot.ShadowID }
$thisShadowPath = $thisShadow.DeviceObject + "\"

# Creating symlink
$null=cd C:
$null=cmd /c mklink /d $vssAccessLink $thisShadowPath
write-host "Vss Snapshot of $targetVolume has been made and it's accessible at this local file system (LFS): $vssAccessLink."

# Validation
if(Test-Path $vssAccessLink){
$snapshotId=$thisShadow.ID;
write-host "Snapshot $snapshotId has been created.";
return $snapshotId;
}else{
write-host "Failed to create client accessible VSS Snapshot.";
return $false;
}
}

createVssSnapshot $targetVolume $vssAccessLink
  • Copy data from snapshot to new volume
$vssAccessLink="C:\shadowcopy"
$newVolume='X:\'
robocopy $vssAccessLink $newVolume /e /R:0 /NP
  • Change the drive letter of the new volume as the original volume’s drive letter

 

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

Windows Short-cut vs Symbolic Link vs Junction vs Hard Link

Although they behave similarly, there are fundamental differences between a short-cut (a Microsoft's implementation for…

PowerShell: Remove an A-Host Record within Active Directory Integrated DNS Domain

Warning: this code is NOT 'production ready'. Please review and test on DEV environments carefully…

How to move the Active Directory (AD) Global Catalog (GC) to another domain controller (DC)

You don't actually move the GC between servers. Instead, you simply enable the GC on…
Other project: DragonCoin.com