Map disks to volumes on your Windows instance

Aman Raiyyani
Map disks to EBS volumes on your Windows instance

List NVMe volumes

You can find the disks on your Windows instance using Disk Management or Powershell.

List NVMe disks using Disk Management

You can find the disks on your Windows instance using Disk Management.

To find the disks on your Windows instance

Log in to your Windows instance using Remote Desktop. For more information, see Connect to your Windows instance.

  1. Start the Disk Management utility.
  2. Review the disks. The root volume is an EBS volume mounted as C:\. If there are no other disks shown, then you didn’t specify additional volumes when you created the AMI or launched the instance.

The following is an example that shows the disks that are available if you launch an r5d.4xlarge instance with two additional EBS volumes.

List NVMe disks using PowerShell

The following CLI script lists each disk name and its corresponding volume ID.

  1. Connect to your Windows instance and run the following command to enable PowerShell script execution.

Set-ExecutionPolicy RemoteSigned

2.Copy the following script in notepad and save it as mapping.ps1 on your Windows instance.

# List the disks for NVMe volumes

function Get-EC2InstanceMetadata {
    param([string]$Path)
    (Invoke-WebRequest -Uri "http://169.254.169.254/latest/$Path").Content 
}

function GetEBSVolumeId {
    param($Path)
    $SerialNumber = (Get-Disk -Path $Path).SerialNumber
    if($SerialNumber -clike 'vol*'){
        $EbsVolumeId = $SerialNumber.Substring(0,20).Replace("vol","vol-")
    }
    else {
       $EbsVolumeId = $SerialNumber.Substring(0,20).Replace("AWS","AWS-")
    }
    return $EbsVolumeId
}

function GetDeviceName{
    param($EbsVolumeId)
    if($EbsVolumeId -clike 'vol*'){
    
        $Device  = ((Get-EC2Volume -VolumeId $EbsVolumeId ).Attachment).Device
        $VolumeName = ""
    }
     else {
        $Device = "Ephemeral"
        $VolumeName = "Temporary Storage"
    }
    Return $Device,$VolumeName
}

function GetDriveLetter{
    param($Path)
    $DiskNumber =  (Get-Disk -Path $Path).Number
    if($DiskNumber -eq 0){
        $VirtualDevice = "root"
        $DriveLetter = "C"
        $PartitionNumber = (Get-Partition -DriveLetter C).PartitionNumber
    }
    else
    {
        $VirtualDevice = "N/A"
        $DriveLetter = (Get-Partition -DiskNumber $DiskNumber).DriveLetter
        if(!$DriveLetter)
        {
            $DriveLetter = ((Get-Partition -DiskId $Path).AccessPaths).Split(",")[0]
        } 
        $PartitionNumber = (Get-Partition -DiskId $Path).PartitionNumber   
    }
    
    return $DriveLetter,$VirtualDevice,$PartitionNumber

}

$Report = @()
foreach($Path in (Get-Disk).Path)
{
    $Disk_ID = ( Get-Partition -DiskId $Path).DiskId
    $Disk = ( Get-Disk -Path $Path).Number
    $EbsVolumeId  = GetEBSVolumeId($Path)
    $Size =(Get-Disk -Path $Path).Size
    $DriveLetter,$VirtualDevice, $Partition = (GetDriveLetter($Path))
    $Device,$VolumeName = GetDeviceName($EbsVolumeId)
    $Disk = New-Object PSObject -Property @{
      Disk          = $Disk
      Partitions    = $Partition
      DriveLetter   = $DriveLetter
      EbsVolumeId   = $EbsVolumeId 
      Device        = $Device 
      VirtualDevice = $VirtualDevice 
      VolumeName= $VolumeName
    }
	$Report += $Disk
} 

$Report | Sort-Object Disk | Format-Table -AutoSize -Property Disk, Partitions, DriveLetter, EbsVolumeId, Device, VirtualDevice, VolumeName
  • Run the script in powershell in the location the file is saved in:
PS D:\> .\mapping.ps1

The following is example output for an instance with a root volume, two EBS volumes, and two instance store volumes.

Disk Partitions DriveLetter EbsVolumeId           Device    VirtualDevice VolumeName

—- ———- ———– ———–           ——    ————- ———-

   0          1 C           vol-03683f1d861744bc7 /dev/sda1 root

   1          1 D           vol-082b07051043174b9 xvdb      N/A

   2          1 E           vol-0a4064b39e5f534a2 xvdc      N/A

   3          1 F           AWS-6AAD8C2AEEE1193F0 Ephemeral N/A           Temporary Storage

   4          1 G           AWS-13E7299C2BD031A28 Ephemeral N/A           Temporary Storage

Explore our range of trailblazer services

Risk and Health Audit

Get 360 degree view in to the health of your production Databases with actionable intelligence and readiness for government compliance including HIPAA, SOX, GDPR, PCI, ETC. with 100% money-back guarantee.

DBA Services

The MOST ADVANCED database management service that help manage, maintain & support your production database 24×7 with highest ROI so you can focus on more important things for your business

Cloud Migration

With more than 20 Petabytes of data migration experience to both AWS and Azure cloud, we help migrate your databases to various databases in the cloud including RDS, Aurora, Snowflake, Azure SQL, Etc.

Data Integration

Whether you have unstructured, semi-structured or structured data, we help build pipelines that extract, transform, clean, validate and load it into data warehouse or data lakes or in any databases.

Data Analytics

We help transform your organizations data into powerful,  stunning, light-weight  and meaningful reports using PowerBI or Tableau to help you with making fast and accurate business decisions.

Govt Compliance

Does your business use PII information? We provide detailed and the most advanced risk assessment for your business data related to HIPAA, SOX, PCI, GDPR and several other Govt. compliance regulations.

You May Also Like…