4

I am just learning linux kernel programming with the LINUX KERNEL DEVELOPMENT book(I am beginner linux kernel programming but not on linux programming). It is possible to test programs in a kernel machine with VMware viritual on Ubuntu without damage my system ?

sergio campo
  • 190
  • 2
  • 13
  • 1
    A handy trick with VirtualBox or (paid version only?) VMWare is, you can take snapshots of the VM. So, when you have it in working state, take a snapshot. If it no longer boots, you just roll back to a snapshot (unless you want to examine what went wrong). – hyde Oct 12 '14 at 11:09
  • I just only want to know if i can test drivers without any hardware or methodology or standart to do it. – sergio campo Oct 13 '14 at 11:42
  • 1
    I would highly recommend installing linux (any flavour) on the bare metal, then use KVM and virt-manager to manage your VM's on which you can test the development version of the kernel, write your own drivers/module to play around. – askb Oct 14 '14 at 13:23

3 Answers3

5

Yes you can safely test kernel modules on a virtual machine! I'll give you some links that may help: watch this site

in particular this book:

Also this guide: http://www.tldp.org/HOWTO/Module-HOWTO/

invictus1306
  • 587
  • 1
  • 4
  • 19
  • It is so useful. In conclusion, can I have a virtual machine with the image of the http://beagleboard.org/ board ,make usb drivers and test it in the same virtual machine without any hardware? – sergio campo Oct 13 '14 at 11:33
  • I do not believe to be possible, it must be borne in mind also the ARM processor. You could buy the card and do the test with real hardware (in this case you should also www.raspberrypi.org/ is very well documented) You might also download a version of Ubuntu (or other), virtualise (x86 32/64 bit), and then test the implementation of kernel modules; this seems like the best way to start – invictus1306 Oct 13 '14 at 12:12
3

An embedded distro is even better

An Ubuntu guest is fine, but I prefer to keep things minimal and use an embedded distro, as this will make things:

  • simpler and easier to understand and control
  • faster

In particular, I recommend using:

Embedded distros can generate rootfs images smaller than 10MiB, and it becomes possible to understand the entire userland setup, which will make it easier to focus on the kernel.

I have made a setup to make everything as automated as possible: https://github.com/cirosantilli/linux-kernel-module-cheat

Ciro Santilli OurBigBook.com
  • 347,512
  • 102
  • 1,199
  • 985
1

I've been using a VM for a long time for Linux kernel programming and I've never had any problem. Actually, if you manage to violate the protections of a VM then you will probably be hired by Oracle or VMWare :D

However, I recommend you to read this post: https://security.stackexchange.com/questions/23452/is-it-safe-to-use-virtual-machines-when-examining-malware

Community
  • 1
  • 1
Claudi
  • 5,224
  • 17
  • 30
  • Are you using any special settings for the virtual machine that you use for Linux kernel programming or are you using the default settings? – karel Oct 12 '14 at 08:39
  • You got me... I'm actually not responsible of managing the VMs we use at work. I'll try to get an answer tomorrow. – Claudi Oct 12 '14 at 08:42
  • Is there another way? I mean another way to learn linux kernel programming? – sergio campo Oct 12 '14 at 08:52
  • 2
    @karel If you're not trying to interact with _real_ hardware, no special settings should be necessary. If you need to map real hardware into your VMs memory space to write a hardware driver, you'll need VM specific settings for that. – Joachim Isaksson Oct 12 '14 at 08:53
  • @sergiocampo If you want to test on the same machine as you're writing the programs, a VM or emulator (VMware/KVM/Qemu/...) is a very good way since most of them allow bugs to only crash a limited part of the system and roll back the file systems easily. If you want to test on a remote system there are many solutions, but most of them are rather specific to the target system so a very wide topic. – Joachim Isaksson Oct 12 '14 at 08:56