I am learning how to create kernel modules and it was all working fine: I compiled, inserted the
sudo insmod cheat.ko, and the
printk messages inside the init function (set by
module_init) appeared correctly in
/etc/log/syslog. Then I made changes to the module, removed it with
sudo rmmod cheat.ko, reinserted, and
printk messages were good again.
Then, when I tried a new feature the screen became like a tty, error messages all over, I did ctrl-alt-f2 ctrl-alt-f7 (I'm on ubuntu), and I got back to the X server.
I undid the most recent modifications to the source file, recompiled, but the problem now is that I am unable to reinsert the module to test things out again, unless I reboot, which is too annoying for testing.
How can I reinsert the modified module without rebooting?
What I tried and info I got:
cat /etc/log/syslog: The only relevant information to me was:
BUG: unable to handle kernel NULL pointer dereference at 00000003
so it seems that was the cause of the problem, and then I got an oops:
Oops: 0002 [#1] SMP
Horrid debug information follows that, but nothing that seems to help me on how to reinsert the module.
sudo insmod cheat.ko: command just hangs, outputs nothing, and the only way I can get on using that terminal emulator is killing it with
sudo rmmod cheat:
Error: Module cheat is not currently loaded
sudo modprobe -r cheat.ko
FATAL: Module cheat.ko not found.
lsmod | grep cheat:
cheat 19009 -2
which has a very suspicious
cat /proc/modules | grep cheat
cheat 19009 1 - Loading 0x00000000 (OF+)
interesting, so the module is still loading...
As others have said, use a VM. And I strongly recommend you to use Vagrant to manage it.
Nah, Vagrant is for newbs, use QEMU + Buildroot instead: https://github.com/cirosantilli/linux-kernel-module-cheat