Is developing/testing a linux module safe using a virtual machine?

The main risks developing kernel modules are that you can crash your system much more easily than with regular code, and you'll probably find that you sometimes create modules that can't be unloaded which means you'll have to reboot to re-load them after you fix what's wrong.

Yes, a VM is fine for this kind of development and it's what I use when I'm working on kernel modules. The VM nicely isolates your test environment from your running system.

If you're going to take and restore snapshots, you should keep your source code checked in to a version control repository outside the VM so you don't accidentally lose your latest code when you discard the VM's current state.


Assuming you aren't trying to write a driver for actual hardware, this is a great way to work on modules. You can snapshot the working system, and if you blow something up, just go back to the snapshot.

If you can, make a full duplicate of the VM, just in case the snapshot system is weirder than I think. :)