Page 1 of 1

Compiling your own/custom/latest Linux kernel made easy :)

Posted: 28 Aug 2014, 09:29
by bdheeman
Hello,

For compiling your own/custom/latest Linux kernel, I have created a few SlackBuild scripts, which must be run in the following sequence:

1) http://ebba.ddns.net/pub/Linux/SlackBui ... nel.tar.xz
2) http://ebba.ddns.net/pub/Linux/SlackBui ... ers.tar.xz
3) http://ebba.ddns.net/pub/Linux/SlackBui ... rce.tar.xz

Please note, that you'll need ample (3-4 Gib) disk space on a mounted partition, if your changes are being saved only to memory. Better mount the partition say at /mnt/sda3 or substitute sda3 with the partition you want to use and execute a few commands as root/su:

Code: Select all

# mkdir -p /mnt/sda3
# mount /dev/sda3 /mnt/sda3
# mkdir -p /mnt/sda3/usr/src/{tmp,SlackBuilds,Packages}
# OUTPUT=/mnt/sda3/usr/src/Packages; export OUTPUT
# SRCDIR=/mnt/sda3/usr/src; export SRCDIR
# TMP=/mnt/sda3/usr/src/tmp; export TMP
Extract the above said SlackBuild scripts into $SRCDIR/SlackBuilds.
Activate 05-devel.xzm; which can be downloaded from http://ftp.nluug.nl/os/Linux/distr/port ... t/modules/
Get git package using usm and either convert and activate git-<version>*.t[gx]z or install it.

Now chdir into $SRCDIR/SlackBuilds/kernel and run:

Code: Select all

$ ./kernel.SlackBuild
Grab a few cans/bottles of beer or whatever you like to pass time, since the above said build will take an hour or so; depending on processing power of your machine.

Build kernel-headers and then kernel-source in a similar manner. you will get 3 *.txz packages in your $OUTPUT directory; which we also need convert into Porteus modules using txz2xzm script.

Finally, we'll need to move the new kernel module onto an ISO image; which is quite easy for Porteus users, as follows:

Code: Select all

# cp -a /mnt/live/mnt/isoloop /mnt/sda3/porteus
# cp $TMP/kernel-packege/boot/vmlinuz /mnt/sda3/porteus/boot/syslinux
# cp $OUTPUT/kernel-<version>*.xzm /mnt/sda3/porteus/porteus/000-kernel.xzm
# cd /mnt/sda3/porteus/porteus
# ./make_iso.sh
# cd ../..
Now, you may either boot off of the resulting ISO image using grub2 or need to fix this ISO image using isohybrid command from syslinux package; which again can either be installed or downloaded using usm tool so that you may copy the hybrid ISO image on USB Stick, Pen-drive or SDCard for booting. You may copy this hybrid ISO image using cat or dd command; Be warned, you'll lose everything from the target USB Stick, Pen-drive or SDCard. try booting off of the target media.

If everything worked as expected, we can move onto integrating other kernel modules into 05-devel.xzm, as follows:
(Hope you still have copy of /mnt/sda3/porteus/<whatever> intact, and you have 00-devel.xzm in optional directory)

Code: Select all

# cd /mnt/sda3/porteus/porteus/optional
# mkdir 05-devel; xzm2dir 05-devel.xzm 05-devel
# ROOT=05-devel removepkg kernel-headers
# rm 05-devel/var/log/removed_packages/*
# rm 05-devel/var/log/removed_scripts/*
# rm -rf 05-devel/usr/src/{linux,linux-*}
# xzm2dir <path/to/>kernel-headers-3.16.1*.xzm 05-devel
# xzm2dir <path/to/>kernel-source-3.16.1*.xzm 05-devel
# dir2xzm 05-devel 05-devel.xzm
# rm -rf 05-devel
# cd ..
# ./make_iso.sh
# cd ../..
# isohybrid porteus*.iso
And you've done it! Try/use this new ISO image ;)

BTW, our current initrd.xz in boot/syslinux does not have any kernel modules; hence we need not update the same. Anyway, in case the need arises to update and, or rebuild the initrd.xz as well, I better leave it as an exercise for you ;)

EDIT: Updated links to new site/location ;-)

Re: Compiling your own/custom/latest Linux kernel made easy

Posted: 28 Aug 2014, 14:53
by brokenman
Excellent contribution.

Typo in first codeblock: OUTOUT --> OUTPUT

Also perhaps bear is a typo (but who knows)

Re: Compiling your own/custom/latest Linux kernel made easy

Posted: 28 Aug 2014, 15:15
by bdheeman
brokenman wrote:Excellent contribution.

Typo in first codeblock: OUTOUT --> OUTPUT

Also perhaps bear is a typo (but who knows)
Thanks for the encouragement :)
Fixed, both were typos, indeed; yes, that's beer and I like Haywards 5000 :Yahoo!:

Re: Compiling your own/custom/latest Linux kernel made easy

Posted: 28 Aug 2014, 17:19
by brokenman
Haywards 5000.

Alcohol content: < 7.5% by volume :shock:
Serving temperature: 7 - 9 °C :crazy:

This is a recipe for getting very drunk, very quick. :beer:

I will do some testing with the scripts this weekend.

Re: Compiling your own/custom/latest Linux kernel made easy

Posted: 13 Mar 2015, 00:52
by yldouright
I'm late to this party but have two questions before I try to custom compile a kernel. The processor is an old Celeron Coppermine 8.5x100. The GPU is AGP, nVidia GF3_ ti500. What flags should I use and how long should it take? The system is unusable stock 32 bit, 640MB RAM.