Sunday, June 1, 2014

little steps towards Kernel Programming

I got a chance to work on a bug which is in vfs(Probably?). Brian Foster at redhat is mentoring me. I chose to document the process here.

This post is a mail sent by Brian For getting my workspace, test setup ready before I started working on the bug.

You probably want to start out just getting comfortable with compiling a
kernel. My upstream linus tree (linus' tree) comes from here:

git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git

So that's the latest upstream (all sub-trees are merged into there).
This might be ultimately something that has to go into a vfs subtree,
but we can figure that out later.

My normal workflow is relatively simple. Install rawhide (fedora latest)
to a VM:

https://fedoraproject.org/wiki/Releases/Rawhide

Grab the /boot/config-x.y.z kernel config file associated with the
current running kernel and install it to your git repo as /.config. Run
'make oldconfig' to resolve any unconfigured options. You could also run
a 'make localmodconfig LSMOD=<file>' where <file> contains the 'lsmod'
output from your VM to speed up compiles (i.e., 'lsmod > /tmp/lsmod' on
the VM, copy the file to the host). This will disable any non-running
kernel modules.

Steps to build/install the kernel:

- make -j 8
- make modules_install INSTALL_MOD_PATH=./install

The above will install the kernel modules to a local subdirectory such
that you can copy them to the VM:

- scp arch/x86/boot/bzImage root@<VM.IPboot/bzImage
- rsync -rv install/lib/modules/x.y.z root@<VM.IPlib/modules/

Create a new initramfs on the VM:

- dracut -H /boot/initramfs.img x.y.z
(x.y.z matches the subdirectory under /lib/modules)
- Edit /boot/grub2/grub.cfg to add a new boot option that points to
  /boot/bzImage and /boot/initramfs-x.y.z (whatever you named the
files). Just copy an existing entry.

... and at that point you should be able to reboot using the alternate
boot option. I wouldn't worry about anything else with regard to the bug
until you get comfortable with that.

Brian

No comments:

Post a Comment