how to compile a kernel without creating a rpm ?

here is the situation :’(

our prof wants us to make some measurable changes in the kernel as a part of our assignment. I’m new to linux (started using linux only day b4 yest)… till now i’ve built a new kernel using cloneconfig and ended up with a rpm package (since i couldnt find any other option)… .and here’s the prob

  1. how to make changes in the kernel code?
  2. do i have to create an rpm everytime after a change? (it jus takes too long :frowning: )

the deadline is on 18.4.2011… i would really appreciate ur help.

ps: i’ve installed opensuse 11.3.

On 2011-04-14 09:36, Vidya89 wrote:
>
> here is the situation :’(
>
> our prof wants us to make some measurable_changes in the kernel as a
> part of our assignment. I’m new to linux (started using linux only day
> b4 yest)… till now i’ve built a new kernel using cloneconfig and ended
> up with a rpm package (since i couldnt find any other option)… .and
> here’s the prob

The sequence is:

cd /usr/src/linux
make cloneconfig <- just once.

make menuconfig ← apply your changes

make
make modules
make modules_install install (modifies grub)

More: read /usr/src/linux/README.SUSE

> 2. do i have to create an rpm everytime after a change? (it jus takes
> too long :frowning: )

No, but then you can only create one kernel variation.


Cheers / Saludos,

Carlos E. R.
(from 11.2 x86_64 “Emerald” at Telcontar)

thank you :slight_smile:

didnt get this part…

check my blog post

Compiling kernel in openSUSE – easy way | Beli’s blog

Hey Emil,
That looks really interesting, is going to become one of my “weekend” projects sometime…

Some quick questions about what can be expected before actually following the steps in your blog…

  • It looks like a major part of your procedure describes only enabling/disabling items from a menu – I assume those are standard “Loadable Kernel Modules” – Am I correct?
  • If the menu only lists standard LKM, is there a provision for adding other LKM what might not be a part of Kernel Dev packages?
  • For awhile now, I’ve been interested in any way to modify the “SLAB Allocator” in the kernel, it’s the configuration that plays a major part in allocating core kernel resources to various functions/services and cannot be modified except when the kernel is compiled, does your procedure support selecting SLAB, SLUB, SLAM or other?

TIA if you have answers to any of these questions,
Tony

On 2011-04-14 19:06, Vidya89 wrote:
>
> thank you :slight_smile:
>
> robin_listas;2323551 Wrote:
>>
>>
>>
>>> 2. do i have to create an rpm everytime after a change? (it jus takes
>>> too long :frowning: )
>>
>> No, but then you can only create one kernel variation.

>
> didnt get this part…

That you can only compile one kernel. If you want to try some setting, you
have to compile it again, and you again have only one kernel. However, if
you store them as rpms, you can install any of them.

Ah, I forgot: kernels can have names, it is defined somewhere in the
configuration phase. You should actually do it, or your kernel will be
named “default” and replace the default suse kernel.


Cheers / Saludos,

Carlos E. R.
(from 11.2 x86_64 “Emerald” at Telcontar)

@ Emil
thank you sooooo much :slight_smile:

@robin
haa got it :)… correct me if im wrong,
first i compile from version 1… which gives me ver 2
so now if i wanna make changes i go back to ver 1
and then make the changes in the cd usr/src/linux dir and then compile again…
but this time i dont have to change the name coz its the ver 2’s code that im changing…

and guys one question remains unsolved… the kernel code part…
from the menu i can only add/del module (again correct me if im wrong)… how do i change the kernel code itself… is it the zillions of C files in the downloaded source… if yes, is it rite to say i can change one of those C files and then compile the whole thing as given above?..

On 2011-04-15 13:36, Vidya89 wrote:
>
> @ Emil
> thank you sooooo much :slight_smile:
>
> @robin
> haa got it :)… correct me if im wrong,
> first i compile from version 1… which gives me ver 2
> so now if i wanna make changes i go back to ver 1
> and then make the changes in the cd usr/src/linux dir and then compile
> again…
> but this time i dont have to change the name coz its the ver 2’s code
> that im changing…

You have to change the name the first time, or you will overwrite the
original kernel installed, which is known to work. If your new kernel does
not boot, you are stuck.

Changing the name in menuconfig, internally, changes not only the kernel
name in /boot, but also changes the entire module tree in /lib/modules. It
can be a gigabyte of code.

> and guys one question remains unsolved… the kernel code part…
> from the menu i can only add/del module (again correct me if im
> wrong)… how do i change the kernel code itself… is it the zillions
> of C files in the downloaded source… if yes, is it rite to say i can
> change one of those C files and then compile the whole thing as given
> above?..

Yes, you have to change those files. And I can’t tell you how, never tried.


Cheers / Saludos,

Carlos E. R.
(from 11.2 x86_64 “Emerald” at Telcontar)

You are welcome. But you have seen that I haven’t been going into the depth of things on my blog. It is mostly enabling/disabling things.
But I see your questions are answered by other good people.
Just another warning: pay attention to names, and don’t start from 0 if you don’t know what are you doing.
I have compiled kernel many times that I downloaded directly from kernel.org, if you don’t know what are you doing, I advise against.
Usually, most secure way is to modify current kernel… use make cloneconfig whenever you can.

@robin n emil

thank you :)… point taken :slight_smile:

@emil
think u can gimme a list of few things which can be omitted
i did change the processor type from generic, and removed certain
device drivers which i wont need… wat are the other things tat can be omitted?

btw im done compiling n now posting from my new kernel lol! … thanks to u guys :slight_smile:
but compiling took 1hr n 50 mins…
my laptop has intel core 2 duo n a 2.5 GB ram… is this the expected time
or is there some issue with my system?

On 2011-04-15 22:36, Vidya89 wrote:
>
> @robin n emil
>
> thank you :)… point taken :slight_smile:
>
> @emil
> think u can gimme a list of few things which can be omitted
> i did change the processor type from generic, and removed certain
> device drivers which i wont need… wat are the other things tat can
> be omitted?
>
>
> btw im done compiling n now posting from my new kernel lol! … thanks
> to u guys :slight_smile:
> but compiling took 1hr n 50 mins…
> my laptop has intel core 2 duo n a 2.5 GB ram… is this the expected
> time or is there some issue with my system?

Compiling the kernel has been traditionally used as a measurement of
computer speed. Two hours seems a lot for that cpu, but the HD is also
involved a lot. I have found that compilation tasks in linux are
appreciably faster if the filesystem is reiserfs.

Mmm… I haven’t compiled a kernel in this machine, I’m curious.
…]
It is only using one core for the process, it needs something else to run
several threads.


Cheers / Saludos,

Carlos E. R.
(from 11.2 x86_64 “Emerald” at Telcontar)

On Fri, 2011-04-15 at 21:33 +0000, Carlos E. R. wrote:
> Mmm… I haven’t compiled a kernel in this machine, I’m curious.
> …]
> It is only using one core for the process, it needs something else to run
> several threads.
>
Hi
make -jN where N is the number of threads, for an rpm spec file you use;


make %{?_smp_mflags}


Cheers Malcolm °¿° (Linux Counter #276890)
SUSE Linux Enterprise Desktop 11 (x86_64) Kernel 2.6.32.29-0.3-default
up 9 days 5:46, 2 users, load average: 0.11, 0.12, 0.09
GPU GeForce 8600 GTS Silent - Driver Version: 270.41.03

On 2011-04-15 23:51, malcolmlewis wrote:
> On Fri, 2011-04-15 at 21:33 +0000, Carlos E. R. wrote:
>> Mmm… I haven’t compiled a kernel in this machine, I’m curious.
>> …]
>> It is only using one core for the process, it needs something else to run
>> several threads.
>>
> Hi
> make -jN where N is the number of threads, for an rpm spec file you use;
>


> make %{?_smp_mflags}
> 

I’ll try that when the current kernel compile finishes, thanks.


Cheers / Saludos,

Carlos E. R.
(from 11.2 x86_64 “Emerald” at Telcontar)

You can omit all that is tagged experimental, and things that you are ABSOLUTELY certain that you don’t have. However, kernel will not get bigger or slower even with everyting inside. Most things are marked as modules. That means that it will be loaded if there is a necessity for it.
One thing that is included in kernel and can be removed completely is open sound system. By disabling options will just make compile time smaller, as there are less things to compile.

What makes kernel faster and more responsive are (in order of influence):

  1. setting the processor type
  2. removing generic optimiziations
  3. removing “optimize for size” if it is set.
  4. Setting the clock to 1000hz, but newer kernels has that by default.

there were evidence, few years ago, that setting (in kernel hacks), forgot the name… stack or whatever from 8 KB to 4 KB. However, I don’t notice difference in speed because new machines are too fast to notice that.

Now, this doesnt apply for kernel compilation as kernel will reset it before build, but for other source compliations:
edit bashrc.bash (or bash.bashrc - I am in freakin windows now due to some work) in /etc

go to end of the file and add:
export CFLAGS=“-O2 -pipe -fomit-frame-pointer -march=native”
export CXXFLAGS=$CFLAGS
export MAKEOPTS=“-jX” #this X is number of cores +1. My machine I7 has 8 cores, so I use -j9

whenerver you compile from source (but not kernel), will have most optimized binary. Drawback: if you change computer, you’ll need to recompile.

On 2011-04-16 00:33, Carlos E. R. wrote:
> On 2011-04-15 23:51, malcolmlewis wrote:
> I’ll try that when the current kernel compile finishes, thanks.

Ok, normal kernel compile, one core:

real 58m6.866s
user 50m29.163s
sys 7m57.151s

make clean cloneconfig menuconfig, change name.

time make --j4

(core2 quad Q9550 2.83GHz)

real 19m25.620s
user 50m40.652s
sys 7m51.458s

Much faster, but not 4 times (that would be 15 minutes).


Cheers / Saludos,

Carlos E. R.
(from 11.2 x86_64 “Emerald” at Telcontar)

On 2011-04-16 01:36, beli0135 wrote:
> export MAKEOPTS="-jX" #this X is number of cores +1. My machine I7
> has 8 cores, so I use -j9

Why the plus one? :open_mouth:


Cheers / Saludos,

Carlos E. R.
(from 11.2 x86_64 “Emerald” at Telcontar)

So, if you want to compile a kernel, I got to throw my two cents in by using SAKC.

Kernel 2.6.38.2 is the most recent stable kernel you can download source to from The Linux Kernel Archives. I am using it on my PC with openSUSE 11.4 and it works great! I don’t think it materially matters where it came from though I would look for a version based on the most recent stable one if possible (2.6.38.2). You can compile your own from source using the SAKC bash script located here in message #17:

S.A.K.C. - SUSE Automated Kernel Compiler - Version 2.00

To compile your own kernels normally you should consider doing the following:

Open YaST / Software / Software Management - Select the View Button on the top left and pick Patterns. Now, you will see several Patterns listed and you want to select:

    Development 

[X] Base Development
[X] Linux Kernel Development
[X] C/C++ Development

Then Press the Accept button on the bottom right and allow these applications to install. Using SAKC does not remove any previous kernels and all would be there to select from in your grub menu.lst file. If you load a proprietary video driver from nVIDIA or AMD, it must be reloaded into any new kernel that you might install. SAKC is just another option that allows any compatible kernel to be installed from kernel.org without waiting for the version you want to move to one of the repositories.

Thank You,

On 04/15/2011 07:03 PM, Carlos E. R. wrote:
> On 2011-04-16 01:36, beli0135 wrote:
>> export MAKEOPTS="-jX" #this X is number of cores +1. My machine I7
>> has 8 cores, so I use -j9
>
> Why the plus one? :open_mouth:

One compile job for each core plus one job to coordinate the rest.

On 2011-04-16 05:37, Larry Finger wrote:
> On 04/15/2011 07:03 PM, Carlos E. R. wrote:

>> Why the plus one? :open_mouth:
>
> One compile job for each core plus one job to coordinate the rest.

Curious. I compiled with -j4 on my 4 cores machine, and it went almost 4
times as fast.


Cheers / Saludos,

Carlos E. R.
(from 11.2 x86_64 “Emerald” at Telcontar)

On 04/16/2011 07:03 AM, Carlos E. R. wrote:
> On 2011-04-16 05:37, Larry Finger wrote:
>> On 04/15/2011 07:03 PM, Carlos E. R. wrote:
>
>>> Why the plus one? :open_mouth:
>>
>> One compile job for each core plus one job to coordinate the rest.
>
> Curious. I compiled with -j4 on my 4 cores machine, and it went almost 4
> times as fast.

On my dual core laptop, -j4 is faster than -j3, but -j5 is slower. On a desktop
system with a dual core, -j5 is the fastest. The sweet spot will depend on the
relative speed of the CPUs, the disk, and memory, and the amount of RAM. You can
tell from ‘make clean ; time make -jX’

Note: using -j2 on a single CPU is quite a bit faster than the default of -j1.