User:Btodoroff/KernelNewbiesGuide

From ArchWiki

Newbie Kernel Hacker's Guide to Arch Linux

So maybe, like me, you've recently gotten interested in how the Linux kernel works and how you can hack on it. You might have stumbled onto Kernel Newbies or The Eudyptula Challenge (if not take a moment and stumble over there now as you'll find a treasure trove of guidance for starting out). You may have also come to the realization that keeping many of the popular distributions up-to-date and functioning with the latest kernel is not how you want to spend your free time. Arch Linux makes a great platform for kernel hacking - you get the ability to stay up on the latest kernel, you can have anything you want but don't get bogged down with alot of extra features you don't need, and you will immediately start learning a great deal about how Linux really works just by installing Arch Linux. This page will try to guide you to the resources you'll need to get set up specifically for newbie kernel hacking and hopefully save you some frustration and restarts. We'll assume you are familiar with using Linux from the command line, but new to Arch Linux and kernel development.

Choosing a platform

For kernel hacking you've basically got a few options: real x86-64 based computer, x86 virtual machine, or a single board computer like Raspberry Pi, BeagleBone, etc.

  • Single board computers involve a whole host of difficulties in setting up and maintaining a build environment and offer far less documentation or support for kernel hacking - this guide won't cover those platforms as they aren't a great platform for kernel newbies.
  • Virtual machines will work just fine 90% of the time, but you will need to invest extra Google-fu to figure out kernel extensions for virtualization during setup and when recompiling kernels but is very do-able. Hyper-V, VMWare, and Virtual Box all work, but I had the least issues with Virtual Box. Currently this guide doesn't yet address those issues.
  • Real x86 based computers are the gold standard for kernel development and you don't need a very powerful machine for this. Any x86_64-compatible machine with a minimum of 2GB RAM, 32GB of hard drive, and an internet connection will do great, so scrounge up an old PC and have fun. You can also carve out a bit of disk space and dual boot your existing machine just fine - however you will be frustrated at times when your hacking has broken your kernel and have to keep booting that machine back and forth between Arch and your main OS to search the net for help. The x86-64 platform is what the vast majority of kernel documentation and work is targeted towards, so you'll have all the help and documentation you need.

Installing Arch Linux

You don't need or want to do anything particularly special here, so head over to the official [[w:Installation_guide|Installation Guide] and follow along there. Once that is done also read through the post install recommendations on System Administration, Package Management, and Booting.

  • DHCP


vim is Your Friend

Kernel hacking means lots of time editing the text of Makefiles, test scripts, and config files. There are many great text editors for Linux and all of them will work great, but vim is a friend you need for two main reasons: it's tiny with almost no dependencies so it'll always run if you can get a shell prompt; Vim's grandfather vi is the editor you'll almost always get when things have gone horribly wrong and your system has refused to boot or is throwing another tantrum. So install vim and start using it as your go to for small text tasks like editing config files, email and such - when your cursing and trying to recover you're system isn't the time to be trying to figure out those ':' commands and mode keybindings.

Kernel Friendly Email

The only way the huge kernel development community thrives is through a fairly strict set of conventions and rules for everything from coding style to email. To even enter into this world you'll need to get yourself set up with the ability to send good old text-only email in very specific formats and almost none of the web based email interfaces will give you the control to do this reliably. I recently got this well deserved gem from a certain little black and white script when I made the mistake of simply replying to a text only email from the GMail web interface which decided it would be a grand idea to take my nice text-only email and re-encode it as an html attachment beside the text-only version....

Re: [##########] Task XX of the Eudyptula Challenge
Really?  You send me HTML email after being told explicitly not to?

What type of script do you think I am?

Please fix your email client and try again.


Since you probably don't want to setup your own email service right now I'll suggest you get started with hooking up a Gmail account (either your existing or a new one) to your new Arch Linux system.

esmtp

mutt

Keep X Windows Simple

For kernel development, you want to keep your environment productive but simple - you'll be mucking about in the guts of the system so you want a simple system that's less likely to break as you hack.

  • xorg
  • lightdm
  • gtk greeter

Simple Remote Access

SSH

  • passwords vs certificates
  • port forwarding
  • IPv6

tigervnc

  • lightdm integration
  • tunneling for VNC