How do I install and activate the latest ENA driver for enhanced network support on my EC2 instance that runs RHEL?

6 minute read
1

I want to use the latest Elastic Network Adapter (ENA) driver for enhanced network support. My Amazon Elastic Compute Cloud (Amazon EC2) instance runs on a Red Hat Enterprise Linux (RHEL).

Resolution

Note: If you receive errors when you run AWS Command Line Interface (AWS CLI) commands, then see Troubleshooting errors for the AWS CLI. Also, make sure that you're using the most recent AWS CLI version.

Some earlier versions of the RHEL operating system (OS) don't include an ENA driver. For Nitro instances, you must update the ENA driver if you change your EC2 instance type for network connectivity. To install the latest ENA driver on your EC2 instance, complete the following steps based on your RHEL version.

Before you install or update an ENA driver, it's a best practice to create a snapshot of your instance's Amazon Elastic Block Store (Amazon EBS) volume.

For more information about how to update Linux drivers, see ENA Linux driver best practices and performance optimization guide on the GitHub website.

Important: When you stop an instance, Amazon EC2 deletes all data in the instance store volumes. To check your root device type, see Determine the root device type of your AMI. You must back up data stored on an instance store volume if you want to keep that data.

RHEL version 7.4 and later

By default, RHEL version 7.4 and later Amazon Machine Images (AMIs) have the ENA driver for enhanced networking installed. For more information, see Activate enhanced networking with ENA on your EC2 instances.

RHEL versions earlier than 7.4

To install the ENA driver, complete the following steps:

  1. Run the following command to upgrade the kernel to the latest version:

    sudo yum upgrade kernel -y
  2. Stop the instance.

  3. To update the instance, run the following modify-instance-attribute AWS CLI command:

    aws ec2 modify-instance-attribute --instance-id exampleID --ena-support --region exampleRegion

    Note: Replace exampleID with your instance ID and exampleRegion with your AWS Region.

  4. Start the instance.

  5. To validate that you correctly installed the ENA driver on the instance, run the following command:

    ethtool -i eth0

    Note: Replace eth0 with the name of the interface that you want to check. If your OS uses predictable network names, then the network name might be different. For more information, see Understanding the predictable network interface device names on the Red Hat website.

RHEL 6

Note: RHEL 6 doesn't include Amazon EC2 production-ready NVMe drivers, and you can't upgrade to NVMe drivers. To use a Nitro-based instance, or an instance type with NVMe instance store volumes, upgrade to RHEL 7.4 or higher.

Download and install the ENA driver

Complete the following steps:

  1. To update the kernel and reboot the system to use the latest kernel, run the following command:

    sudo yum upgrade kernel -y && sudo reboot
  2. To install the development package to build kernel modules that match the kernel, run the following commands:

    sudo yum install kernel-devel-$(uname -r) gcc git patch rpm-build wget -ycd /usr/src/
    sudo wget https://github.com/amzn/amzn-drivers/archive/master.zip
    sudo unzip master.zip
    cd amzn-drivers-master/kernel/linux/ena
    sudo make
  3. To copy the module to the module directory, run the following command:

    sudo cp ena.ko /lib/modules/$(uname -r)/
  4. To regenerate the kernel module dependency map files, run the following command:

    sudo depmod
  5. To confirm that the ENA module is present, run the following command:

    modinfo ena

    When you compile and install the ENA driver on your system, the version might be later than 2.2.11g. The command output shows the ENA driver information.
    Example output:

    filename:       /lib/modules/2.6.32-754.33.1.el6.x86_64/ena.koversion:        2.2.11g
    license:        GPL
    description:    Elastic Network Adapter (ENA)
    author:         Amazon.com, Inc. or its affiliates
    retpoline:      Y
    srcversion:     17C7CD1CEAD3F0ADB3A5E5E
    alias:          pci:v00001D0Fd0000EC21sv*sd*bc*sc*i*
    alias:          pci:v00001D0Fd0000EC20sv*sd*bc*sc*i*
    alias:          pci:v00001D0Fd00001EC2sv*sd*bc*sc*i*
    alias:          pci:v00001D0Fd00000EC2sv*sd*bc*sc*i*
    alias:          pci:v00001D0Fd00000051sv*sd*bc*sc*i*
    depends:        
    vermagic:       2.6.32-754.33.1.el6.x86_64 SMP mod_unload modversions 
    parm:           debug:Debug level (0=none,...,16=all) (int)
    parm:           rx_queue_size:Rx queue size. The size should be a power of 2. Max value is 8K
     (int)
    parm:           force_large_llq_header:Increases maximum supported header size in LLQ mode to 224 bytes, while reducing the maximum TX queue size by half.
     (int)
    parm:           num_io_queues:Sets number of RX/TX queues to allocate to device. The maximum value depends on the device and number of online CPUs.
     (int)
  6. To add net.ifnames=0 to /boot/grub/grub.conf and turn off network interface naming, run the following command:

    sudo sed -i '/kernel/s/$/ net.ifnames=0/' /boot/grub/grub.conf
  7. Stop the instance.

  8. To activate enhanced network support at the instance level, run the following modify-instance-attribute command:

    aws ec2 modify-instance-attribute --instance-id exampleID --ena-support --region exampleRegion

    Note: Replace exampleID with your instance ID and exampleRegion with your Region.

  9. Change the instance type to an instance type that supports ENA.

  10. Start the instance.

  11. Use SSH to connect to the instance, and then run the following command to validate that you correctly installed the ENA driver:

    ethtool -i eth0

    Example output:

    driver: enaversion: 2.2.11g
    firmware-version: 
    bus-info: 0000:00:05.0
    supports-statistics: yes
    supports-test: no
    supports-eeprom-access: no
    supports-register-dump: no
    supports-priv-flags: no

(Optional) Configure the DKMS program

If your application has a direct dependency on the ENA version, then configure the Dynamic Kernel Module Support (DKMS) program. This makes sure that Amazon EC2 includes the driver in future kernel upgrades.

Note: You can use the Extra Packages for Enterprise Linux (EPEL) repository in a RHEL instance.

To configure the DKMS program, complete the following steps:

  1. To install the Red Hat Package Manager (rpm) file, run the following command:

    sudo yum install https://archives.fedoraproject.org/pub/archive/epel/6/x86_64/epel-release-6-8.noarch.rpm -y

    Note: For a list of the latest .rpm packages, see Available packages in EPEL on the Fedora Project website.

  2. To install DKMS, run the following command:

    sudo yum install dkms -y
  3. To delete the existing kernel, run the following command:

    VER=$( grep ^VERSION /usr/src/amzn-drivers-master/kernel/linux/rpm/Makefile | cut -d' ' -f2 )
  4. To copy the source files into the source directory, run the following command:

    sudo cp -a /usr/src/amzn-drivers-master /usr/src/amzn-drivers-${VER}
  5. To create the DKMS config file, and build and install the ENA module, run the following command:

    sudo cat <<EOM | sudo tee /usr/src/amzn-drivers-${VER}/dkms.confPACKAGE_NAME="ena"
    PACKAGE_VERSION="$VER"
    CLEAN="make -C kernel/linux/ena clean"
    MAKE="make -C kernel/linux/ena/ BUILD_KERNEL=\${kernelver}"
    BUILT_MODULE_NAME[0]="ena"
    BUILT_MODULE_LOCATION="kernel/linux/ena"
    DEST_MODULE_LOCATION[0]="/updates"
    DEST_MODULE_NAME[0]="ena"
    AUTOINSTALL="yes"
    EOM
    
    sudo dkms add -m amzn-drivers -v $VER
    sudo dkms build -m amzn-drivers -v $VER
    sudo dkms install -m amzn-drivers -v $VER
AWS OFFICIAL
AWS OFFICIALUpdated 13 days ago