Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to install with DKMS #2

Open
bpranoto opened this issue Nov 18, 2020 · 5 comments
Open

How to install with DKMS #2

bpranoto opened this issue Nov 18, 2020 · 5 comments

Comments

@bpranoto
Copy link

This is not a bug report but my experience how I install this modul with DKMS so whenever a kernel upgrade, this module will be automatically recompiled and reinstalled. Hope this will help other people who still needs ipx with the modern linux.

My system is ubuntu 18.04 with kernel version 5.4.0-54-generic.

  1. Install dkms and build-essential
    sudo apt install dkms build-essential

  2. Create directory /usr/src/ipx-1.0
    sudo mkdir /usr/src/ipx-1.0

  3. Download this repository source https://github.com/pasis/ipx/archive/master.zip

  4. Extract the zip file, place the files to /usr/src/ipx-1.0 , here is mine:

bambang@bambang-Vostro-1014:/usr/src/ipx-1.0$ ls -l
total 108
-rw-r--r-- 1 root root 50935 Nov 17 22:06 af_ipx.c
-rw-r--r-- 1 root root     8 Nov 17 23:43 built-in.a
-rw-r--r-- 1 root root   277 Nov 18 00:07 dkms.conf
-rw-r--r-- 1 root root  8733 Nov 17 22:06 ipx_proc.c
-rw-r--r-- 1 root root  6785 Nov 17 22:06 ipx_route.c
-rw-r--r-- 1 root root  2794 Nov 17 22:06 Kconfig
-rw-r--r-- 1 root root   436 Nov 17 22:06 Makefile
drwxr-xr-x 2 root root  4096 Nov 17 22:06 net
-rw-r--r-- 1 root root  1687 Nov 17 22:06 p8023.c
-rw-r--r-- 1 root root   767 Nov 17 22:06 pe2.c
-rw-r--r-- 1 root root   321 Nov 17 22:06 README
-rw-r--r-- 1 root root   955 Nov 17 22:06 sysctl_net_ipx.c

  1. Create dkms.conf file in /usr/src/ipx-1.0 with the content:
MAKE="'make'"
CLEAN="make clean"
BUILT_MODULE_NAME[0]="ipx"
BUILT_MODULE_LOCATION[0]="./"
DEST_MODULE_LOCATION[0]="/kernel"
BUILT_MODULE_NAME[1]="p8023"
BUILT_MODULE_LOCATION[1]="./"
DEST_MODULE_LOCATION[1]="/kernel"
PACKAGE_NAME="ipx"
PACKAGE_VERSION="1.0"
AUTOINSTALL=yes

  1. Add this package to dkms database:
    sudo dkms add -m ipx -v 1.0
    Make sure there is no error

7.Build the package through dkms, dkms will try to make the package:
sudo dkms build -m ipx -v 1.0
Make sure there is no error.

8.Install the package
sudo dkms install -m ipx -v 1.0
This will copy to ipx.ko and p8023.ko to the appropriate directory.

9.Now we have to tell the computer to load the ipx kernel module everytime it boots. Create file /etc/modules-load.d/ipx.conf with content as follow:

p8022
psnap
p8023
ipx
  1. Reboot the computer

  2. Check wether the ipx.ko is load or not:
    bambang@bambang-Vostro-1014:/usr/src/ipx-1.0$ lsmod | grep ipx

ipx                    28672  0
p8023                  16384  1 ipx
psnap                  16384  1 ipx
p8022                  16384  1 ipx

  1. Check dkms status
bambang@bambang-Vostro-1014:/usr/src/ipx-1.0$ dkms status
ipx, 1.0, 5.4.0-54-generic, x86_64: installed

  1. Done. Thank you.
@pasis
Copy link
Owner

pasis commented Nov 18, 2020

Thank you for the guide!

@bpranoto
Copy link
Author

Thank you. Actually, I think this will be better going into the README or wiki.

@bpranoto
Copy link
Author

Correction, the make command in dkms.conf should be:
MAKE[0]="'make' KERNELDIR=/lib/modules/${kernelver}/build"

@bishopdynamics
Copy link

Since p8023.ko is no longer created by the makefile, updated dkms.conf (including correction by @bpranoto):

MAKE[0]="'make' KERNELDIR=/lib/modules/${kernelver}/build"
CLEAN="make clean"
BUILT_MODULE_NAME[0]="ipx"
BUILT_MODULE_LOCATION[0]="./"
DEST_MODULE_LOCATION[0]="/kernel"
PACKAGE_NAME="ipx"
PACKAGE_VERSION="1.0"
AUTOINSTALL=yes

@bishopdynamics
Copy link

And for the sake of completeness, I whipped up full install script for this kernel module and the userspace utils.
Tested on Ubuntu 24.10 with kernel 6.11.0-9-generic

#!/usr/bin/env bash
# Compile IPX kernel module using DKMS, and install IPX-Utils for management

# need to be root
if [ "$(id -u)" != "0" ]; then
    echo "Must be run as root"
    exit 1
fi

# sanity check
if [ "$(uname -s)" != "Linux" ]; then
    echo "Only works on Linux!"
    exit 1
fi

set -e # bail on any errors

# install needed packages
apt-get update
apt-get install -y build-essential automake linux-source dkms git make gcc curl unzip pahole

# fetch the latest ipx source and place it in a reasonable location
cd /tmp
if [ -f master.zip ]; then
    rm master.zip
fi
if [ -d ipx-master ]; then
    rm -rf ipx-master
fi
curl -LO https://github.com/pasis/ipx/archive/master.zip
unzip master.zip
rm master.zip
if [ -d "/usr/src/ipx-1.0" ]; then
    rm -r "/usr/src/ipx-1.0"
fi
mv ipx-master /usr/src/ipx-1.0
cd /usr/src/ipx-1.0

# Create the DKMS configuration file
cat <<'EOF_DKMSCONF' >dkms.conf
MAKE[0]="'make' KERNELDIR=/lib/modules/${kernelver}/build"
CLEAN="make clean"
BUILT_MODULE_NAME[0]="ipx"
BUILT_MODULE_LOCATION[0]="./"
DEST_MODULE_LOCATION[0]="/kernel"
PACKAGE_NAME="ipx"
PACKAGE_VERSION="1.0"
AUTOINSTALL=yes
EOF_DKMSCONF

# add this package to DKMS database
dkms add -m ipx -v 1.0 || {
    echo "looks like ipx module might already be registered, removing and re-adding"
    dkms remove -m ipx -v 1.0 --all
    dkms add -m ipx -v 1.0
}

# first build
dkms build -m ipx -v 1.0

# install it
dkms install -m ipx -v 1.0

# load the kernal at boot
mkdir -p /etc/modules-load.d
cat <<EOF_IPXCONF >/etc/modules-load.d/ipx.conf
p8022
psnap
p8023
ipx
EOF_IPXCONF

# compile and install IPX userspace utilities
cd /tmp
if [ -f master.zip ]; then
    rm master.zip
fi
if [ -d ipx-master ]; then
    rm -rf ipx-utils-master
fi
curl -LO https://github.com/pasis/ipx-utils/archive/master.zip
unzip master.zip
rm master.zip
mv ipx-utils-master /usr/src/ipx-utils-1.2

echo "compiling ipx-utils"
cd /usr/src/ipx-utils-1.2
aclocal
autoconf
automake --add-missing
./configure
make
make install

echo "Done setting up IPX kernel module and userspace utils."
echo "please reboot"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants