mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 10:15:57 +01:00
36 lines
669 B
Markdown
36 lines
669 B
Markdown
# Host
|
|
|
|
Simple things that can be demonstrated by inserting a module into the currently running host. Tested on Ubuntu 16.04.
|
|
|
|
1. [hello](hello.c)
|
|
|
|
## Rationale
|
|
|
|
This method easier to setup, but it is not recommended for development, as:
|
|
|
|
- it may break your system
|
|
- you can't control which kernel version to use
|
|
|
|
Use VMs instead.
|
|
|
|
## Usage
|
|
|
|
We only use it for super simple examples.
|
|
|
|
Build, insert and remove a hello world module:
|
|
|
|
make
|
|
|
|
sudo insmod hello.ko
|
|
|
|
# Our module should be there.
|
|
sudo lsmod | grep hello
|
|
|
|
# Last message should be: init_module
|
|
dmest -T
|
|
|
|
sudo rmmod hello
|
|
|
|
# Last message should be: cleanup_module
|
|
dmest -T
|