[HOWTO] - Compile and use custom Porteus kernel

Post tutorials, HOWTO's and other useful resources here.
Post Reply
User avatar
fanthom
Site Admin
Site Admin
Posts: 4613
Joined: 28 Dec 2010, 02:42
Distribution: Porteus Kiosk
Location: Poland, currently - Cork, IE
Contact:

[HOWTO] - Compile and use custom Porteus kernel

Post#1 by fanthom » 28 Dec 2010, 14:22

HOWTO moved to the docs section of the main site:
http://www.porteus.org/component/conten ... ernel.html
Please add [Solved] to your thread title if the solution was found.

ndiamond
White ninja
White ninja
Posts: 5
Joined: 28 Dec 2011, 06:42
Location: Tokyo

Re: [HOWTO] - Compile and use custom Porteus kernel

Post#2 by ndiamond » 12 Dec 2012, 06:35

That link gives me an HTTP 500 error.

Please, are there current instructions on how to build a custom kernel for Porteus 1.2?

User avatar
brokenman
Site Admin
Site Admin
Posts: 5553
Joined: 27 Dec 2010, 03:50
Distribution: Porteus v3.2rcX all desktops
Location: Brazil
Contact:

Re: [HOWTO] - Compile and use custom Porteus kernel

Post#3 by brokenman » 12 Dec 2012, 11:43

How do i become super user?
Wear your underpants on the outside and put on a cape.

ndiamond
White ninja
White ninja
Posts: 5
Joined: 28 Dec 2011, 06:42
Location: Tokyo

Re: [HOWTO] - Compile and use custom Porteus kernel

Post#4 by ndiamond » 13 Dec 2012, 01:34

It looks to me like the link is the same, but it's working now (no HTTP error 500 today). Thank you.

Meanwhile I also found this:
viewtopic.php?f=53&t=1553
"[Solved]How to build the kernel 3.4.4(Portues v1.20)?"
I wonder whether to add "Unsolved" to a "Solved" thread. So I'll ask here first.

I downloaded two files
http://www.kernel.org/pub/linux/kernel/ ... .4.tar.bz2
http://dl.porteus.org/i486/current/pack ... 6-1ftm.xzm

While running Porteus 1.2, I expanded those, found the patches inside the crippled sources and copied the patches to the appropriate directories.

I tried to patch aufs. The patch program patched a bunch of files and then started giving errors. The patch program didn't find some files, so I just used the mouse to copy and paste part of the pathname, and then it worked. This is weird. The patch program warned that some files would be created, but the files already existed, so the patch program asked whether to overwrite? But overwriting might lose contents that would be preserved by an ordinary patch. Is the aufs patch really meant for a different kernel version?

I didn't try to patch BFS yet because the aufs patch was too weird.

Does it matter which order I do these in, BFS patch and then aufs, or vice versa?

User avatar
fanthom
Site Admin
Site Admin
Posts: 4613
Joined: 28 Dec 2010, 02:42
Distribution: Porteus Kiosk
Location: Poland, currently - Cork, IE
Contact:

Re: [HOWTO] - Compile and use custom Porteus kernel

Post#5 by fanthom » 13 Dec 2012, 02:06

@ndiamond
you do not need crippled-sources to compile new kernel. crippled-sources is a stripped down version of kernel compiled by me for porteus-1.2.

please follow kernel compilation HOWTO "line by line" and you should not have any problems.
Please add [Solved] to your thread title if the solution was found.

User avatar
Slaxmax
Contributor
Contributor
Posts: 403
Joined: 03 Jan 2013, 09:51
Distribution: KDE4
Location: Campinas Brazil https://goo.gl/yrxwKi

Re: [HOWTO] - Compile and use custom Porteus kernel

Post#6 by Slaxmax » 26 Sep 2013, 16:36

I tried this procedure
http://www.porteus.org/component/conten ... ernel.html

But
...Navigate to "File systems" menu and make sure that FUSE will be compiled in (*). Then go to -> "Miscellaneous filesystems". Aufs and Squashfs must also be compiled in (*), as well as xz compression for Squashfs (*)

in menuconfig "Miscellaneous filesystems" does not show Aufs, only Squashfs.
Terminates the entire procedure without errors. Reboot shows Aufs error.
“DNA is like a computer program but far, far more advanced than any software ever created.”
― Bill Gates, The Road Ahead

User avatar
fanthom
Site Admin
Site Admin
Posts: 4613
Joined: 28 Dec 2010, 02:42
Distribution: Porteus Kiosk
Location: Poland, currently - Cork, IE
Contact:

Re: [HOWTO] - Compile and use custom Porteus kernel

Post#7 by fanthom » 26 Sep 2013, 20:46

hello Slaxmax,
in menuconfig "Miscellaneous filesystems" does not show Aufs, only Squashfs.
looks like aufs patch was not applied cleanly on your kernel sources. which kernel version are you trying to compile?
Please add [Solved] to your thread title if the solution was found.

User avatar
Slaxmax
Contributor
Contributor
Posts: 403
Joined: 03 Jan 2013, 09:51
Distribution: KDE4
Location: Campinas Brazil https://goo.gl/yrxwKi

Re: [HOWTO] - Compile and use custom Porteus kernel

Post#8 by Slaxmax » 26 Sep 2013, 21:16

I tried compile kernel 3.7.8 running Porteus 2.1 i486

But exactly now I succeeded in compiling. I used porteus 2.0 i486 that has the same kernel 3.7.8. 8)

Thanks
“DNA is like a computer program but far, far more advanced than any software ever created.”
― Bill Gates, The Road Ahead

KnallKopf
Samurai
Samurai
Posts: 134
Joined: 18 Sep 2012, 20:56
Distribution: Porteus 64bit KDE4
Location: Absurdistan

Re: [HOWTO] - Compile and use custom Porteus kernel

Post#9 by KnallKopf » 11 Dec 2014, 00:03

Nice tutorial but how can i make the crippled-sources ?
How is the right way to strip the source down ?

User avatar
fanthom
Site Admin
Site Admin
Posts: 4613
Joined: 28 Dec 2010, 02:42
Distribution: Porteus Kiosk
Location: Poland, currently - Cork, IE
Contact:

Re: [HOWTO] - Compile and use custom Porteus kernel

Post#10 by fanthom » 11 Dec 2014, 03:51

please run this script inside the folder where kernel was compiled (maybe do a backup first so it wont become crippled):

Code: Select all

#!/bin/bash

dest=`pwd`
cd $dest

echo "do you want to create crippled sources module? Answer y/n"
read ans
if [ "$ans" = "y" ]; then
name=`echo $dest | rev | cut -d/ -f1 | rev`
mkdir Porteus-patches && chmod -x *.patch && mv *.patch Porteus-patches
cp .config Porteus-patches/kernel.config
rm .config.old 2>/dev/null
mv System.map ../
make clean
mv ../System.map .
make prepare
make scripts
# remove a lot of stuff
rm -Rf Documentation drivers fs net sound firmware
ls -1d arch/* | grep -v x86 | xargs rm -Rf
ls -1d include/* | grep asm- | grep -v x86 | grep -v generic | xargs rm -Rf
cp -a include/generated/* include/linux
pushd include/linux && ln -sf uapi/linux/version.h version.h && popd
mkdir -p new/usr/src/$name
mv * new/usr/src/$name 2>/dev/null
mv .* new/usr/src/$name 2>/dev/null
cd new/usr/src
ln -s $name linux
cd ../../../
rm -f new/usr/src/$name/p_devel
mksquashfs new crippled_sources.xzm -b 256K -Xbcj x86
rm -r new
echo "all jobs done"
fi
Please add [Solved] to your thread title if the solution was found.

KnallKopf
Samurai
Samurai
Posts: 134
Joined: 18 Sep 2012, 20:56
Distribution: Porteus 64bit KDE4
Location: Absurdistan

Re: [HOWTO] - Compile and use custom Porteus kernel

Post#11 by KnallKopf » 11 Dec 2014, 22:31

Thanks. I will try it in the next weeks.

KnallKopf
Samurai
Samurai
Posts: 134
Joined: 18 Sep 2012, 20:56
Distribution: Porteus 64bit KDE4
Location: Absurdistan

Re: [HOWTO] - Compile and use custom Porteus kernel

Post#12 by KnallKopf » 14 Jan 2015, 01:30

I have not tested the pxeinitrd but when one of the modules not exist: "dca mii libphy sungem_phy ssb uio crc-ccitt" the code copy all modules.
I used this:

Code: Select all

#!/bin/sh

cd `pwd`
mkdir pxe
cd pxe
cp -a --parents /lib/modules/`uname -r`/kernel/drivers/net/ethernet .
for x in dca mii libphy sungem_phy ssb uio crc-ccitt; do
  pth="/lib/modules/`uname -r`/$(grep $x.ko: /lib/modules/`uname -r`/modules.dep | cut -d: -f1)"
  test -n "$pth" && cp -a --parents $pth .
done
depmod -b .
find | cpio -H newc -o | xz --check=crc32 --x86 --lzma2 > ../../initrdpxe.xz
cd ..
rm -r pxe
mv ../initrdpxe.xz .
mv /root/initrd.xz /mnt/sdb1/boot/syslinux/pxelinux.cfg/initrdpxe.xz

KnallKopf
Samurai
Samurai
Posts: 134
Joined: 18 Sep 2012, 20:56
Distribution: Porteus 64bit KDE4
Location: Absurdistan

Re: [HOWTO] - Compile and use custom Porteus kernel

Post#13 by KnallKopf » 14 Jan 2015, 01:34

Here a supplement if you install 2 kernels on the same LiveCD.
For example if you would to make a small change on the same Kernel version (for this example 3.17.4).

changing the localversion (for default the localversion are "-porteus")
You can change them to for example "-custom1" by using
CONFIG_LOCALVERSION=-custom1 insteat of CONFIG_LOCALVERSION=-porteus

Code: Select all

# cd into kernel source dir
LOCALV=-custom1
sed s/"CONFIG_LOCALVERSION=\".*\""/"CONFIG_LOCALVERSION=\"$LOCALV\""/ -i ./.config
that causes that 'uname -r' prints 3.17.4-custom1
and the modules are in /lib/modules/3.17.4-custom1

for 000-kernel module i use this:

Code: Select all

LOCALV=-custom1
cp -r /mnt/live/memory/images/000-kernel.xzm/ /root/000-kernel-$LOCALV
rm -r /root/000-kernel-$LOCALV/lib/modules/*
rm -r /root/000-kernel-$LOCALV/lib/firmware/*

make INSTALL_MOD_PATH=/root/000-kernel-$LOCALV KERNELRELEASE=3.17.4-custom1 modules_install
make INSTALL_MOD_PATH=/root/000-kernel-$LOCALV firmware_install

dir2xzm /root/000-kernel-$LOCALV /mnt/sdb1/porteus/base/000-kernel-$LOCALV.xzm
The name of 000-kernel should normally not changed because the name will used by initrd.
For this reason the name must change in initrd

Code: Select all

# provided the right intrd.xz is in /mnt/sdb1/boot/syslinux/intrd.xz
LOCALV=-custom1
mkdir ./initrd-$LOCALV
cd ./initrd-$LOCALV
xz -d < /mnt/sdb1/boot/syslinux/intrd.xz | cpio -i
### changes in initrd
sed s/"000-kernel"/"000-kernel-$LOCALV"/g -i ./linuxrc
sed s/"000-kernel"/"000-kernel-$LOCALV"/g -i ./cleanup
mv ./opt/000-kernel ./opt/000-kernel-$LOCALV
### changes end
find | cpio -H newc -o | xz --check=crc32 --x86 --lzma2 > /mnt/sdb1/boot/syslinux/intrd-$LOCALV.xz"
and of course the kernel should change:

Code: Select all

cp arch/x86/boot/bzImage /mnt/sdb1/boot/syslinux/vmlinuz-1custom
change the /mnt/sdb1/boot/syslinux/porteus.cfg
by adding for the
old:

Code: Select all

KERNEL vmlinuz
APPEND initrd=initrd.xz noload=000-kernel-1custom.xzm ... 
new:

Code: Select all

KERNEL vmlinuz-1custom
APPEND initrd=initrd-1custom.xz noload=000-kernel.xzm ... 
but no idea whether i save me the renaming in initrd
when i use the 000-kernel and do this: dir2xzm /root/000-kernel /mnt/sdb1/porteus/base/000-kernel-$LOCALV.xzm
instead of: dir2xzm /root/000-kernel-$LOCALV /mnt/sdb1/porteus/base/000-kernel-$LOCALV.xzm

KnallKopf
Samurai
Samurai
Posts: 134
Joined: 18 Sep 2012, 20:56
Distribution: Porteus 64bit KDE4
Location: Absurdistan

Re: [HOWTO] - Compile and use custom Porteus kernel

Post#14 by KnallKopf » 14 Jan 2015, 01:34

and then the next question how was the graphic driver build especially the nvidia driver.

User avatar
fanthom
Site Admin
Site Admin
Posts: 4613
Joined: 28 Dec 2010, 02:42
Distribution: Porteus Kiosk
Location: Poland, currently - Cork, IE
Contact:

Re: [HOWTO] - Compile and use custom Porteus kernel

Post#15 by fanthom » 14 Jan 2015, 10:02

GPU drivers is a story for another topic. you can have a look on this thread:
viewtopic.php?f=39&t=33

i have stopped updating the script as new driver release means new patches and different procedures. i wont publish 'ready to go script' as it would be outdated quickly.
Please add [Solved] to your thread title if the solution was found.

Post Reply