Not so much asking what books (although if you know of any guides/tutorials that'd be helpful) but what is the best way to start doing kernel programming and is there a particular distribution that would be best to learn on?

I'm mostly interested in the Device Drivers portion, but I want to learn how the Kernel is set up as well (Modules and such) I have around 4-5 years Experience with C/C++ but it's mostly knowledge from College (so it's not like 4-5 years work experience, if you know what I mean)

  • 4
    To start with, it's spelled kernel with an e.
    – Caleb
    Commented May 10, 2011 at 13:20
  • Ya I noticed that when I was putting on the tags lol.
    – user4877
    Commented May 10, 2011 at 14:38
  • 4
    Next time take the time to fix it. It's a good way to respect the community here that is taking the time to help you. Also if you want to code for the kernel, your going to have to be rigorous about details like that!
    – Caleb
    Commented May 10, 2011 at 14:44
  • @Caleb, will do!
    – user4877
    Commented May 10, 2011 at 15:13
  • Thank you for asking this question, I have always wondered myself Commented May 11, 2011 at 10:12

4 Answers 4



For the baby stages, writing various variations on "hello world" modules, and virtual hardware drivers, are the best way to start (real hardware introduces real world problems best faced when you have more of an idea what you are doing).

"Linux Device Drivers" is an excellent book and well worth starting with: http://lwn.net/Kernel/LDD3/

LDD (used to, at least) have exercises where you wrote virtual drivers, e.g. RAM disks, and virtual network devices.


subscribe to https://lkml.org/ or to the mailing list of a sub-system you will be hacking in. Lurk for a bit, scanning over threads, reading code review (replies to patches) to see what kind of things people stumble on or pick up on.

See if you can obtain (cheap) hardware for a device that is not yet supported, or not yet supported well. Good candidates are cheap-ish USB NICs or similar, low-cost USB peripherals. Something with an out-of-date, or out-of-tree driver, perhaps vendor written, perhaps for 2.4.x, is ideal, since you can start with something that works (sort-of), and gradually adapt it/rewrite it, testing as you go. My first driver attempt was for a Davicom DM9601 USB NIC. There was a 2.4-series vendor-written kernel driver that I slowly adapted to 2.6. (Note: the driver in mainline is not my driver, in the end someone else wrote one from scratch).

Another good way in is to look at the Kernel Newbies site, specifically the "kernel janitors" todo: http://kernelnewbies.org/KernelJanitors/Todo This is a list of tasks that a beginner should be able to tackle.

  • 4
    Good answer for Linux, missing just one resource: LXR for browsing the kernel source. Commented May 10, 2011 at 22:41

There are many kernels in existence.

Linux is not the only game out there, but it's the most widely used. Some people recommend the minix kernel to understand operating system concepts. I would go with Linux 2.6.x series as it's the most common and it won't be wasted on something (almost) nobody uses. Solaris, XNU (Mac), FreeBSD and Dragonfly are notable.1

Find something super simple (serial port, usb, etc.) and make it do something else. For an extra challenge, try writing a kernel module for something that doesn't yet have one. (Be sure to google the suspect by pci sudo lspci -nn and/or usb id sudo lsusb first.)

Update: Don't do this directly on your primary system, use virtual machines (VM) (computer in a computer) as mentioned. VirtualBox can provide this and it's free. Also, I don't want it to seem overwhelming, but try VM snapshots so you can go back in case something breaks the VM itself.

Update 2: The note about Git (DVCSes inc. mercurial, fossil, bazaar, darcs) is a good idea, mostly for code and small, important files. Try not to use Git to backup music, videos and such unless you know the implications. ;)


Find a module or driver you want to modify or start with a null / hello world type of module and build from there. Specifically work with a module because it will allow you to load, unload, recompile and reload the code into a running kernel. Later you can get into the core bits, but basically modules have all kinds of and you can do pretty much whatever you like.

Second, use a VM. Setup a guest machine under VirtualBox or some over VM and do your kernel testing in there for a while. That way you won't kill your main system when you break something, and restarting, backtracking to a working snapshot, etc is really easy.

Third, learn git.


Someone already mentions the book "Linux Device Drivers" - this is an excellent resource, and I highly recommend it as well.

Although the question mentions the originator isn't asking specifically for books, the newest edition of the book "Understanding the Linux Kernel" ( http://oreilly.com/catalog/9780596005658/ ) is invaluable in learning about the Linux kernel in general, and also contains a section on Linux device drivers.

You must log in to answer this question.