8

I want to do kernel module programming. But, all sources tell that linux distributions patch the original kernel and that module codes might not run on them. If this is true, what should i do.I tried making lfs using ubuntu but errors cropped up at almost every step. I saw somewhere that arch, gentoo, Ubuntu Server without any packages selected during the installation, slackware, susestudio etc. are vanilla distributions. So, can i use them for module programming?

Please suggest keeping in mind that i need a GUI in the distribution.

Can this be followed?
PS: I have a intel core i3 processor and will be running the distros on vmware workstation.

dave
  • 4,812
  • 4
  • 25
  • 38
AvinashK
  • 3,309
  • 8
  • 43
  • 94
  • Arch Linux patches the kernel, but you can install the vanilla Linux kernel from [the AUR](https://aur.archlinux.org/packages.php?ID=51082) easily. It isn't a beginner distro (you have to install X server, a DE, etc.), but it is powerful. – Blender Sep 16 '12 at 19:18
  • 2
    Modular Programming is not really directly related to the Linux Kernel. It is related to programming languages: Ocaml and Go do provide modules. If you care only about modules in the kernel your title is wrong (it is not modular *programming*, but modular kernel). – Basile Starynkevitch Sep 16 '12 at 19:29
  • Yes, please do explain what exactly you mean by "Modular programming"... – thkala Sep 16 '12 at 22:00
  • @BasileStarynkevitch@thkala...yes i was referring to modular kernel – AvinashK Sep 17 '12 at 09:48
  • 1
    possible duplicate of [distro for linux kernel development](http://stackoverflow.com/questions/3503414/distro-for-linux-kernel-development) – jsj May 15 '14 at 12:40

1 Answers1

9

If you want to program kernel modules then it doesn't matter which distribution you choose. You will need to be able to recompile the kernel from source and install a new kernel yourself. Even just for a kernel module you'll want to be able to compile the latest kernel and develop against that, otherwise you won't be able to get the module accepted in to mainline.

An alternative if the module is not to be released is to develop against a particular kernel version. In this instance then the choice of distribution should be chosen based on the target for the module - not the development environment.

So pick a distribution based on what you like: 1) Desktops - (GNOME, KDE, other) 2) Ease of use - (Ubuntu, Fedora, etc vs Arch, Gentoo) 3) Cutting edge vs Stable (Arch, Fedora vs Ubuntu vs Debian, Red Hat, CentOS)

Then head off to kernelbewbies to learn a bit about getting started with kernel programming (where to get the source, how to compile it). Then read Greg Kroah-Hartman's excellent book on linux device drivers. The interfaces will have changed (it's written about version 2.6 of the kernel and version 3.6 is currently being worked on). It can be found online here

You'll also want to learn how to use git. And more importantly how to use git to generate a patch and email it without messing it up! I don't have a website for this but a bit of googling will help.

dave
  • 4,812
  • 4
  • 25
  • 38
  • 1
    Thats not exactly true, according to here: http://ubuntuhandbook.org/index.php/2018/01/install-linux-kernel-4-15-in-ubuntu-linux-mint/ Ubuntu doesnt support mainline kernel, meaning you cant just got to Linus's github, fork the kernel, compile and run it on ubuntu, you need a special distribution so I dont think ubuntu is so good for kernel development you want to contribute back to the mainline – tomer.z Mar 06 '18 at 19:48
  • Agreed with tomer.z above. Most distributions add their own patches to cater for their end users' need. Using ubuntu as an example, one can go to the https://packages.ubuntu.com/search?keywords=linux-source to get the linux kernel source. Make sure to download the version you are using. – g5thomas Oct 06 '22 at 20:34