You are not logged in.

#1 2007-07-03 01:42:55

mildred
Member
From: france
Registered: 2006-12-23
Posts: 43
Website

How to create a custom kernel with initrd and ARCH patches

Hi,

I like the default kernel because everything seems to work well and I think the Arch kernel includes patches I need (such as the mactel patch). But some options that i would like to be enabled are not. in fact i would like to use powertop but i can't because it needs the CONFIG_TIMER_STATS option.

What I would like is a kernel based on the arch kernel but with a different config file. Nothing more.

if i look at the solution on the Wiki, I see that I have to add all patches the standard kernel have ... Moreover there is no initrd creation. i think i will need it if I use the Arch kernel configuration.
And if i use the kernel26 PKGBUILD, I must change the package name in order to keep my current kernel. It's easy to do in the PKGBUILD but much more complicated to do it in the kernel26.install file beacuse I have to change the filenames in /boot and I do not want to replace the kernel26 files.

So do you have any ideas how to compile my custom kernel ? Is there a better solution ?

Thanks.
Mildred.

Last edited by mildred (2007-07-03 01:46:33)

Offline

#2 2007-07-03 03:59:10

kishd
Member
Registered: 2006-06-14
Posts: 401

Re: How to create a custom kernel with initrd and ARCH patches

Update abs and use the kernel26 PKGBUILD and files from /var/abs/kernels/kernel26.

Add make menuconfig to the PKGBUILD at the position indicated below. Modify as needed and save the config and the kernel will build. 

----------------------------------------------------------------------------------------------------------------------
# build the full kernel version to use in pathnames
  . ./.config
  #_kernver="2.6.21-rc7${CONFIG_LOCALVERSION}"
  _kernver="${_basekernel}${CONFIG_LOCALVERSION}"

#Add this line to the PKGBUILD here
-------->make menuconfig

  # load configuration
  yes "" | make config
  # build!
----------------------------------------------------------------------------------------------------------------------


---for there is nothing either good or bad, but only thinking makes it so....
Hamlet, W Shakespeare

Offline

#3 2007-07-03 04:39:11

mildred
Member
From: france
Registered: 2006-12-23
Posts: 43
Website

Re: How to create a custom kernel with initrd and ARCH patches

That's what I've done but I also had to change the package name in the PKGBUILD, the install file and the preset file ... Because I don't want to loose the arch kernel.
Is there a way to make those changes easier ?

Offline

#4 2007-07-03 06:59:02

kishd
Member
Registered: 2006-06-14
Posts: 401

Re: How to create a custom kernel with initrd and ARCH patches

A work around could be to rename the standard arch kernel etc in /boot and add an entry pointing to those in the grub. Then compile and install the custom kernel.


---for there is nothing either good or bad, but only thinking makes it so....
Hamlet, W Shakespeare

Offline

#5 2007-07-03 07:21:00

kano
Member
From: Michigan
Registered: 2007-05-04
Posts: 185
Website

Re: How to create a custom kernel with initrd and ARCH patches

kishd wrote:

A work around could be to rename the standard arch kernel etc in /boot and add an entry pointing to those in the grub. Then compile and install the custom kernel.

if you ever upgraded kernel26 from the repo's though, it would overwrite your custom kernel26 (i think) and leave the older, renamed kernel26 unupgraded.

the safest, and easiest imo, path is it to just change the pkgname to something like kernel26custom like suggested above.


\\ archlinux on a XPS M1530 //

Offline

#6 2007-07-03 07:37:25

kishd
Member
Registered: 2006-06-14
Posts: 401

Re: How to create a custom kernel with initrd and ARCH patches

What I did was install the custom kernel and rename it and then re-installed the standard kernel.


---for there is nothing either good or bad, but only thinking makes it so....
Hamlet, W Shakespeare

Offline

#7 2007-07-03 11:32:06

mildred
Member
From: france
Registered: 2006-12-23
Posts: 43
Website

Re: How to create a custom kernel with initrd and ARCH patches

I think it could be a good idea if the kernel26 PKGBUILD renames the filenames in other files according to $pkgname or some other variable. isn't it possible ? I don't want to make all this modifications again the next time kernel26 is updated ...

Offline

#8 2007-07-03 13:48:24

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: How to create a custom kernel with initrd and ARCH patches

It's possible I'm missing something here, but I don't understand what you're worried about. If I understand correctly, you now have a PKGBUILD and associated files for kernel26mildred (or whatever you've decided to call it). Why do you think you would have to change the files again when kernel26 is updated?

Offline

#9 2007-07-03 14:12:41

kano
Member
From: Michigan
Registered: 2007-05-04
Posts: 185
Website

Re: How to create a custom kernel with initrd and ARCH patches

tomk wrote:

It's possible I'm missing something here, but I don't understand what you're worried about. If I understand correctly, you now have a PKGBUILD and associated files for kernel26mildred (or whatever you've decided to call it). Why do you think you would have to change the files again when kernel26 is updated?

don't the patches change from version to version?

anyways, i was bored so i wrote a little script... edit the configuration variables at the top and it'll do the work for you. just put it in /var/abs/kernels or wherever you have the kernel26/ at, chmod +x scriptname, and run. smile
if you're in /var/abs/kernels you'll probably have to run as root.

from my testing, it seems to be all working (looking at resulting files and no errors so far from makepkg); but i'm still building my test kernel with it.

#!/bin/bash
# Author: kano <gt@fallendusk.org>

# Configuration #
appendname="-custom1" # Name to append to kernel package
BUILD=0    # Build package when done? No = 0; Yes = 1
#MAKEPKGOPT="" # Uncomment if you're building after you make; Add any options you want passed to makepkg (can be nothing)

# Work starts here; shouldn't have to edit anything below #
mkdir kernel26${appendname}/
cp kernel26/* kernel26${appendname}/

regen_md5sum() {
    if [ ${file} != 'PKGBUILD' ]; then
        echo "Regenerating md5sum for ${file}"
        cat kernel26${appendname}/PKGBUILD \
        | sed "s/'`md5sum kernel26/${file} | awk '{ print $1 }'`'/'`md5sum kernel26${appendname}/${file} | awk '{ print $1 }'`'/;" \
        > PKGBUILD.tmp
        mv PKGBUILD.tmp kernel26${appendname}/PKGBUILD
    fi
}

for file in "PKGBUILD" "kernel26.preset" "kernel26.install"; do
    echo "Editing ${file}"

    cat kernel26/${file} | \
           sed "s/kernel26/kernel26${appendname}/g" \
    | sed "s/vmlinuz26/vmlinuz26${appendname}/g" \
    | sed "s/kconfig26/kconfig26${appendname}/g" \
    | sed "s/System.map26/System.map26${appendname}/g" \
    > kernel26${appendname}/${file}

    # Regenerate md5sum
    regen_md5sum
done

for file in "config" "config.x86_64"; do
    echo "Editing ${file}"

    cat kernel26/${file} | \
           sed "s/CONFIG_LOCALVERSION=\"-ARCH\"/CONFIG_LOCALVERSION=\"-ARCH${appendname}\"/" \
    > kernel26${appendname}/${file}

    # Regenerate md5sum
    regen_md5sum
done

mv kernel26${appendname}/mkinitcpio-kernel26.conf kernel26${appendname}/mkinitcpio-kernel26${appendname}.conf
mv kernel26${appendname}/kernel26.install kernel26${appendname}/kernel26${appendname}.install
mv kernel26${appendname}/kernel26.preset kernel26${appendname}/kernel26${appendname}.preset

# Add make menuconfig to PKGBUILD
cat kernel26${appendname}/PKGBUILD | \
sed 's/# load configuration/\n  # configure kernel before build\n  make menuconfig\n\n  # load configuration/;' \
> PKGBUILD.tmp
mv PKGBUILD.tmp kernel26${appendname}/PKGBUILD

echo "Custom kernel pkgbuild created."

# To build or to not to build?
if [ ${BUILD} -eq 1 ]; then
    cd kernel26${appendname}
    makepkg ${MAKEPKGOPT}
fi

\\ archlinux on a XPS M1530 //

Offline

#10 2007-07-03 18:32:09

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: How to create a custom kernel with initrd and ARCH patches

Yes, the patches change - but that would apply to any kernel PKGBUILD based on kernel26. My impression was that the OP, having made the necessary changes to all relevant build files for her custom kernel, thought she would have to do that again next time there was a kernel26 update:

mildred wrote:

I don't want to make all this modifications again the next time kernel26 is updated ...

If I'm wrong, feel free to ignore me. smile

Offline

#11 2007-08-06 02:29:28

mildred
Member
From: france
Registered: 2006-12-23
Posts: 43
Website

Re: How to create a custom kernel with initrd and ARCH patches

I just tested it to go from kernel 2.6.21 to 2.6.22 and it seems to works well, great thanks smile
Mildred

Offline

Board footer

Powered by FluxBB