I am learning how to create kernel modules and it was all working fine: I compiled, inserted the .ko with 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 00000003so it seems that was the cause of the problem, and then I got an oops:
Oops: 0002 [#1] SMPHorrid 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 withc-csudo rmmod cheat:Error: Module cheat is not currently loadedsudo modprobe -r cheat.koFATAL: Module cheat.ko not found.lsmod | grep cheat:cheat 19009 -2which has a very suspicious
-2usage count...cat /proc/modules | grep cheatcheat 19009 1 - Loading 0x00000000 (OF+)interesting, so the module is still loading...
Edit
As others have said, use a VM. And I strongly recommend you to use Vagrant to manage it.
Edit 2
Nah, Vagrant is for newbs, use QEMU + Buildroot instead: https://github.com/cirosantilli/linux-kernel-module-cheat
cheat, notcheat.ko). But you should seriously consider rebooting (or better: experiment in a VM rather than your host). Generating an OOPS in kernel is Not A Good Thing, you have no idea (I guess) what you could have "corrupted" or otherwise rendered dysfunctional.sudo rmmod cheatand got the same result. Updated question using it.