Monthly Archives: January 2014

Fridie Spidie: Put Your Hands in the Air

Hands Up Jumping Spider

Photo by karthi keyan.

Advertisements

Handy Kernel Resources

These free resources have been a great help to me in my kernel studies.

First is the Linux Cross Reference at Free Electrons. The Identifier Search provides a quick and easy way to grep your way through the sources, because the identifiers in the code are clickable. It’s great for drilling down to the roots of a macro.

Then there’s Mel Gorman’s book, “Understanding the Linux Virtual Memory Manager“. He warned me that it was outdated, and some of it is; but some things, such as the layout of page tables, don’t change very often. It has diagrams. I like diagrams.

Another great book is Linux Device Drivers, by Jonathan Corbet, Alessandro Rubini, and Greg Kroah-Hartman. It explains how the kernel deals with modules, and how they are constructed.

Prefer to watch and listen? Youtube has you covered.

Final Call for She’s Geeky

The She’s Geeky Bay Area 2014 Un-conference starts tomorrow, and only the late registration tickets are left–but don’t worry, that 25% off redemption code from Codechix is still good! It’s CCHIX25, so go grab your tix!

Also, don’t miss the exciting Codechix track on Saturday! Codechix member Melody Bliss has a fascinating session in store for us. She’ll be presenting “A Brief Introduction to OpenSCAD.” OpenSCAD is a programmatic 3D modeling language, which Melody uses in relation to 3D printing. Here’s a simple model you’ll be able to code right away.
melody-scad

Also, Akkana Peck will be auctioning off one of her telescopes at the end of the day. Proceeds will help get Codechix members to PyCon. Even if you don’t bid, come for the connections and the fun!

Building a KVM Guest for Kernel Testing

Making mistakes and correcting them is part of the software development process. Trial and error come with the territory, no matter how well a developer plans and executes her code. Thus, running and testing a kernel that you’ve just hacked on yourself can be risky. Even without kernel panics, it can be a big PITR because you can’t just stop and start a kernel like you can any other program; you have to reboot the machine. This is why kernel development is often done inside a virtual machine. A guest system running inside a VM can be stopped and started much the same way as any other program, and it’s definitely a lot faster than rebooting.

My mentor advised me to use KVM because, with Linux rather than a separate hypervisor in charge, it’s much lighter and faster than other virtualization solutions. I chose to use LVM logical volumes to store the guest images, because I thought that would offer me the most flexibility in the long run, without having yet another folder full of hacking junk in my home directory. Here’s what my final setup looks like, and how you can replicate it on a full featured Linux distro (Mint and Ubuntu, in my case).

First, make sure that virtualization technology is enabled in your machine’s BIOS. Unless your machine is quite old, your processor is almost certainly built with it; to test, run egrep -c '(vmx|svm)' /proc/cpuinfo and if the output is nonzero, you’re good to go. Once you enable it, be sure to completely power down your machine–don’t just reboot–before you run lsmod | grep kvm and look for the needed modules. There should be two; one is kvm and the other, in my case, is kvm_intel.

Of course, you’re going to need to install a bunch of packages. I can’t list every one because I let Synaptic pull a bunch of them in for me and, to be honest, I fumbled around awhile before I had them all. Among the key packages and searches were qemu-kvm (but not qemu itself), qemu-system, and system-config-lvm for the logical volume manager (I selected the GUI tool and let it pull in the base packages). A suggestion from my mentor, virt-manager, turned out to be centrally important. The commands for creating and managing VMs is confusing (forms of it are currently being deprecated and replaced, for instance), and the first time I ran the tool, it suggested and fetched the qemu-system-* packages.

While you’re fetching bits, grab the OS that you want to run in the guest, if you don’t already have it. I used Ubuntu Saucy, the same OS as my main computer (the host). The installation will go a lot faster if you have it stored as an iso in your file system rather than on a disk.

If you choose to use LVM volumes for the guests (instead of creating disk image files), create them first. The version of system-config-lvm that ships with current Debian based distributions (and perhaps others) has a bug described here, and will not start if called from the menu. That link contains a workaround, which I’ve wrapped in a shell script here. Just make one logical volume for each guest, and make it big (my main one is 75G). You will partition it into drives and swap areas through the guest’s installation program.

Now it’s a simple matter of calling Virtual Machine Manager from the menu and filling in the blanks on its five screens. If you’ve created logical volumes, you’ll also need to tell Virtual Machine Manager where to find them. Click Edit->Connection Details and in the Storage tab, click the blue plus sign at the bottom left (great description of the process here). Once the guest’s installation program starts, it will be just like installing Linux anywhere else. Once the installation is done and tested, set it up for kernel hacking as described in the OPW First Patch tutorial, and you’re good to go! Happy hacking!

She’s Geeky Discount Code

She’s Geeky is only one week away! Have you registered yet? If you’ve been trying to justify it, Codechix can sweeten the deal for you with a 25% discount! It’s for Friends of Codechix–and if you’re reading this, you’re our friend!

The code is: CCHIX25

Plus on Saturday, there’s an extra treat from Codechix–we’re putting on our own “track” (informally, of course). Watch Twitter @codechix for our topics!

It’s going to be a great event this year. See you there!

Register for She’s Geeky – Bay Area 2014