The default kernel which comes with Trisquel is a generic kernel which aims to run on the maximum number of hardware configurations. When you build your own, you can optimize it for your hardware and leave out all the drivers and features you don't have use for. It's also educational to take a peek into the inner workings of GNU Linux-libre.

Make a directory inside your home directory for compiling the kernel:

mkdir ~/kernel_compiling/

uname -r

To see what kernel you're now on, typeAcquire the source code for the new kernel at http://www.fsfla.org/ikiwiki/selibre/linux-libre/ and save it to the kernel_compiling folder

Install packages needed for the job:

sudo apt-get install kernel-package ncurses-dev bzip2 module-init-tools initramfs-tools procps fakeroot build-essential lzop unp bc

If you plan on using the graphical configuration tools, gconfig or xconfig, you'll need additional packages, respectively libgtk2.0-dev libglib2.0-dev libglade2-dev for gconfig or libqt3-mt-dev for xconfig. There might be other dependencies too and if they're not satisfied you'll be notified once you try to invoke the graphical configurator.

Goto the kernel_compiling directory:

cd ~/kernel_compiling

unp linux-libre-3.18.8-gnu.tar.xz

cd linux-3.18.8

Extract the new kernel archive, e.g.Goto the new kernel directory:Now you may apply any patches you wish.

Now comes the configuration step. This requires a lot of work on your part and will take a long time. There are many interesting ways to automatically select some of the options, you'll want to read the README file.

less README

The localmodconfig is quite handy, it still probably needs additions and subtractions.

Perhaps start with copying the config of the current kernel you're running.

make oldconfig

make config

make menuconfig

make gconfig

make xconfig

And then pick one of the interactive configuration tools(text based, linear)(text based, ncurses interface)(graphical GTK based) (GTK=gnome toolkit)(graphical QT based) (QT=toolkit used in KDE)

I think menuconfig probably is the fastest, gconfig prettiest and xconfig has by far the best search function.

Y means integrated into the kernel and (theoretically) always active

M means built as a module and activated if required

N means not included in any form

You can get info about your processor with

cat /proc/cpuinfo

lspci

lsusb

To get info about the rest of your hardware, runandStart with changing only the obvious things, the ones you're 300% sure of. You will repeat this process many times and will get to know the more esoteric ones... If this is your first time, don't be too bold! Once you're done, save changes and exit.

Clean the slate for kernel compiling

make-kpkg clean

grep -c '^processor' /proc/cpuinfo

export CONCURRENCY_LEVEL=2

You can get the current number of CPUs using the commandIf you have a multiprocessor machine, you'll want to make all processors work, do e.g.Documentation suggests using "a (small) integer".

Perform the actual compile, this will take anywhere from 10 minutes to 5 hours depending on your hardware and configuration choices (the more you selected, the longer it will take). Your presence is not required. You need to include kernel_headers if you later want to compile some other modules against your kernel.

make-kpkg --rootcmd fakeroot --initrd kernel_image kernel_headers

It then will give you all kind of chatter, warnings and notices during, it's quite normal. Only errors are serious, as in the process will halt. If you get an error about missing zlib.h, you need to install the zlib1g-dev package. If you get any other error, you probably need to install a related -dev package as a rule of thumb.

Once it's done through with no errors, goto the lower directory where the .deb we just created is

cd ..

sudo nano /etc/initramfs-tools/initramfs.conf

sudo dpkg -i *.deb

If you didn't select kernel support for gzip type of initrd compression then you need to edit the COMPRESS parameter of initramfs.conf to match your selection. Gzip will be used for compressing the initrd unless you specify something else in initramfs.conf. If your kernel doesn't support the compression used to make the initrd, you'll get a kernel panic at reboot (indicated by hang + flashing caps lock).Install the .deb package(s)Then it's the moment of truth, the smoke test! It's a good idea to have a live CD or live USB at hand now. Reboot and hold shift to show grub menu and select from the list the new kernel.

If it boots, nice, you made it, congratulations!

Checklist

Network (Wireless and Ethernet)

Audio

USB Sticks

CD/DVD Drives

Any queer peripherals

If not, reboot and select another kernel from the menu. Back to the drawing board...

You'll want to polish the kernel more, go back to the directory you extracted the source into. If everything worked out pretty nicely, make a backup of your .config. If it failed spectacularly, you might want to load a working .config and start working from it again.

Then do some more configuring, and cleanup, recompile... repeat until! :)

Hints and tips:

Check out the time command to clock your compiles to see how long it takes.

You might want to nice your compile, so you can use your computer while it is compiling.

Try patching your kernel with something, for example, http://tuxonice.net/

I use xxdiff to compare different .config files.

There's some good info available at http://kernelnewbies.org/FAQ

If you have questions or comments, please make a new thread in the forum.