Enable Enhanced Networking in RHEL EC2 Instances
Today we will learn, How to enable the enhanced networking (ENA) in Centos/RHEL/Amazon Linux EC2 instances.
Before moving further, un the following command to upgrade the kernel to the latest version::
1 ▶ sudo yum upgrade kernel -y
Now, Here are the steps that We have to taken in order to enable ENA:
Step 1. Ensure gcc is installed on the instance.
- Confirm if it is installed:
1 ▶ rpm -qa | grep -i gcc
- To install the package execute the command below:
1 ▶ sudo yum install gcc
Step 2. Ensure the kernel-devel package is installed using the command provided below.
- Confirm installation:
1 ▶ rpm -qa | grep -i kernel-devel-$(uname -r)
- To install the kernel-devel package run the command:
1 ▶ yum install kernel-devel-$(uname -r)
Step 3. Install the EPEL package from its repository:
- For RHEL 6
1 ▶ sudo yum install http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
- For RHEL 7
1 ▶ sudo yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm -y
Step 4. Install build-essentials and DKMS.
- Install the build-essentials and DKMS (Dynamic Kernel Module Support) packages to compile kernel modules and kernel rebuild for ENA on each upgrade and kernel development package
1 ▶ sudo yum install -y build-essential dkms kernel-devel kernel-devel-$(uname -r)
Step 5. Clone the Amazon ENA driver's source code.
1 ▶ sudo yum install -y git
2 ▶ git clone https://github.com/amzn/amzn-drivers
Step 6. Move package to the "/usr/src/" directory.
- Move the amzn-drivers package to the /usr/src/ directory. So that, dkms can find it and build it for each kernel update. Append the version number (you can find the current version number in the release notes) of the source code to the directory name.
1 ▶ sudo mv amzn-drivers /usr/src/amzn-drivers-2.0.2
Step 7. Create the dkms configuration file.
- We will create the dkms configuration file to substituting the version of ENA.
1 ▶ sudo touch /usr/src/amzn-drivers-2.0.2/dkms.conf
Step 8. Edit the file and add the following content.
1 ▶ sudo vi /usr/src/amzn-drivers-2.0.2/dkms.conf
1 PACKAGE_NAME="ena"
2 PACKAGE_VERSION="2.0.2"
3 CLEAN="make -C kernel/linux/ena clean"
4 MAKE="make -C kernel/linux/ena/ BUILD_KERNEL=${kernelver}"
5 BUILT_MODULE_NAME[0]="ena"
6 BUILT_MODULE_LOCATION="kernel/linux/ena"
7 DEST_MODULE_LOCATION[0]="/updates"
8 DEST_MODULE_NAME[0]="ena"
9 AUTOINSTALL="yes"
Step 9. Add, build, and install the ENA module on your instance using dkms.
a) Add the module to dkms.
▶ sudo dkms add -m amzn-drivers -v 2.0.2
b) Build the module using dkms.
▶ sudo dkms build -m amzn-drivers -v 2.0.2
c) Install the module using dkms.
▶ sudo dkms install -m amzn-drivers -v 2.0.2
Step 10. Update "initramfs" so the correct module is loaded at boot time.
1 ▶ sudo mkinitrd -f -v /boot/initramfs-$(uname -r).img $(uname -r)
Step 11. Before migrating, took a backup and confirmed the "/etc/fstab" entry using the commands:
1 ▶ sudo cp /etc/fstab /etc/fstab_backup
2 ▶ sudo cat /etc/fstab
Note: If the entry for device volume is mounted in UUID then you are good. But if the entry is mounted by device name then you will have to edit and change the device volume entry to be mounted in UUID.
- To find the UUID of the device volume
1 ▶ lsblk -f
-
Edit and mount the device with the UUID instead of the device volume name. For example:
UUID=abcd123e-4567-8910e-1f23-ec978d9581ae / ext4 defaults,nofail 0 2
Step 12. Stop the EC2 instance.
Step 13. On your local computer's AWS CLI modify the ENA attribute.
- Modify the ENA attribute:
1 ▶ aws ec2 modify-instance-attribute --instance-id i-0123abcd4567 --ena-support --region us-west-2
- Confirm modification
1 ▶ aws ec2 describe-instances --instance-ids i-08207464e4f6c09a3 --query "Reservations[].Instances[].EnaSupport"
Step 14. Start instance and confirm the installation of the ENA driver:
- Confirm ENA installation:
1 ▶ modinfo ena
Step 15. Update cloud-init to the latest version.
1 ▶ sudo yum update cloud-init
Step 16. 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:
1 ▶ sudo dracut -f -v
Step 17. Stop the instance. While stopped, change the instance type to M5/C5/R5 by selecting the instance from the AWS console, the 'Actions' tab, then 'Instance settings' followed by 'Change Instance Type'.
Note: You can also check the all the dependencies while running a simple script. To check the same, Please click this link.