dkms

最後更新: 2021-07-05

介紹

 

dkms = Dynamic Kernel Module Support

dkms is a framework which allows kernel modules to be dynamically built

  for each kernel on your system in a simplified and organized fashion.

* 在 centos 要安裝 kernel-devel

目錄

 


Command

 

安裝

yum install dkms

add

 * The source-tree contains a dkms.conf file

 * It will copy /path/to/source-tree to /usr/src/module-module-version

i.e.

dkms add /path/to/source-tree

status

# Returns the current status of modules

dkms status

zfs/2.0.7: added

build

# All builds occur in the directory /var/lib/dkms/<module>/<module-version>/build

# If the -k option is not specified it builds for the currently running kernel and arch

build module/module-version [-k kernel/arch]

i.e.

#1 找出 module/module-version

dkms status

#2 build it

dkms build module/module-version

install

# Installs a built "module/version" combo onto the kernel it was built for.

# If the module has not been built, dkms will try to build it.

i.e.

dkms install zfs/2.0.7

remove

remove [module/module-version] [-k kernel/arch] [--all]

Use the --all option in order to remove all instances for every kernel at once.

i.e.

dkms remove drbd/9.0.29-1 --all

Error! The module/version combo: drbd-9.0.29-1
is not located in the DKMS tree.

Or

------------------------------
Deleting module version: 9.0.29-1
completely from the DKMS tree.
------------------------------
Done.

 


dkms.conf

 

$kernelver

要 build 的 kernel version number: $kernelver

PACKAGE_NAME

PACKAGE_VERSION

BUILT_MODULE_NAME[#]

不包含 .ko 副檔名

BUILT_MODULE_LOCATION[#]

成功編譯的 .ko 所在目錄

find . -name drbd.ko

DEST_MODULE_LOCATION[#]

.ko 將會放置在那目錄

Centos & Ubuntu 都不食此設定, default 在 /lib/modules/$(uname -r)/extra/

drbd.ko.xz  drbd_transport_tcp.ko.xz

MAKE[#]

i.e.

PACKAGE_NAME="drbd"
PACKAGE_VERSION="9.0.29-1"
BUILT_MODULE_NAME[0]="drbd"
BUILT_MODULE_NAME[1]="drbd_transport_tcp"
BUILT_MODULE_LOCATION[0]="drbd/"
BUILT_MODULE_LOCATION[1]="drbd/"
MAKE="make -j KDIR=/usr/src/kernels/$kernelver"
CLEAN="make clean"

 


Example: Build drbd

 

dkms add /usr/src/drbd/drbd-9.0.29-1

Creating symlink /var/lib/dkms/drbd/9.0.29-1/source ->
                 /usr/src/drbd-9.0.29-1

DKMS: add completed.

dkms status

drbd, 9.0.29-1: added

dkms build drbd/9.0.29-1

Kernel preparation unnecessary for this kernel.  Skipping...

Building module:
cleaning build area...
./configure; make -j KDIR=/usr/src/kernels/3.10.0-1160.31.1.el7.x86_64............
cleaning build area...

DKMS: build completed.

dkms install drbd/9.0.29-1

drbd.ko.xz:
Running module version sanity check.
 - Original module
   - No original module exists within this kernel
 - Installation
   - Installing to /lib/modules/3.10.0-1160.31.1.el7.x86_64/extra/

...

dkms remove drbd/9.0.29-1 --all

-------- Uninstall Beginning --------
Module:  drbd
Version: 9.0.29-1
Kernel:  3.10.0-1160.31.1.el7.x86_64 (x86_64)
-------------------------------------

...

 

 

Creative Commons license icon Creative Commons license icon