I'm in an operating systems class. Coming up, we have to do some work modifying kernel code. We have been advised not to use personal machines to test (I suppose this means install it) as we could write bad code and write over somewhere we shouldn't. We are given access to a machine in a lab to be safe.

If I were to test using a VM, would that protect the host system from potentially unsafe code? I really want to not have to be stuck to a system at school and snapshots will be useful.

If it is still high risk, any suggestions on what I need to consider to test safely?

We will be using something like linuxmint to start with. If anyone wants to see what will be in the current project: http://www.cs.fsu.edu/~cop4610t/assignments/project2/writeup/specification.pdf

  • It's honestly not so much of a risk to do it on real hardware, especially if you take backups. I have, and I'm sure many other devs have as well.
    – hobbs
    Commented Oct 1, 2015 at 2:54
  • @hobbs That's because many of us like to live dangerously, usually long enough to regret it. Working on your actual machine is fine if you're a careful developer working on rather small modules. For larger developments (or careless devs), it's probably best to work on an isolated environment. It might also be a good idea to work on a "clean distribution", to make sure no kernel-level customisation can interefere with your module. Keep in mind that kernel module development is where the smallest mistake can have the most dreadful consequences :D Commented Oct 1, 2015 at 16:52

3 Answers 3


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.

  • 4
    Or it might be possible to snapshot only certain aspects of the VM. Keeping source code on a separate virtual disk, for example. Of course, an out-of-VM source code repository to which you regularly check in code is a good idea anyway; it can save you from many embarassing mistakes, and it teaches good coding practice.
    – user
    Commented Oct 1, 2015 at 11:02
  • 1
    The other side of crashing your system more easily is that when you do crash your system, you have a higher chance of causing collateral corruption. Commented Oct 2, 2015 at 0:13

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. :)


Assuming you have written some c programs to run as a process (A process is just a program in execution) in user space, now you you want get where the real action is(kernel space). Where a single wild pointer can wipe out your file system may be your entire kernel.

Yes i would recommend a VM for a beginners. That will protect your kernel from you XD.

Some people prefer Docker, which is not a good option because at the end you are using your main kernel. Docker is like another distribution on the same kernel.

Snapshots are just for restoring files of your home directory .you can use any version control system to do that in an easy way.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .