How to install usbip vhci_hcd drivers on an AWS EC2 Ubuntu Kernel Version

0

It took me a while to figure out the problem, but I've been stuck and can't seem to find a solution to this.

So basically I want to connect a local USB to a AWS EC2 Instance, and the way to do it on linux is through usbip, but the problem now lies with EC2 Kernel Instances, they dont have the drivers installed by default, and drives need the exact specs to be loaded on the system.

Now, I have been trying to manually compile the drivers but I haven't managed to successfully accomplish that, the reason being is that the system does not compile the specific .ko module but at the same time, the other .ko modules installed, are not supported by the kernel.

The steps I am following are taken from here on Ubuntu on how to build my kernel: https://wiki.ubuntu.com/Kernel/BuildYourOwnKernel

This is to pull the correct kernel version that is under use from the EC2, the other steps are:

ubuntu@:$ sudo cp /boot/config-$(uname -r) .config
ubuntu@:
$ sudo cp /usr/src/linux-headers-$(uname -r)/Module.symvers .
ubuntu@:$ sudo make menuconfig
ubuntu@:
$ sudo make modules_prepare && sudo make M=drivers/usb/usbip
ubuntu@:~$ sudo insmod drivers/usb/usbip/usbip-core.ko && sudo insmod drivers/usb/usbip/vhci-hcd.ko
but even though the module compiles, there are no .ko drivers, nor the ones compiled work.

Is there a way to make usbip work on AWS on a EC2 instance? Is there another solution to the usbip drivers?

TValley
asked 3 years ago2040 views
1 Answer
0

So, I got an answer to this question from someone at AWS Support team. Hope this answer helps someone else in need.

You reached out to AWS Support, because you are looking to use usbip client on AWS EC2 instances, but found no required kernel modules (usbip-core, vhci-hcd) available on Ubuntu[18|20] AMIs. You would like our assistance to address this and find the way to have usbip working on AWS EC2 instances.

In my test environment in us-east-1 AWS Region, I launched test EC2 instances from the latest AMIs for Amazon Linux 2 (ami-0be2609ba883822ec), and Ubuntu 20.04 (ami-0885b1f6bd170450c).

I found that Amazon Linux 2 has required drivers:

uname -r

4.14.209-160.339.amzn2.x86_64  

modinfo vhci_hcd usbip_core | grep filename

filename:       /lib/modules/4.14.209-160.339.amzn2.x86_64/kernel/drivers/usb/usbip/vhci-hcd.ko  
filename:       /lib/modules/4.14.209-160.339.amzn2.x86_64/kernel/drivers/usb/usbip/usbip-core.ko  

But, I didn't find usbip userspace tools after enabled EPEL repository[1], and scanned for package which may have this binary:

yum provides */usbip | grep bin

And proceeded with installation of it from a tarball I sourceforge[2]:

yum install autoconf libtool libsysfs-devel glib*

wget https://downloads.sourceforge.net/project/usbip/usbip/0.1.7/usbip-0.1.7.tar.gz

tar -xzf usbip-0.1.7.tar.gz

cd usbip-0.1.7/src

./autogen.sh

./configure

make install

By default it's installed in /usr/local/bin which can be added to PATH with profile:

echo "export PATH=$PATH:/usr/local/bin" > /etc/profile.d/path.sh && source /etc/profile.d/path.sh

usbip --help

For Ubuntu 20.04, I found that the drivers are available in "linux-image-extra-virtual" and I have it installed with 5.4.0-58-generic kernel:

uname -r

5.4.0-1029-aws  

apt update

apt install linux-image-extra-virtual

find /usr/ -iname "vhci*"

/usr/lib/modules/5.4.0-58-generic/kernel/drivers/usb/usbip/vhci-hcd.ko  
..  

find /usr/ -iname "usbip*"

/usr/lib/modules/5.4.0-58-generic/kernel/drivers/usb/usbip  
/usr/lib/modules/5.4.0-58-generic/kernel/drivers/usb/usbip/usbip-core.ko  
/usr/lib/modules/5.4.0-58-generic/kernel/drivers/usb/usbip/usbip-vudc.ko  
/usr/lib/modules/5.4.0-58-generic/kernel/drivers/usb/usbip/usbip-host.ko  
..  

Added drivers to load on boot:

echo "vhci_hcd" >> /etc/modules-load.d/modules.conf

echo "usbip_core" >> /etc/modules-load.d/modules.conf

Then installed usbip:

apt install linux-tools-5.4.0-58-generic

Then modified grub to boot with 5.4.0-58-generic instead of 5.4.0-1029-aws according to $menuentry_id_option in my /boot/grub/grub.cfg

grep -A1000 submenu /boot/grub/grub.cfg |grep menuentry

submenu 'Advanced options for Ubuntu' $menuentry_id_option 'gnulinux-advanced-175c087c-0fe9-4d62-a38d-e5f8a66a5851' {
..
menuentry 'Ubuntu, with Linux 5.4.0-58-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.4.0-58-generic-advanced-175c087c-0fe9-4d62-a38d-e5f8a66a5851' {
..
vim /etc/default/grub
#GRUB_DEFAULT=0
GRUB_DEFAULT="gnulinux-advanced-175c087c-0fe9-4d62-a38d-e5f8a66a5851>gnulinux-5.4.0-58-generic-advanced-175c087c-0fe9-4d62-a38d-e5f8a66a5851"

Then updated grub, rebooted ec2 instance, and verified usbip and loaded modules:

update-grub && reboot

uname -r

5.4.0-58-generic  

lsmod | grep vhci

vhci_hcd               53248  0  
usbip_core             36864  1 vhci_hcd  

usbip --help

Edited by: TValley on Dec 31, 2020 12:51 AM

TValley
answered 3 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions