What’s the geekiest way to release an album? How about as a Linux kernel module?
That’s exactly what a small band called Netcat did with their latest album, Cycles Per Instruction. Here’s how to get it.
If this sound complex, don’t panic: while certainly quirky, it’s not hard to set up. All it takes is a well-written list of instructions, and you too can be listening to the album via a module for the Linux kernel. Here’s what you need to do, assuming you’re using Ubuntu.
This is not the only way to gain access to the music. The album is also on BandCamp, for streaming. To actually download the music, you’ll need to buy the songs. Using this kernel module method is not a way of avoiding paying for the songs. The songs as they exist for the kernel module are not typical files that can be played by a media player.
Since we do need to compile a kernel module, we’ll need to make sure that our build environment is ready to go. To install all the necessary dependencies on Ubuntu, run the command
sudo apt-get install build-essential vorbis-tools git linux-headers-$(uname -r).
This will install the compile tools, the kernel headers needed to make kernel modules, the audio playback tools that work with the kernel module we’re making, and the git utility, which is used for development version control, which we’ll use the retrieve the code.
Next, we’ll need to “checkout” (which means to retrieve) the code for the album. We can do this using the command
git clone https://github.com/usrbinnc/netcat-cpi-kernel-module.git.
This will make a folder in your home folder named netcat-cpi-kernel-module. Since it’s downloading 6 songs (that are just shy of an hour long total) it may take some time — this is normal.
Once it completes downloading, we’ll want to go into that folder. We can do so with the command
Now we need to compile the kernel module. This can be done very easily with the command make. Depending on your system’s hardware, this may not take very long. However, do note that compiling this kernel module does require a bit over 1GB in available RAM to complete. The developers mentioned this in their README file, and I can confirm that I saw the same spike while I was compiling.
If you’ve ever compiled software before, you may expect a
sudo make install command to follow. For some reason, that’s not necessary here. Once compilation has completed, congratulations! The hard part is now done.
Now that you’ve installed the module, you need to load it. You can do so with the command
sudo insmod netcat.ko. This should start the kernel module. To check, run the command
dmesg and look for something similar to this near the bottom:
[ 2606.528153] [netcat]: netcat - Cycles Per Instruction - Kernel Module Edition - 2014
[ 2606.528153] [netcat]: netcat is Brandon Lucia, Andrew Olmstead, and David Balatero
[ 2606.528153] [netcat]: 'ogg123 - < /dev/netcat' to play.
To actually play the music, you have one last command:
ogg123 - < /dev/netcat. This is the audio tool that can actually decode the messages that the netcat kernel module is sending out, and it should be automatically sent to your current audio device (speakers, headphones, etc). You can also check whether a song is playing by issuing the
dmesg command again, but check out the miscellaneous notes below first.
You’ll notice that you can no longer type any more terminal commands into your current terminal window – this happens so long as the ogg123 utility is busy. To end playback, you can hit Ctrl + C on your keyboard, or simply close the terminal window which kills all processes bound to it (meaning ogg123).
If you want to enter in some commands while retaining music playback, just open up a new terminal tab or window. You can then use this new tab or window to check out which song is currently playing. This can be done if you run the command dmesg again and check near the bottom of the output.
Does this kernel module do anything useful for your Linux system? Not really. But it’s cool, and it teaches you some useful Linux commands along the way. And, in all honesty, it’s really not that hard. So don’t be afraid to try it out!
What’s the geekiest thing you’ve seen someone do? Are there other cool Linux goodies (possibly similar to this) that come to mind? Let us know in the comments!