Last active
May 27, 2020 17:44
-
-
Save 42milez/d4bd07d28ccac75f33ddbf15c6342756 to your computer and use it in GitHub Desktop.
This script install the Linux kernel driver to provide ENA support for CentOS 7.x and 6.x.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# https://docs.aws.amazon.com/ja_jp/AWSEC2/latest/UserGuide/enhanced-networking-ena.html | |
amzn_driver_ver="1.5.3" | |
centos_ver=`sed -e 's/^CentOS\s\(Linux\s\|\)release\s\([0-9.]\+\)\s.\+$/\2/' /etc/centos-release` | |
# Install the appropriate kernel-devel and kernel-headers | |
# -------------------------------------------------- | |
yum install -y perl | |
rpm -ivh http://vault.centos.org/${centos_ver}/updates/x86_64/Packages/kernel-devel-$(uname -r).rpm | |
rpm -ivh http://vault.centos.org/${centos_ver}/updates/x86_64/Packages/kernel-headers-$(uname -r).rpm | |
# Install dkms | |
# -------------------------------------------------- | |
yum install -y wget | |
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-$(rpm -E '%{rhel}').noarch.rpm | |
rpm -ivh epel-release-latest-$(rpm -E '%{rhel}').noarch.rpm | |
rm epel-release-latest-$(rpm -E '%{rhel}').noarch.rpm | |
sed -i 's/mirrorlist=https/mirrorlist=http/' /etc/yum.repos.d/epel.repo | |
sed -i 's/enabled=1/enabled=0/g' /etc/yum.repos.d/epel.repo | |
yum install -y --enablerepo=epel dkms | |
# Install amzn-drivers | |
# -------------------------------------------------- | |
yum update -y nss curl libcurl | |
yum install -y git | |
git clone https://github.com/amzn/amzn-drivers | |
mv amzn-drivers /usr/src/amzn-drivers-${amzn_driver_ver} | |
cat << EOS >> /usr/src/amzn-drivers-${amzn_driver_ver}/dkms.conf | |
PACKAGE_NAME="ena" | |
PACKAGE_VERSION="${amzn_driver_ver}" | |
CLEAN="make -C kernel/linux/ena clean" | |
MAKE="make -C kernel/linux/ena/ BUILD_KERNEL=$(uname -r)" | |
BUILT_MODULE_NAME[0]="ena" | |
BUILT_MODULE_LOCATION="kernel/linux/ena" | |
DEST_MODULE_LOCATION[0]="/updates" | |
DEST_MODULE_NAME[0]="ena" | |
AUTOINSTALL="yes" | |
EOS | |
dkms add -m amzn-drivers -v ${amzn_driver_ver} | |
dkms build -m amzn-drivers -v ${amzn_driver_ver} | |
dkms install -m amzn-drivers -v ${amzn_driver_ver} | |
# Creates a list of module dependencies | |
# -------------------------------------------------- | |
depmod | |
# Create an initramfs | |
# -------------------------------------------------- | |
dracut -f -v | |
# Modify GRUB configuration to use eth0 for ENA | |
# -------------------------------------------------- | |
if [[ ${centos_ver} =~ ^7 ]] ; then | |
sed -i '/^GRUB\_CMDLINE\_LINUX/s/\"$/\ net\.ifnames\=0\"/' /etc/default/grub | |
grub2-mkconfig -o /boot/grub2/grub.cfg | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment