How to compile your own kernel for Debian/Ubuntu – without paying $20 and violating GPL

Turns out there’s a company that provides expensiveish linux-next-built .debs for Ubuntu/Debian with some .config improvements – proprietary, of course. You need to pay $20 per machine or something, I haven’t even checked the website, really, who cares. It’s not clear if they’re violating GPLv2 by not providing the source because nobody seems to have asked for it yet, but something tells me they won’t just give you the sourcecode if you buy it. They are definitely violating GPLv2 by having you accept an EULA before you can use the kernel, and their way of bundling OpenZFS is specifically the way that big players avoid because it’d violate GPLv2… I feel pretty safe saying that’s a triple violation of GPLv2, and I’m not even a doctor… or whoever you need to be to diagnose GPL violations.

If you’d like to bother with asking them for source code – there’s “free trial” kernels that shut down your PC after 3 hours of runtime, you can download that kernel, then email them and request sourcecode for that kernel, they’re required by GPLv3 to provide it to you after you download the trial kernel and then message them requesting the sourcecode. I won’t bother, but you – knock yourself out! If you succeed (lol, good luck), please do post it online, you’re allowed to – I wouldn’t mind looking at their EULA check code, for one.

I’ve found an interesting comment, from a user who seems to have just created their account and only used it for this one comment under this specific post. Here it goes:

Is someone forcing you? Do you have the ability to build such a kernel and with such capabilities? Not? Then don’t bother people. A bunch of talkers can not to compiled kernel.

Thanks to assholes like you, they made their project non-public. Now are you going to compiled the kernels for us?

Not implying they’re a throwaway created by someone involved in the project who’s mad at this post or whatever. Let’s address the substance – can I compile a kernel that requires an EULA, does a hardware-fingerprinted license check and shuts down the machine after 3 hours of use? And then violate GPLv2 thrice while distributing it? Probably not – point taken.

Am I going to compile kernels for everyone? No, I certainly don’t have neither the processing power nor time, so they got me there, too.

What I can certainly do is show you how you can compile your own, latest, kernel with minimal effort – nicely .deb-packaged, no less! Only takes 7 commands and about 10 minutes of preparation + however long it’d take your machine to build a kernel (total of 40 minutes for my Ryzen 3500U laptop), and then you can just “dpkg -i” three packages and reboot.

Setup

Make a separate directory inside which you’d do all the work. It’s $HOME/kernel for me, you can just cd $HOME && mkdir kernel && cd kernel. This is needed to avoid cluttering your $HOME with .debs – you will see, just trust me, ok?

Commands

Go to kernel.org , right click on the latest “stable” kernel’s “Tarball” link and use “Copy link”. I know, this is not a command, but bear with me.

1. Wget it:

wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.12.8.tar.xz

2. Untar it:

tar xf linux-5.12.8.tar.xz

3. Cd into it:

cd linux-5.12.8/

4. Copy your current config over:

cp /boot/config-$(uname -r) .config

5. Update the config:

make oldconfig

This will present you with a slew of configuration options that got added in the time period between releases of your current kernel and the one you’re going to install. My own strategy is – answer “m” where that’s an option, answer “y” otherwise unless it’s a CONFIG_DEBUG option of some kind. Use ? and your search engine of choice liberally if you’d like to know what the options you’re adding actually stand for.

BTW, if you need to add some kernel patches – that’s an option and this is the step where you can do it.

6. Build it as .deb

nice -n10 make -j8 bindeb-pkg

Vary the nice -n (process scheduling priority) and the make -j (thread count) parameters up/down if you’d like (lower niceness for higher priority, range is from 20 to -20), these two are just what I use on my 4c8t Ryzen 3500U so that my music playing in a YouTube tab doesn’t stutter.

7. Install the .deb files

Now that you’ve finished compiling, you have three .debs to install. Provided you’re installing a 5.12.8 kernel like this example mentions, do this to install them all in one go:

sudo dpkg -i *5.12.8*.deb

Now reboot and you will have a new kernel that you will booted with when using your default grub entry, you can use ‘uname -a’ in console to check it’s really the new kernel after you’ve booted with it – and you can use the grub menu to boot with an earlier version in case booting the new kernel fails – it never does for me, but it’s an option if you need it..

2 thoughts on “How to compile your own kernel for Debian/Ubuntu – without paying $20 and violating GPL

  1. Funny Legs

    That however does not include any changes made to the config by those people.
    As far as I understood they don’t opensource their patches (correct me if I’m wrong). If there are any noteworthy patches at all.
    Your tutorial shows people how to build latest mainline kernel based on the config of the current kernel making every change between the running and latest mainline kernel optional as modules.
    That’s all fine but it really isn’t quite the same.

    Reply
    1. CRImier Post author

      >>> Your tutorial shows people how to build latest mainline kernel based on the config of the current kernel making every change between the running and latest mainline kernel optional as modules.

      Yep, you are absolutely correct! If there’s any noteworthy patches they’ve done (pressing X on that one), anyone is free to email them for those, as my second paragraph describes =) I focused on the “compiling your own kernel” part, because 1) that’s what I wanted to write about for a long time 2) this is what I had tutorial-worthy material for 3) that’s specifically what the absolutely-not-suspicious commenter talked about ;-P Not going to cover patching/schedulers/compile options/etc, but if you want to fiddle with those on Ubuntu/Debian, I’ve basically got you most of the way there.

      Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s