Recompiling the Kernel for a realtime Frugal Install

How to do things, solutions, recipes, tutorials
Post Reply
Message
Author
brent99
Posts: 17
Joined: Thu 15 Oct 2009, 21:15

Recompiling the Kernel for a realtime Frugal Install

#1 Post by brent99 »

*** EXECUTIVE SUMMARY ***

A frugal pup need vmlinuz, the builds sfs, and the initrd.gz files. So all that needs to be done is rebuild the patched kernel with the desired options (and additional patches) to produce the new vmlinuz file and rebuild the modules. Then replace the modules in the initrd.gz and main sfs file to stay kernel compatible with a unzip-replace-rezip ninja move.


*** DETAILS AND SCRIPTS ***

I wanted to build a kernel patched with realtime extensions for a FRUGAL install. I started my journey at:

http://puppylinux.com/development/compilekernel.htm

I found it didn't tell me quite what I wanted, so I found my own way to rebuild the kernel and repatch the release frugal files with the updated modules. Here is how I did it! This may not be the best way, may not be even a decent way to do this, I don't know. I'm sure there are far better ways. However, this does seem to work and if you are attempting something similar, maybe you'll find some things in here you will think useful, so I shared it. If I missed some magic button or utility that does all this ridiculously easier than I did it, feel free to share!

*NOTE: NOT FOR THE FAINT OF HEART -- DANGEROUS --
SOME DECENT LINUX KNOWLEDGE REQUIRED!*


RECOMPILING KERNEL AND REBUILDING PUPPY LIBRARIES
Puppy Precise 5.5, Linux 3.2.29, for FRUGAL INSTALL REBUILDS

This is an example of rebuilding Puppy Precise 5.5 kernel with the RT extension patch 44 applied for a Frugal Install. Depending on what you are trying to do, you may have to modify the steps/scripts for other kernels and other patches or other Puppy Distros. Particularly names and things like that!

You will need the patched kernel source, the "3rd party" drivers (to rebuild
them -- 2modules can be skipped for just testing a kernel w/o network)

I modified the build scripts primarily to keep 1kernel.sh from applying patches so that I could do that manually. I took the puppy patched kernel source and applied the RT patch with "zcat patches.gz | patch -p1". I have /usr/src/linux soft-linked to /usr/src/linux-3.2.29-rt44 (after renaming linux-3.2.29). So 1kernel.sh is just running a modified build with simplified system checks and I put the "3.2.29" hardcoded. 2modules.sh is also modified for 3.2.29.

1. Using my modified scripts, run 1kernel.sh from /usr/src with /usr/src/linux populated with a puppy-patched kernel and RT extension patch if applicable to your goal. The DOTconfig in /usr/src should copy down to /usr/src/linux, which should be soft linked to /usr/src/linux-3.2.29. This should be done on a FULL INSTALL of Puppy 5.5. You will have a chance to modify/verify .config at the start of the install, and then it will re-build on this system. It will build vmlinuz and place it in /boot/vmlinuz after a couple hours. Issue a "depmod -a" to rebuild modules.dep.You now have vmlinuz, 1 of the 3 necessary files. Reboot and run the ./2modules.sh script that I have also modified for my purposes. This rebuilds some modules needed for a complete set. When prompted, "Enter, i686, and 1, Enter" are my responses to questions.

After rebuilding the kernel, we need to update the modules packed into
initrd.gz and puppy_precise_5.5.sfs as well as a couple name references to reflect the build change. I rebuild these myself rather than use ./3packages.

2. Create a subdirectory, enter it, and unpack initrd.gz with:
zcat ../initrd.gz | cpio -i
We will modify this. DISTRO_SPECS should reflect DISTRO_PUPPYSFS=
'puppy_precise_5.5-rt44.sfs'. Changing this name will warn puppy save files that they need to be updated, which may prove useful.


** NOTE: THE REST OF THE STEPS HERE ARE IN A ATTACHED SCRIPT CALLED 4rebuild-frugal.sh!! **


Now go to ./lib/modules and move 3.2.29 to 3.2.29-rt44.
Enter this directory and set aside modules.dep as is.
Unzip the files using:
find . -name '*.ko.gz' | xargs -i gunzip {}
Replace the files using:
find . -name '*.ko' | xargs -i cp -a /lib/modules/3.2.29-rt44/{} {}
Re-zip the files using:
find . -name '*.ko' | xargs -i gzip {}
Clear the old stuff in this /lib/modules/3.2.29 directory with:
rm *
(A 'can't remove kernel directory message' is expected!)
Replace it with:
cp /lib/modules/3.2.29-rt44/* .
(Don't copy directories! 'Omit' messages expected!)
Replace the modules.dep file that was set aside previously.
Move back to the top of the initrd subdirectory.
Rebuilding initrd gz with:
find . | cpio -H newc -o | gzip -9 > ../initrd.gz
Now you have 2 of the 3 necessary files.

3. Unsquashfs puppy_precise_5.5.sfs. This will create squashfs-root with the Puppy Precise. Update /etc/DISTRO_SPECS based on what was used in initrd. Go to ./lib/modules/3.2.29 and remove it. Replace it with:
cp -a /lib/modules/3.2.29-rt44 .
Go back to the root of squashfs-root and enter:
mksquashfs * ../puppy_precise_5.5-rt44.sfs
Note: if that filename already exists, delete it first!
You now have all 3 of the files needed for your FRUGAL!

4. Now, copy vmlinuz, initrd.gz, and puppy_precise_5.5-rt44.sfs to your frugal install. Reboot. It will automatically update the save file (not sure what this actually does and if its really needed) because it sees the name change.

You can verify the Linux build running with "dmesg | grep Linux" for key build flags and the kernels build time.
Attachments
4rebuild-frugal.sh.gz
All the rebuild steps above in a single script (note: hardcoded to specific linux-3.2.29-rt44 -- please modify!)
(731 Bytes) Downloaded 281 times
1kernel-nopatch.zip
Build scripts modified to skip patch, minimum check, set for specific kernel v.
(4.61 KiB) Downloaded 214 times

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#2 Post by musher0 »

Hello, brent99.

Please forgive my ignorance, but what are real time extensions useful for?
Recording live music directly to disk? Like in the old Atari Falcon?
Does this solve a particular deficiency in Puppy?
Should the average user be concerned with this re-building process?

Thanks in advance for your reply.

Best regards.

musher0
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#3 Post by Karl Godt »

Low Latency Kernel
As of Ubuntu Studio 12.04 the default kernel is linux-lowlatency, which in essence is a generic Ubuntu linux kernel, with a tweaked configuration to allow for stable operation for audio applications at lower latencies. Since much of the realtime patch has now been implemented into the vanilla kernel, and considering the difficulties in maintaining linux-rt, Ubuntu Studio decided on using linux-lowlatency in its place.
http://en.wikipedia.org/wiki/Ubuntu_Stu ... ime_kernel

https://rt.wiki.kernel.org/index.php/Fr ... _Questions
https://rt.wiki.kernel.org/index.php/RT_PREEMPT_HOWTO

I once looked for it but that time it stopped at some kernel 2.6.20ies .
Now there seems to be newer patches at
https://www.kernel.org/pub/linux/kernel/projects/rt/

Post Reply