WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: how to compile a specific kernel for my PC? (target: improving the boot time)  (Read 3998 times)

Offline floppy

  • Hero Member
  • *****
  • Posts: 577
Hello,
since I was messing up in another place,  http://forum.tinycorelinux.net/index.php/topic,11235.msg68971.html#msg68971
I create here a new topic.

For compiling a kernel, only for my PC, I do

a) load compiletc.tcz
b) load the source from http://distro.ibiblio.org/tinycorelinux/4.x/x86/release/src/kernel/   to     /mnt/sdb1/files/  (on the boot USB)
c) unpack the source in directory /mnt/sdb1/files/linux-3.0.3/ with "sudo tar xf linux-3.0.3-patched.tar.xz"
d) "mkdir /home/linux"
e) "sudo ln -s /mnt/sdb1/files/linux-3.0.3/ /home/linux"
f) "cd /home/linux"
g) "sudo make localmodconfig"
error "make: *** No rule to make target ' localmodconfig' . Stop."). Same with thwe "oldconfig" param.

Can somebody help in finishing that "how to" for making a space shuttle out of my P4 DC7100 ?..
I will further have a look into http://www.linuxfromscratch.org/lfs/view/stable/chapter08/kernel.html
Any support is welcome. I wil post all updates of the howto in that first post.

« Last Edit: March 02, 2012, 09:57:08 AM by floppy »
AMD K6-IIIATZ 550MHz MB DFI K6xv3/+66
P4 HP DC7100 3GB 3GHz
Samsung NC10 boot from SD card port (via USB reader)
.. all TinyCore proofed

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14516
Why not just cd into /mnt/sdb1/files/linux-3.0.3/ and do "make ..." from there?

You'll also need to copy over the tc .config file and load the perl5, ncurses-dev and bash extensions to compile the kernel

Offline waslit

  • Newbie
  • *
  • Posts: 13
Here is an excellent guide that works for me no credit to me was unable to put in an external link. Must be cause im noob status on the forums.

Install the kernel source tree

Unpack the kernel source tree into the Percio directory so the sources appear in Percio/linux-2.6.33.3/. With Fedora the download of the patched kernel can be handed off to the Archive Manager. This makes life easy as you only have to select 'Extract' and then navigate to the Percio directory before clicking on Extract.

Next open a terminal, move to the kernel source directory and ensure the directory is clear of any previous builds.

[thin@mantaray Percio]$ cd linux.2.6.33.3
[thin@mantaray linux-2.6.33.3]$ make mrproper

The make mrproper command ensures that the source tree is clean of any previous builds.

You can then either copy over the original config file or a custom config file.

[thin@mantaray linux-2.6.33.3]$ cp ../config-2.6.33.3-tinycore .config

Edit config

There are a variety of ways in which you can edit the .config file:

    make config This will ask you if you want to add in the new options from the kernel by selecting y/n/m.
    make xconfig Uses a GUI configuration.
    make menuconfig Uses a terminal configuration based on curses.

xconfig and menuconfig have a help option which is nice if you are unsure of what option you are turning on/off. config DOES NOT have this help menu option.

I usually use make menuconfig - but only because that's what I've always done in the past. However I found that for some unknown reason make menuconfig was resulting in a complete rebuild of the kernel each time rather than the expected partial rebuild so I invested a little time in getting the right libraries loaded so that I could use make xconfig. When using this option I found that things behaved as expected.
(Re)Build new kernel

If you've been making significant changes - and also when you think everything is fine and this is the final build it's best to start with a clean sheet:

[thin@mantaray linux-2.6.33.3]$ make clean

Then build everything. During small tweaks of the main kernel you may not want to bother with the modules bit.

[thin@mantaray linux-2.6.33.3]$ make bzImage modules

You'll end up with a new kernel in arch/x86/boot/bzImage.

If you've made a significant change to the kernel - such as turning off SMP support - then you'll need to also rebuild the tinycore.gz file with the new set of modules.

In a root shell in the directory extract delete the previous set of modules. Then install the new set. This is done by the following sequence of commands:

Note: References to lib/ are to the lib/ in the extract subdirectory. Don't inadvertently add a leading '/' and remove files from your system's lib directory!

[root@mantaray extract]# rm -r -f lib/modules lib/firmware
[root@mantaray extract]#cd ../linux-2.6.33.3
[root@mantaray linux-2.6.33.3]#make INSTALL_MOD_PATH=../extract modules_install
.....
[root@mantaray linux-2.6.33.3]#cd ../extract

I find I also get some spurious firmware files installed that are of no interest. To save space you can delete them:

[root@mantaray extract]# rm -r -f lib/firmware

Final step is to recreate the .gz file. At this stage I tend to name mine mytinycore.gz.

[root@mantaray extract]# find | cpio -o -H newc | gzip >../mytinycore.gz

Finally copy over the new kernel and (maybe initrd) file(s) to your Compact Flash card - in my case it is mounted on /media/TINYCORE - and then unmount it preparatory to removing it.

[root@mantaray linux-2.6.33.3]# cp arch/x86/boot/bzImage /media/TINYCORE/boot/mybzImage
[root@mantaray linux-2.6.33.3]# cp ../mytinycore.gz /media/TINYCORE/boot/
[root@mantaray linux-2.6.33.3]# umount /media/TINYCORE

The only limit to my abilities, lies in how much I feed my curiosities.

Offline tweetyhack

  • Newbie
  • *
  • Posts: 42
d) "mkdir /home/linux"
e) "sudo ln -s /mnt/sdb1/files/linux-3.0.3/ /home/linux"
f) "cd /home/linux"

I didn't even know you can ln -s /mnt/sdb1/files/linux-3.0.3/ /home/linux but apparently, it creates a link inside the directory. So step f should be more like cd /home/linux/linux-3.0.3. If you skip step d, make the link, and cd /home/linux, that would take you into the correct directory.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11178
Hi floppy
I just want to point out that the  localmodconfig  script was created to reduce compilation time, not boot time. Personally,
I don't think you'll see much difference in boot time. Regardless, one thing you want to watch out for, you have to make
sure that all the modules you will require are loaded, or you'll find certain functions removed. If you use cifs to connect
to a drive on another machine, make sure you mount a shared drive, or cifs support will probably be removed. The
same goes for any other special functions like connecting an ipod, firewire, usb, etc.

Offline floppy

  • Hero Member
  • *****
  • Posts: 577
Hi floppy
I just want to point out that the  localmodconfig  script was created to reduce compilation time, not boot time. Personally,
I don't think you'll see much difference in boot time. Regardless, one thing you want to watch out for, you have to make
sure that all the modules you will require are loaded, or you'll find certain functions removed. If you use cifs to connect
to a drive on another machine, make sure you mount a shared drive, or cifs support will probably be removed. The
same goes for any other special functions like connecting an ipod, firewire, usb, etc.
Other way of success: with http://forum.tinycorelinux.net/index.php/topic,9028.0.html! , my AMD K6 improved its boot time between "desktop on button pushed" and "screen background there" from 124s to 103s. Good. So, I made now a new menu entry in grub "Core K6 speed boot". I dont change every week the desktop structure/cards, so, this process of squeezing the initramfs can be recommended after few weeks/months of a TinyCore installation. So, now, I postpone the project for compiling the kernel for my PC.
I got a 20% better boot time on my P4, too, with the "gutmensch" script.
AMD K6-IIIATZ 550MHz MB DFI K6xv3/+66
P4 HP DC7100 3GB 3GHz
Samsung NC10 boot from SD card port (via USB reader)
.. all TinyCore proofed

Offline gutmensch

  • Administrator
  • Hero Member
  • *****
  • Posts: 605
  • I can make it disappear, have no fear!
    • remembrance blog
btw. I think especially on old PCs you can reduce the boot time a lot when you use LZO compression for kernel and initrd. It's a little plus in size but it's often a better minus in speed. According to this http://free-electrons.com/blog/lzo-kernel-compression/ they gained 30% in speed with a 9% bigger kernel on a quite slow machine and other arch (ARM), but for old PCs it's probably likewise.
If I seem unduly clear to you, you must have misunderstood what I said. (Alan Greenspan)

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 10957
You can use LZO ramdisks with the current kernel too, letting you benchmark without needing to rebuild the kernel.
The only barriers that can stop you are the ones you create yourself.

Offline floppy

  • Hero Member
  • *****
  • Posts: 577
You can use LZO ramdisks with the current kernel too, letting you benchmark without needing to rebuild the kernel.
how to rebuild my hpdc7100core.gz with the LZO compression?
AMD K6-IIIATZ 550MHz MB DFI K6xv3/+66
P4 HP DC7100 3GB 3GHz
Samsung NC10 boot from SD card port (via USB reader)
.. all TinyCore proofed

Offline gutmensch

  • Administrator
  • Hero Member
  • *****
  • Posts: 605
  • I can make it disappear, have no fear!
    • remembrance blog
how to rebuild my hpdc7100core.gz with the LZO compression?

install lzop.tcz and run

Code: [Select]
$ zcat core.gz | lzop -9 - > core.lzo
If I seem unduly clear to you, you must have misunderstood what I said. (Alan Greenspan)