Skip to content

Instantly share code, notes, and snippets.

@retpolanne
Last active August 4, 2021 19:52
Show Gist options
  • Save retpolanne/c740247b2431f2f4cfde35d2748de073 to your computer and use it in GitHub Desktop.
Save retpolanne/c740247b2431f2f4cfde35d2748de073 to your computer and use it in GitHub Desktop.
Notes from a newbie wannabe kernel developer

Linux Dev Notes

Notes from a newbie wannabe kernel developer.

First things first

I'm running Ubuntu on my Mac (working pretty well btw). I separated 10GBs for / and ~100GB for /home and I do my work on /home.

Configuring GRUB

I also changed some things on my /etc/default/grub so I can change the kernel on boot if I need to (really important, if the new kernel doesn't boot, you might have a hard time switching to the old one if grub's splash screen doesn't show up)

# I changed it to 10s, my default was 0
GRUB_TIMEOUT=10
# Fix grub menu not showing even with timeout configured
GRUB_TIMEOUT_STYLE=menu
GRUB_TERMINAL=console
# Linux Foundation Training - Enable printing early boot messages to vga using the earlyprink=vga kernel boot option:
GRUB_CMDLINE_LINUX="earlyprink=vga"

After changing it, run sudo update-grub.

Clean up kernels

Little script for that, based on [1].

# Change the version accordingly
export VERSION=5.8.0-rc5+
rm /boot/vmlinuz-$VERSION
rm /boot/initrd.img-$VERSION
rm /boot/System.map-$VERSION
rm /boot/config-$VERSION
rm -rf /lib/modules/$VERSION/
rm /var/lib/initramfs-tools/$VERSION

update-grub

Install needed packages

sudo apt-get install build-essential vim git cscope libncurses-dev libssl-dev bison flex git-email

What to clone?

I got really confused about which tree should I clone: gregkh's staging, linux_stable, linux_mainline or linux_next?

On [2], linux_mainline is used, then let's use it.

# From [3]
git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git linux_mainline

Cloning is really slow, and resolving deltas can be really CPU intensive. I wish git.kernel.org was faster! More on that @ [4]

References

[1] https://askubuntu.com/questions/594443/how-can-i-remove-compiled-kernel

[2] https://trainingportal.linuxfoundation.org/learn/course/a-beginners-guide-to-linux-kernel-development-lfd103/writing-your-first-kernel-patch/writing-your-first-kernel-patch?page=3

[3] https://trainingportal.linuxfoundation.org/learn/course/a-beginners-guide-to-linux-kernel-development-lfd103/exploring-linux-kernel-sources/exploring-linux-kernel-sources?page=2

[4] https://lwn.net/Articles/216948/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment