-
-
Save 7171u/dd77833a008f0965280f to your computer and use it in GitHub Desktop.
For a linux kernel below 3.2.0-22.25 | |
yum install kernel-devel automake autoconf gcc glib make ncurses-devel ncurses sysfsutils | |
yum install rpm-build redhat-rpm-config asciidoc hmaccalc perl-ExtUtils-Embed xmlto | |
yum install audit-libs-devel binutils-devel elfutils-devel elfutils-libelf-devel | |
yum install newt-devel python-devel zlib-devel | |
Download sysfsutils-2.1.0.tar.gz | |
tar xvf sysfsutils-2.1.0.tar.gz | |
cd sysfsutils-2.1.0 | |
./configure | |
make | |
make install | |
#Module build | |
Download the correct linux-`uname -r`.tar.bz2 from vault.centos.org | |
Login as a diffrent user other than root | |
tar xvf linux-`uname -r`.tar.bz2 -C ~/ | |
cp /usr/src/kernels/<uname -r>/Module.symvers ~/linux-`uname -r` | |
cd ~/linux-`uname -r` | |
make oldconfig | |
make menuconfig | |
>>Device Drivers>>Statging>USBIP ( Select M) | |
make prepare | |
make M=drivers/staging/usbip/ | |
sudo cp drivers/staging/usbip/*.ko /lib/modules/`uname -r`/extra/ | |
sudo modprobe vhci-hcd | |
sudo modprobe usbip_common_mod | |
sudo modprobe usbip | |
#Binary file build | |
Download http://sourceforge.net/projects/usbip/files/usbip/0.1.7/usbip-0.1.7.tar.gz/download | |
tar xvf usbip-0.1.7.tar.gz -C /tmp | |
cd /tmp/usbip-0.1.7/src/ | |
./autogen.sh | |
make | |
ls | |
./configure | |
make | |
sudo make install | |
Ref: | |
http://sourceforge.net/p/usbip/discussion/418507/thread/86706429/ | |
http://askubuntu.com/questions/14627/no-symbol-version-for-module-layout-when-trying-to-load-usbhid-ko | |
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/900384 | |
http://wiki.centos.org/HowTos/I_need_the_Kernel_Source | |
http://wiki.centos.org/HowTos/BuildingKernelModules | |
Successful steps on CentOS Linux release 7.3.1611 (Core) 3.10.0-514.2.2.el7.x86_64 to compile the modules:
(for some people, some steps might not be needed)
The following gets you past the well-known errors such as:
1. No rule to make target `arch/x86/syscalls/syscall_32.tbl',
2. /bin/sh: scripts/genksyms/genksyms: No such file or directory
3. insmod: ERROR: could not insert module /lib/modules/3.10.0-514.2.2.el7.x86_64/extra/usbip-core.ko: Invalid module format
and
4. insmod: ERROR: could not insert module /lib/modules/3.10.0-514.2.2.el7.x86_64/extra/vhci-hcd.ko: Unknown symbol in module
Under root (or another super/sudo user):
- Install some prerequisites (if you haven't already done so)
sudo yum install kernel-tools kernel-tools-libs kernel-devel kernel-headers
Note: Bear in mind you might need some additional packages described here and also we need the full kernel source as these modules fail to compile otherwise hence the error listed by number 1 in the above mentioned.
Under non-root user (I used the user builder):
- Set a variable to make commands usage and life easier
export OS_VER="7.3.1611"
export KERNEL_VER="3.10.0-514.2.2.el7"
export KERNEL_ARCH="x86_64"
- Get header source RPM
wget http://vault.centos.org/$OS_VER/updates/Source/SPackages/kernel-$KERNEL_VER.src.rpm
- Install RPM
rpm -i kernel-$KERNEL_VER.src.rpm
- Make some directories required for compiling
mkdir -p ~/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
- RPM macro
echo '%_topdir %(echo $HOME)/rpmbuild' > ~/.rpmmacros
- Prepare to compile
cd ~/rpmbuild/SPECS/
- Prepare source code, needed to compile the kernel modules
rpmbuild -bp --target=$(uname -m) kernel.spec
- Go to kernel source tree to compile
cd ~/rpmbuild/BUILD/kernel-$KERNEL_VER/linux-$KERNEL_VER.$KERNEL_ARCH/
-------------------------------
ONLY IF YOU ARE RECOMPILING OR FAILED SOMEWHERE BELOW THIS POINT GET BACK TO HERE AND DO A
make mrproper
------------------------------- - Copy module symbols versions
cp /usr/src/kernels/$KERNEL_VER.$KERNEL_ARCH/Module.symvers .
- Copy current config
cp /boot/config-$KERNEL_VER.$KERNEL_ARCH .config
- Configure everything according to what we copied
make oldconfig
- Pick what we want to compile (>>Device Drivers>>Statging>USBIP ( Select M))
make menuconfig
- Now prepare to compile for real
make prepare
- Make scripts
make scripts
- FINALLY... compile the modules (only)
make M=drivers/staging/usbip/
Again, under root (or another super/sudo user):
- We need those vars again
export KERNEL_VER="3.10.0-514.2.2.el7"
export KERNEL_ARCH="x86_64"
- Copy the modules (replace /home/builder if you need)
sudo cp /home/builder/rpmbuild/BUILD/kernel-$KERNEL_VER/linux-$KERNEL_VER.$KERNEL_ARCH/drivers/staging/usbip/*.ko /lib/modules/$KERNEL_VER.$KERNEL_ARCH/extra/
- Insert whatever modules you need
sudo insmod /lib/modules/$KERNEL_VER.$KERNEL_ARCH/extra/usbip-core.ko
sudo insmod /lib/modules/$KERNEL_VER.$KERNEL_ARCH/extra/usbip-host.ko
sudo insmod /lib/modules/$KERNEL_VER.$KERNEL_ARCH/extra/vhci-hcd.ko
And there you go! You finally have working USB/IP Modules.
On CentOS 6.6 (and probably all others) you also need to:
make scripts
Before compiling the module, else you'll get a failure like:
/bin/sh: scripts/genksyms/genksyms: No such file or directory
And before "sudo modprobe vhci-hcd
" you also need to
depmod -a
On CentOS 6.6 (and probably all others) you also need to:
make scripts
Before compiling the module, else you'll get a failure like:
/bin/sh: scripts/genksyms/genksyms: No such file or directory