AWS/Enable ENA Support in Ubuntu

From Ever changing code
< AWS
Jump to navigation Jump to search

In order to enable this feature, you must launch an HVM AMI with the appropriate drivers. C5, R4, X1, I3, P3, P2, G3, and m4.16xlarge instances provide the Elastic Network Adapter (ENA) interface (which uses the “ena” Linux driver) for Enhanced Networking. C3, C4, R3, I2, M4 (except m4.16xlarge) and D2 instances use Intel® 82599g Virtual Function Interface (which uses the “ixgbevf” Linux driver). Amazon Linux AMI includes both of these drivers by default. For AMIs that do not contain these drivers, you will need to download and install the appropriate drivers based on the instance types you plan to use. You can use Linux or Windows instructions to enable Enhanced Networking in AMIs that do not include the SR-IOV driver by default. Enhanced Networking is only supported in Amazon VPC.

This is required for any instance running on new Amazon EC2 (own built hypervisor) built on core Linux Kernel-based Virtual Machine (KVM) technology, but does not include general purpose operating system components

Verify current settings

Verify Instance Attribute (enaSupport)

aws ec2 describe-instances --instance-ids i-0303ce0e47eac5f7d --query 'Reservations[].Instances[].EnaSupport' --profile devops-vpc
Verify Image Attribute (enaSupport)
aws ec2 describe-images --image-id ami-8fd760f6 --query 'Images[].EnaSupport' --profile devops-vpc #official eu-west-1 xenial 16.04 amd64 hvm-ssd 20171121.1 ami-8fd760f6
[
    true
]

Check if your network adapter is using ena driver

[ec2-user ~]$ ethtool -i eth0
driver: ena
version: 0.6.6

Enable ENA

Update ENA drives on Ubuntu 16.04 and modify an instance-attribute to SupportENA

Install driver

ubuntu:~$ sudo apt-get update && sudo apt-get upgrade -y
ubuntu:~$ sudo apt-get install -y build-essential dkms
ubuntu:~$ git clone https://github.com/amzn/amzn-drivers
ubuntu:~$ sudo mv amzn-drivers /usr/src/amzn-drivers-1.0.0

Create DMKS config file

ubuntu:~$ sudo touch /usr/src/amzn-drivers-1.0.0/dkms.conf
ubuntu:~$ sudo vim /usr/src/amzn-drivers-1.0.0/dkms.conf
PACKAGE_NAME="ena"
PACKAGE_VERSION="1.0.0"
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"

Build, and install the ena module on your instance using dkms

ubuntu:~$ sudo dkms add -m amzn-drivers -v 1.0.0       # Add the module to dkms
ubuntu:~$ sudo dkms build -m amzn-drivers -v 1.0.0     # Build the module using dkms
ubuntu:~$ sudo dkms install -m amzn-drivers -v 1.0.0   # Install the module using dkms

Rebuild initramfs so the correct module is loaded at boot time.

ubuntu:~$ sudo update-initramfs -c -k all

Modify ec2 instance-attribute to SupportENA

aws ec2  stop-instances --instance-ids i-0b7f3342388888888 --dry-run --profile devops-vpc
aws ec2 modify-instance-attribute --instance-id i-0b7f3342388888888 --ena-support --profile devops-vpc
aws ec2 describe-instances --instance-ids i-0b7f3342388888888 --query 'Reservations[].Instances[].EnaSupport' --profile devops-vpc
[
    true
]
aws ec2 start-instances --instance-ids i-0b7f3342388888888

To avoid stop starting instances you can reload kernel module (not recommended)

sudo rmmod ena && sudo modprobe ena

Now login to a box and check a network interface driver in use

[ec2-user ~]$ ethtool -i eth0
driver: ena
version: 1.4.0g

References