

# 볼륨에 Amazon EC2 Windows 인스턴스의 NVMe 디스크 매핑
<a name="windows-list-disks-nvme"></a>

[Nitro 기반 인스턴스](instance-types.md#instance-hypervisor-type)를 사용하면, EBS 볼륨은 NVMe 디바이스로 표시됩니다. 이 주제에서는 인스턴스의 Windows 운영 체제에서 사용할 수 있는 **NVMe 디스크**를 보는 방법을 설명합니다. 또한 이러한 NVMe 디스크를 기본 Amazon EBS 볼륨에 매핑하는 방법과 Amazon EC2에서 사용하는 블록 디바이스 매핑에 지정된 디바이스 이름을 보여줍니다.

**Topics**
+ [NVMe 디스크 나열](#windows-disks-nvme)
+ [볼륨에 NVMe 디스크 매핑](#ebs-nvme-volume-map)

## NVMe 디스크 나열
<a name="windows-disks-nvme"></a>

디스크 관리 또는 Powershell을 사용하여 Windows 인스턴스에 있는 디스크를 검색할 수 있습니다.

------
#### [ Disk Management ]

**Windows 인스턴스에 있는 디스크를 검색하려면**

1. 원격 데스크톱을 사용하여 Windows 인스턴스에 로그인합니다. 자세한 내용은 [RDP를 사용하여 Windows 인스턴스에 연결](connecting_to_windows_instance.md) 섹션을 참조하세요.

1. 디스크 관리 유틸리티를 시작합니다.

1. 디스크를 확인합니다. 루트 볼륨은 `C:\`로 마운트되는 EBS 볼륨입니다. 다른 디스크가 표시되지 않는 경우 AMI를 생성하거나 인스턴스를 시작할 때 추가 볼륨을 지정하지 않은 것입니다.

   다음 예는 추가 EBS 볼륨 2개가 포함된 `r5d.4xlarge` 인스턴스를 시작하는 경우 사용 가능한 디스크를 보여줍니다.  
![루트 볼륨 1개, 인스턴스 스토어 볼륨 2개 및 EBS 볼륨 2개가 있는 디스크 관리](http://docs.aws.amazon.com/ko_kr/AWSEC2/latest/UserGuide/images/disk_management_nvme.png)

------
#### [ PowerShell ]

다음 PowerShell 스크립트는 각 디스크 및 해당 디바이스 이름과 볼륨을 목록으로 표시합니다. NVMe EBS 및 인스턴스 스토어 볼륨을 사용하는 [Nitro 기반 인스턴스](instance-types.md#instance-hypervisor-type)와 함께 사용하기 위한 것입니다.

Windows 인스턴스에 연결하고 다음 명령을 실행하여 PowerShell 스크립트 실행을 활성화합니다.

```
Set-ExecutionPolicy RemoteSigned
```

다음 스크립트를 복사하여 Windows 인스턴스에 `mapping.ps1`로 저장합니다.

```
# 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
```

스크립트를 다음과 같이 실행합니다.

```
PS C:\> .\mapping.ps1
```

다음은 루트 볼륨 1개, EBS 볼륨 2개 및 인스턴스 스토어 볼륨 2개가 있는 인스턴스의 예제 출력입니다.

```
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
```

Windows 인스턴스에서 Windows PowerShell용 도구에 대한 자격 증명을 구성하지 않은 경우 스크립트는 EBS 볼륨 ID를 가져올 수 없으며 `EbsVolumeId` 열에 N/A를 사용합니다.

------

## 볼륨에 NVMe 디스크 매핑
<a name="ebs-nvme-volume-map"></a>

[Get-Disk](https://learn.microsoft.com/en-us/powershell/module/storage/get-disk) 명령을 사용하여 Windows 디스크 번호를 Amazon EBS 볼륨 및 Amazon EC2 인스턴스 저장소 볼륨에 매핑할 수 있습니다.

```
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
```

**ebsnvme-id** 명령을 실행하여 EBS 볼륨 ID 및 디바이스 이름에 NVMe 디스크 번호를 매핑할 수도 있습니다.

```
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
```