How to update NVMe and ENA Driver for ec2

Update the driver in existing instance (both linux and windows) before changing to new instance type.

As you already know AWS has introduced the following instances which are based on their own Hypervisor — nitro

A1, C5, C5d, C5n, M5, M5a, M5d, p3dn.24xlarge, R5, R5a, R5d, T3, and z1d

Bare metal: i3.metal, m5.metal, m5d.metal, r5.metal, r5d.metal, u-6tb1.metal, u-9tb1.metal, u-12tb1.metal, and z1d.metal

Although new AMI released by AWS/partner has got the new driver, you cannot just change existing instance to the new type to get advantage of it, unless you update driver and modify ec2 metadata to let it know that it has the drivers to use the new hypervisor.

To download and install the latest AWS NVMe driver for Windows (2008 R2 or later)

  1. Connect to your instance and log in as the local administrator.
    2. Download the latest driver package to the instance.
    3. Extract the zip archive.
    4. Install the driver by running the install.ps1 PowerShell script.
    5. If the installer does not reboot your instance for you, restart the instance.

To install/update the NVMe driver in Linux

1. Connect to your instance.
2. Update your package cache to get necessary package updates as follows.

For Amazon Linux 2, Amazon Linux, CentOS, and Red Hat Enterprise Linux:

sudo yum update -y

For Ubuntu and Debian:

sudo apt-get update -y

Ubuntu 16.04 and later include the linux-aws package, which contains the NVMe and ENA drivers required by Nitro-based instances. Upgrade the linux-aws package to receive the latest version as follows:

sudo apt-get upgrade -y linux-aws

For Ubuntu 14.04, you can install the latest linux-aws package as follows:

sudo apt-get install linux-aws

3. Reboot your instance to load the latest kernel version.

4. sudo reboot

To download and install the latest ENA driver for Windows (2008 R2 or later)

1. Connect to your instance and log in as the local administrator.

2.[Windows Server 2016 and later] Run the following EC2Launch PowerShell script to configure the instance after the driver is installed.

C:\ProgramData\Amazon\EC2-Windows\Launch\Scripts\InitializeInstance.ps1 -Schedule

3. From the instance, install the driver as follows:

a. Download the latest driver to the instance.

b. Extract the zip archive.

c. Install the driver by running the install.ps1 PowerShell script.

To install/update the ENA driver in Linux -

A. All Linux except ubuntu — The following procedure provides the general steps for enabling enhanced networking on a Linux distribution other than Amazon Linux AMI or Ubuntu, such as SUSE Linux Enterprise Server (SLES), Red Hat Enterprise Linux, or CentOS.

1. Connect to your instance.

2. Clone the source code for the ena module on your instance from GitHub at https://github.com/amzn/amzn-drivers. (SUSE SLES 12 SP2 and later include ENA 2.02 by default, so you are not required to download and compile the ENA driver. For SLES 12 SP2 and later, you should file a request to add the driver version you want to the stock kernel).

git clone https://github.com/amzn/amzn-drivers

3. Compile and install the ena module on your instance. (./configure && make && make install)

4. Run the sudo depmod command to update module dependencies.

5. Update initramfs on your instance to ensure that the new module loads at boot time. For example, if your distribution supports dracut, you can use the following command:

dracut -f -v

6.Determine if your system uses predictable network interface names by default. Systems that use systemd or udev versions 197 or greater can rename Ethernet devices and they do not guarantee that a single network interface will be named eth0. This behavior can cause problems connecting to your instance.

a. You can check the systemd or udev versions on RPM-based systems with the following command:

rpm -qa | grep -e ‘^systemd-[0–9]\+\|^udev-[0–9]\+’
systemd-208–11.el7_0.2.x86_64

In the above Red Hat Enterprise Linux 7 example, the systemd version is 208, so predictable network interface names must be disabled.

b. Disable predictable network interface names by adding the net.ifnames=0 option to the GRUB_CMDLINE_LINUX line in /etc/default/grub.

sudo sed -i ‘/^GRUB\_CMDLINE\_LINUX/s/\”$/\ net\.ifnames\=0\”/’ /etc/default/grub
Rebuild the grub configuration file.

c. sudo grub2-mkconfig -o /boot/grub2/grub.cfg

B. To install the linux-aws kernel package (Ubuntu 16.04 or later) -

Ubuntu 16.04 and 18.04 ship with the Ubuntu custom kernel (linux-aws kernel package).

To install the linux-aws kernel package (Ubuntu Trusty 14.04)

1. Connect to your instance.

2. Update the package cache and packages.

sudo apt-get update && sudo apt-get upgrade -y linux-aws

If during the update process you are prompted to install grub, use /dev/xvda to install grub onto, and then choose to keep the current version of /boot/grub/menu.ls

Enable ENA Support

Now you can shutdown the instance and enable ena support, then either change the instance type or take ami before booting the instance.

a. Check whether ena support is enabled -

aws ec2 describe-instances — instance-ids instance_id — query “Reservations[].Instances[].EnaSupport”

b. Enable ena support if the above shows result as false

aws ec2 modify-instance-attribute — instance-id instance_id — ena-support

Everything is Code