Building the AWS ENA driver ena.ko

Tried to load the Clear Linux AMI onto an EC2 i3en instance and it was forbidden by AWS, most likely because the kernel was not stamped with supporting the ENA interface. ENA is Amazon’s enhanced network adaptor.

I didn’t think it would be easy but I tried to follow the Amazon build instructions for the ena.ko module while running on an i3 instance with an updated Clear Linux ami but because it didn’t have specific instructions for the Clear Linux case, I used the generic Linux example but at the point where root would run make in the driver directory that was pulled from GitHub, the make failed.

I had also run sudo bundle-add make vimm git c-basic linux-dev

and uname -r reported 5.2.16-160.aws

/home/clear/amzn-drivers/kernel/linux/ena # make
make -C /lib/modules/5.2.16-160.aws/build M=/home/clear/amzn-drivers/kernel/linux/ena modules
make[1]: *** /lib/modules/5.2.16-160.aws/build: No such file or directory. Stop.
make: *** [Makefile:38: all] Error 2

I naively made the build directory it complained was not there but then the next make error showed there is more that should be going on.

/home/clear/amzn-drivers/kernel/linux/ena # make
make -C /lib/modules/5.2.16-160.aws/build M=/home/clear/amzn-drivers/kernel/linux/ena modules
make[1]: Entering directory ‘/usr/lib/modules/5.2.16-160.aws/build’
make[1]: *** No rule to make target ‘modules’. Stop.
make[1]: Leaving directory ‘/usr/lib/modules/5.2.16-160.aws/build’
make: *** [Makefile:38: all] Error 2

Should it be relatively easy to build this kernel module and then create my own ami from the official Clear Linux ami or am I falling down a rabbit hole? I already see this module would need to be rebuilt any time the Clear Linux kernel was updated and I might not be able to log in to perform the recompile if the network interface isn’t working. So this would not be for the kind of instance I couldn’t afford to destroy and build again.

Also wondering if there might be a plan to build an official Clear Linux ami that works on their ena instances in the future.

Hi @FrankReh you should checkout dkms. This will allow you to update the kernel module with every kernel update.

https://docs.01.org/clearlinux/latest/guides/kernel/kernel-modules-dkms.html

But uname -r returns 5.2.16-160.aws
while the Clear Linux DKMS install says " Only the native and lts kernels are enabled to build and load out-of-tree kernel modules with DKMS."

I went ahead and installed both the native and lts kernel dkms bundles and built a dkms.conf file by hand and created the driver directory usr /usr/src but when it came time to run dkms with add or build, the commands would hang with an error “Vim: Warning: Output is not to a terminal”.

Haven’t figured out what is causing that vim error or hang of dkms yet but the fact these instructions are not for an aws kernel bundle makes me wonder if it would work anyway.

DKMS does not support the AWS kernel.

You need to compile your own AWS kernel, and then include the ENA driver.

1 Like

Thanks @ahkok for the correct info.

Yes, thank you for the clarification. I think I would be taking this too far afield by trying to take on a process that rebuilt my own kernel whenever there were kernel updates so I will put off trying to use this further for aws. Sorry for the noise. Seems like a great project in general. The boot times and cleaned up user set for servers and auto update and module update designs are very nice.

2 Likes

Thanks for the right answer when I saw this I don’t know how to do it but after using the above solution I found a solution thanks for sharing. I am also want to make a career in as AWS developer: AWS Training in Noida | AWS Training in Delhi - AWS Course in Noida

For new readers: this information has changed since the original post. The AWS kernel does have headers and DKMS parts available through the kernel-aws-dkms bundle from October 2019.

3 Likes

If one creates a new EC2 instance from the Clear Linux AMI image in the AWS Marketplace, does it automatically use the AWS specific kernel (kernel-aws-dkms?

It uses the AWS specific kernel kernel-aws, but if you want the kernel sources and DKMS the optional kernel-aws-dkms bundle needs to be added.

1 Like