Petakan disk ke volume pada instans Windows - Amazon Elastic Compute Cloud

Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.

Petakan disk ke volume pada instans Windows

catatan

Topik ini hanya berlaku untuk instance Windows.

Instans Windows Anda dilengkapi dengan volume EBS yang berfungsi sebagai volume root. Jika instans Windows Anda menggunakan driver AWS PV atau Citrix PV, Anda dapat menambahkan hingga 25 volume secara opsional, membuat total 26 volume. Untuk informasi selengkapnya, lihat Batasan volume instans.

Bergantung pada tipe instans, Anda akan memiliki dari 0 hingga 24 kemungkinan volume penyimpanan instans yang tersedia untuk instans. Untuk menggunakan volume penyimpanan instans yang tersedia untuk instans, Anda harus menentukannya saat Anda membuat AMI atau meluncurkan instans. Anda juga dapat menambahkan volume EBS saat Anda membuat AMI atau meluncurkan instans, atau melampirkannya saat instans berjalan.

Saat Anda menambahkan volume ke instans, Anda menentukan nama perangkat yang digunakan Amazon EC2. Untuk informasi lebih lanjut, lihatNama perangkat di instans Amazon EC2. AWS Windows Amazon Machine Image (AMI) berisi sekumpulan driver yang digunakan oleh Amazon EC2 untuk memetakan instans store dan volume EBS ke disk Windows dan huruf drive. Jika Anda meluncurkan instance dari AMI Windows yang menggunakan driver AWS PV atau Citrix PV, Anda dapat menggunakan hubungan yang dijelaskan di halaman ini untuk memetakan disk Windows Anda ke penyimpanan instans dan volume EBS Anda. Jika Windows AMI Anda menggunakan driver PV Red Hat, Anda dapat memperbarui instans Anda untuk menggunakan driver Citrix. Untuk informasi selengkapnya, lihat Mutakhirkan driver PV pada instans Windows.

Mencantumkan volume NVMe

Anda dapat menemukan disk di instans Windows menggunakan Manajemen Disk atau Powershell.

Mencantumkan disk NVMe menggunakan Manajemen Disk

Anda dapat menemukan disk di instans Windows Anda menggunakan Manajemen Disk.

Untuk menemukan disk di instans Windows Anda
  1. Masuk ke instans Windows menggunakan Remote Desktop. Untuk informasi selengkapnya, lihat Hubungkan ke instans Windows Anda.

  2. Mulai utilitas Manajemen Disk.

  3. Tinjau disk. Volume root adalah volume EBS yang dipasang sebagai C:\. Jika tidak ada disk lain yang ditampilkan, berarti Anda tidak menentukan volume tambahan saat membuat AMI atau meluncurkan instans.

    Berikut ini adalah contoh yang menunjukkan disk yang tersedia jika Anda meluncurkan instans r5d.4xlarge dengan dua volume EBS tambahan.

    Manajemen Disk dengan volume root, dua volume penyimpanan instans, dan dua volume EBS.

Daftar disk NVMe menggunakan PowerShell

PowerShell Skrip berikut mencantumkan setiap disk dan nama dan volume perangkat yang sesuai. Ini dimaksudkan untuk digunakan dengan instance yang dibangun di atas Sistem AWS Nitro, yang menggunakan NVMe EBS dan volume penyimpanan instance.

Connect ke instance Windows Anda dan jalankan perintah berikut untuk mengaktifkan eksekusi PowerShell script.

Set-ExecutionPolicy RemoteSigned

Salin skrip berikut dan simpan sebagai mapping.ps1 di instans Windows Anda.

# 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

Jalankan skrip sebagai berikut:

PS C:\> .\mapping.ps1

Berikut ini adalah contoh output untuk sebuah instans dengan volume root, dua volume EBS, dan dua volume penyimpanan instans.

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

Jika Anda tidak mengonfigurasi kredensi Anda untuk Alat untuk Windows PowerShell pada instance Windows, skrip tidak dapat memperoleh ID volume EBS dan menggunakan N/A di kolom. EbsVolumeId

Memetakan volume NVMe EBS

Dengan instans yang dibangun di Sistem AWS Nitro, volume EBS diekspos sebagai perangkat NVMe. Anda dapat menggunakan perintah Get-Disk untuk memetakan nomor disk Windows ke ID volume EBS.

PS C:\> Get-Disk Number Friendly Name Serial Number HealthStatus OperationalStatus Total Size Partition Style ------ ------------- ------------- ------------ ----------------- ---------- ---------- 3 NVMe Amazo... AWS6AAD8C2AEEE1193F0_00000001. Healthy Online 279.4 GB MBR 4 NVMe Amazo... AWS13E7299C2BD031A28_00000001. Healthy Online 279.4 GB MBR 2 NVMe Amazo... vol0a4064b39e5f534a2_00000001. Healthy Online 8 GB MBR 0 NVMe Amazo... vol03683f1d861744bc7_00000001. Healthy Online 30 GB MBR 1 NVMe Amazo... vol082b07051043174b9_00000001. Healthy Online 8 GB MBR

Anda juga dapat menjalankan perintah ebsnvme-id untuk memetakan angka disk NVMe ke ID volume EBS dan nama perangkat.

PS C:\> C:\PROGRAMDATA\Amazon\Tools\ebsnvme-id.exe Disk Number: 0 Volume ID: vol-03683f1d861744bc7 Device Name: sda1 Disk Number: 1 Volume ID: vol-082b07051043174b9 Device Name: xvdb Disk Number: 2 Volume ID: vol-0a4064b39e5f534a2 Device Name: xvdc

Mencantumkan volume

Anda dapat menemukan disk di instans Windows menggunakan Manajemen Disk atau Powershell.

Mencantumkan disk menggunakan Manajemen Disk

Anda dapat menemukan disk di instans Windows Anda menggunakan Manajemen Disk.

Untuk menemukan disk di instans Windows Anda
  1. Masuk ke instans Windows menggunakan Remote Desktop. Untuk informasi selengkapnya, lihat Hubungkan ke instans Windows Anda.

  2. Mulai utilitas Manajemen Disk.

    Pada bilah tugas, klik kanan logo Windows, lalu pilih Manajemen Disk.

  3. Tinjau disk. Volume root adalah volume EBS yang dipasang sebagai C:\. Jika tidak ada disk lain yang ditampilkan, berarti Anda tidak menentukan volume tambahan saat membuat AMI atau meluncurkan instans.

    Berikut ini adalah instans yang menunjukkan disk yang tersedia jika Anda meluncurkan instans m3.medium dengan volume penyimpanan instans (Disk 2) dan volume EBS tambahan (Disk 1).

    Manajemen Disk dengan volume root, satu volume penyimpanan instans, dan satu volume EBS.
  4. Klik kanan panel abu-abu dengan label Disk 1, lalu pilih Properti. Perhatikan nilai Lokasi dan cari dalam tabel di Memetakan perangkat disk ke nama perangkat. Misalnya, disk berikut memiliki lokasi Nomor Bus 0, Target Id 9, LUN 0. Menurut tabel untuk volume EBS, nama perangkat untuk lokasi ini adalah xvdj.

    Lokasi volume EBS.

Memetakan perangkat disk ke nama perangkat

Driver perangkat blok untuk instans menetapkan nama volume aktual saat melakukan pemasangan volume.

Volume penyimpanan instans

Tabel berikut menjelaskan bagaimana driver Citrix PV dan PV memetakan AWS volume penyimpanan instans non-NVMe ke volume Windows. Jumlah volume penyimpanan instans yang tersedia ditentukan oleh tipe instans. Untuk informasi selengkapnya, lihat Volume penyimpanan instans.

Lokasi Nama perangkat

Nomor Bus 0, ID Target 78, LUN 0

xvdca

Nomor Bus 0, ID Target 79, LUN 0

xvdcb

Nomor Bus 0, ID Target 80, LUN 0

xvdcc

Nomor Bus 0, ID Target 81, LUN 0

xvdcd

Nomor Bus 0, ID Target 82, LUN 0

xvdce

Nomor Bus 0, ID Target 83, LUN 0

xvdcf

Nomor Bus 0, ID Target 84, LUN 0

xvdcg

Nomor Bus 0, ID Target 85, LUN 0

xvdch

Nomor Bus 0, ID Target 86, LUN 0

xvdci

Nomor Bus 0, ID Target 87, LUN 0

xvdcj

Nomor Bus 0, ID Target 88, LUN 0

xvdck

Nomor Bus 0, ID Target 89, LUN 0

xvdcl

Volume EBS

Tabel berikut menjelaskan bagaimana driver Citrix PV dan PV memetakan AWS volume EBS non-NVME ke volume Windows.

Lokasi Nama perangkat

Nomor Bus 0, ID Target 0, LUN 0

/dev/sda1

Nomor Bus 0, ID Target 1, LUN 0

xvdb

Nomor Bus 0, ID Target 2, LUN 0

xvdc

Nomor Bus 0, ID Target 3, LUN 0

xvdd

Nomor Bus 0, ID Target 4, LUN 0

xvde

Nomor Bus 0, ID Target 5, LUN 0

xvdf

Nomor Bus 0, ID Target 6, LUN 0

xvdg

Nomor Bus 0, ID Target 7, LUN 0

xvdh

Nomor Bus 0, ID Target 8, LUN 0

xvdi

Nomor Bus 0, ID Target 9, LUN 0

xvdj

Nomor Bus 0, ID Target 10, LUN 0

xvdk

Nomor Bus 0, ID Target 11, LUN 0

xvdl

Nomor Bus 0, ID Target 12, LUN 0

xvdm

Nomor Bus 0, ID Target 13, LUN 0

xvdn

Nomor Bus 0, ID Target 14, LUN 0

xvdo

Nomor Bus 0, ID Target 15, LUN 0

xvdp

Nomor Bus 0, ID Target 16, LUN 0

xvdq

Nomor Bus 0, ID Target 17, LUN 0

xvdr

Nomor Bus 0, ID Target 18, LUN 0

xvds

Nomor Bus 0, ID Target 19, LUN 0

xvdt

Nomor Bus 0, ID Target 20, LUN 0

xvdu

Nomor Bus 0, ID Target 21, LUN 0

xvdv

Nomor Bus 0, ID Target 22, LUN 0

xvdw

Nomor Bus 0, ID Target 23, LUN 0

xvdx

Nomor Bus 0, ID Target 24, LUN 0

xkertas

Nomor Bus 0, ID Target 25, LUN 0

xvdz

Daftar disk menggunakan PowerShell

PowerShell Skrip berikut mencantumkan setiap disk dan nama dan volume perangkat yang sesuai.

Persyaratan dan batasan
  • Memerlukan Windows Server 2012 atau yang lebih baru.

  • Memerlukan kredensial untuk mendapatkan ID volume EBS. Anda dapat mengonfigurasi profil menggunakan Alat untuk PowerShell, atau melampirkan peran IAM ke instance.

  • Tidak mendukung volume NVMe.

  • Tidak mendukung disk dinamis.

Connect ke instance Windows Anda dan jalankan perintah berikut untuk mengaktifkan eksekusi PowerShell script.

Set-ExecutionPolicy RemoteSigned

Salin skrip berikut dan simpan sebagai mapping.ps1 di instans Windows Anda.

# List the disks function Convert-SCSITargetIdToDeviceName { param([int]$SCSITargetId) If ($SCSITargetId -eq 0) { return "sda1" } $deviceName = "xvd" If ($SCSITargetId -gt 25) { $deviceName += [char](0x60 + [int]($SCSITargetId / 26)) } $deviceName += [char](0x61 + $SCSITargetId % 26) return $deviceName } [string[]]$array1 = @() [string[]]$array2 = @() [string[]]$array3 = @() [string[]]$array4 = @() Get-WmiObject Win32_Volume | Select-Object Name, DeviceID | ForEach-Object { $array1 += $_.Name $array2 += $_.DeviceID } $i = 0 While ($i -ne ($array2.Count)) { $array3 += ((Get-Volume -Path $array2[$i] | Get-Partition | Get-Disk).SerialNumber) -replace "_[^ ]*$" -replace "vol", "vol-" $array4 += ((Get-Volume -Path $array2[$i] | Get-Partition | Get-Disk).FriendlyName) $i ++ } [array[]]$array = $array1, $array2, $array3, $array4 Try { $InstanceId = Get-EC2InstanceMetadata -Category "InstanceId" $Region = Get-EC2InstanceMetadata -Category "Region" | Select-Object -ExpandProperty SystemName } Catch { Write-Host "Could not access the instance Metadata using AWS Get-EC2InstanceMetadata CMDLet. Verify you have AWSPowershell SDK version '3.1.73.0' or greater installed and Metadata is enabled for this instance." -ForegroundColor Yellow } Try { $BlockDeviceMappings = (Get-EC2Instance -Region $Region -Instance $InstanceId).Instances.BlockDeviceMappings $VirtualDeviceMap = (Get-EC2InstanceMetadata -Category "BlockDeviceMapping").GetEnumerator() | Where-Object { $_.Key -ne "ami" } } Catch { Write-Host "Could not access the AWS API, therefore, VolumeId is not available. Verify that you provided your access keys or assigned an IAM role with adequate permissions." -ForegroundColor Yellow } Get-disk | ForEach-Object { $DriveLetter = $null $VolumeName = $null $VirtualDevice = $null $DeviceName = $_.FriendlyName $DiskDrive = $_ $Disk = $_.Number $Partitions = $_.NumberOfPartitions $EbsVolumeID = $_.SerialNumber -replace "_[^ ]*$" -replace "vol", "vol-" if ($Partitions -ge 1) { $PartitionsData = Get-Partition -DiskId $_.Path $DriveLetter = $PartitionsData.DriveLetter | Where-object { $_ -notin @("", $null) } $VolumeName = (Get-PSDrive | Where-Object { $_.Name -in @($DriveLetter) }).Description | Where-object { $_ -notin @("", $null) } } If ($DiskDrive.path -like "*PROD_PVDISK*") { $BlockDeviceName = Convert-SCSITargetIdToDeviceName((Get-WmiObject -Class Win32_Diskdrive | Where-Object { $_.DeviceID -eq ("\\.\PHYSICALDRIVE" + $DiskDrive.Number) }).SCSITargetId) $BlockDeviceName = "/dev/" + $BlockDeviceName $BlockDevice = $BlockDeviceMappings | Where-Object { $BlockDeviceName -like "*" + $_.DeviceName + "*" } $EbsVolumeID = $BlockDevice.Ebs.VolumeId $VirtualDevice = ($VirtualDeviceMap.GetEnumerator() | Where-Object { $_.Value -eq $BlockDeviceName }).Key | Select-Object -First 1 } ElseIf ($DiskDrive.path -like "*PROD_AMAZON_EC2_NVME*") { $BlockDeviceName = (Get-EC2InstanceMetadata -Category "BlockDeviceMapping").ephemeral((Get-WmiObject -Class Win32_Diskdrive | Where-Object { $_.DeviceID -eq ("\\.\PHYSICALDRIVE" + $DiskDrive.Number) }).SCSIPort - 2) $BlockDevice = $null $VirtualDevice = ($VirtualDeviceMap.GetEnumerator() | Where-Object { $_.Value -eq $BlockDeviceName }).Key | Select-Object -First 1 } ElseIf ($DiskDrive.path -like "*PROD_AMAZON*") { if ($DriveLetter -match '[^a-zA-Z0-9]') { $i = 0 While ($i -ne ($array3.Count)) { if ($array[2][$i] -eq $EbsVolumeID) { $DriveLetter = $array[0][$i] $DeviceName = $array[3][$i] } $i ++ } } $BlockDevice = "" $BlockDeviceName = ($BlockDeviceMappings | Where-Object { $_.ebs.VolumeId -eq $EbsVolumeID }).DeviceName } ElseIf ($DiskDrive.path -like "*NETAPP*") { if ($DriveLetter -match '[^a-zA-Z0-9]') { $i = 0 While ($i -ne ($array3.Count)) { if ($array[2][$i] -eq $EbsVolumeID) { $DriveLetter = $array[0][$i] $DeviceName = $array[3][$i] } $i ++ } } $EbsVolumeID = "FSxN Volume" $BlockDevice = "" $BlockDeviceName = ($BlockDeviceMappings | Where-Object { $_.ebs.VolumeId -eq $EbsVolumeID }).DeviceName } Else { $BlockDeviceName = $null $BlockDevice = $null } New-Object PSObject -Property @{ Disk = $Disk; Partitions = $Partitions; DriveLetter = If ($DriveLetter -eq $null) { "N/A" } Else { $DriveLetter }; EbsVolumeId = If ($EbsVolumeID -eq $null) { "N/A" } Else { $EbsVolumeID }; Device = If ($BlockDeviceName -eq $null) { "N/A" } Else { $BlockDeviceName }; VirtualDevice = If ($VirtualDevice -eq $null) { "N/A" } Else { $VirtualDevice }; VolumeName = If ($VolumeName -eq $null) { "N/A" } Else { $VolumeName }; DeviceName = If ($DeviceName -eq $null) { "N/A" } Else { $DeviceName }; } } | Sort-Object Disk | Format-Table -AutoSize -Property Disk, Partitions, DriveLetter, EbsVolumeId, Device, VirtualDevice, DeviceName, VolumeName

Jalankan skrip sebagai berikut:

PS C:\> .\mapping.ps1

Berikut ini adalah output contoh.

Disk Partitions DriveLetter EbsVolumeId Device VirtualDevice DeviceName VolumeName ---- ---------- ----------- ----------- ------ ------------- ---------- ---------- 0 1 C vol-0561f1783298efedd /dev/sda1 N/A NVMe Amazon Elastic B N/A 1 1 D vol-002a9488504c5e35a xvdb N/A NVMe Amazon Elastic B N/A 2 1 E vol-0de9d46fcc907925d xvdc N/A NVMe Amazon Elastic B N/A

Jika Anda tidak memberikan kredensial Anda pada instans Windows, skrip tidak bisa mendapatkan ID volume EBS dan menggunakan N/A pada kolom EbsVolumeId.