Newbie Guide To Compiling A Kernel!
first and foremost, THIS may pertain to you so read that first and then you can proceed ;)
and here is a similiar site www.kernel.org **"Go get the kernel source"** cd /usr/src **"Change Directory To /usr/src"** ls -alc **"check for symlink (ex. /usr/src/linux->/usr/src/linux-2.4.18)"** **"also note since its being ask recently, that if there is no symlink"** **"then move on to the untarring of the kernel"** file linux **"double check with this command (output ex.) linux: symbolic link to linux-2.4.18-14"** rm linux **"remove symlink"** tar -zxvf linux-x.x.x.tar.gz **"unpack the tarball (new kernel)"** ln -s /usr/src/linux-x.x.x /usr/src/linux **"make a new link to the new kernel"** cd linux **"type this to change to the directory"** ---------------------------- Now Comes The Fun Part~! ---------------------------- make mrproper **"this removes the current .config and other files"** cp /usr/src/linux-2.4.x/.config /usr/src/linux ***this is if you want to use your old config*** <-->Your Choice<--> make config **"basic config from terminal"** make menuconfig **"for ncurses GUI in the terminal"** make xconfig **"for X-based GUI with modular explanations"** (QT Based) make gconfig **"same as above, but for 2.6.x kernel only"** (GTK Based, and might be still buggy) /********** Note: Don't forget to add module support and kernel support for future hardware. Do not compile your harddrive and filesystem type as a module. The configure program enables you to specify an enormous number of features. It is advisable to skim through all the sections to get a feel for the different things you can do. Most options are about specifying whether you want a feature[*] compiled into the kernel image, [M] compiled as a module, or [ ] not compiled at all. You can also turn off module support altogether from Loadable module support -->. The kernel configuration is one LINUX program that offers lots of help--select < Help > on any feature. The raw help file is /usr/src/linux/Documentation/Configure.help can be also worth reading. When your done the config click exit and save current configuration. Your file is now known as .config . **********/ SKIP THE FOLLOWING IF DOING A 2.6.x KERNEL make dep **"ensures dependancies such as include files are in place"** (vi, pico, emacs) Makefile **"Want A Unique Kernel Name? Edit /usr/src/linux/Makefile and change EXTRAVERSION" make clean **"to clean your sources for they compile correctly"** START HERE IF COMPILING A 2.6.x KERNEL make bzImage **"to make the kernel image (compile and creates compressed image of kernel)"** make modules **"compile your selected modules"** make modules_install **"to install newly compile modules (installs to /lib/modules/linux.x.x.x)"** -------------------------------------------- Now Its Time To Install Your New Kernel~! -------------------------------------------- Remove the following links: rm -rf /boot/System.map rm -rf /boot/vmlinuz Then copy the newly created kernel and system.map to /boot cp /usr/src/linux/arch/i386/boot/bzImage /boot/vmlinuz-x.x.x cp /usr/src/linux/System.map /boot/System.map-x.x.x Make the new links: ln -s /boot/vmlinuz-x.x.x /boot/vmlinuz ln -s /boot/System.map-x.x.x /boot/System.map <-> NOTE: <-> Before doing the next step, read this [1] and this [2] about the initrd.img and see if you even need to do this step ... there is alot of posts about this step, so i am adding this section ... <-> END NOTE <-> Next remove existing initrd.img file: rm -rf /boot/initrd.x.x.x.img ..And create the new one: /sbin/mkinitrd /boot/initrd-x.x.x.img x.x.x (Note: ) The last set of x.x.x is the eqivalent to your new kernel version and it looks to /lib/modules for that version. -------------------------------------------------------------------- Use The Steps That Pertain To You If You Use Grub Then Edit grub.conf If You Use Lilo Then Edit lilo.conf -------------------------------------------------------------------- remember to leave the entry to your old kernel image just in case, so modify what is in the config originally to point to the old image and make a new entry for you new image you just made .... -------------------------------------------------------------------- <-> And Finally Edit Your /etc/grub.conf file <-> <-> Note some distros now use menu.lst, so if you can't find grub or lilo, then you know what to look for <-> title New Kernel :D kernel /vmlinuz-x.x.x ro root=LABEL=/ initrd /initrd-x.x.x.img (Note: ) look at the previous parameters in the grub.conf file and note what "root=" and use what is existing. Exit and Save grub.conf type "/sbin/grub-install" AND REBOOT!!! <-> And Finally Edit Your /etc/lilo.conf file <-> image = /boot/vmlinuz-x.x.x label = New Kernel :D root = /dev/hdx read-only (Note: ) look at the previous parameters in the lilo.conf file and note what "root =" and use what is existing. Exit and Save lilo.conf type "/sbin/lilo" AND REBOOT!!! /******EDIT******* as requested there was wanting the instructions on how to apply patches to your kernel. ****END EDIT*****/ read this or look below .. This step comes after untaring your kernel source. When you download the patch place it in the folder that you untarred you new kernel. Then type: patch -E -p1 < sound_patch Purely an example and you would type whatever the file name is in replace of sound_patch. As of having alternative boot options, well this is no problem.. The stuff above that i tell you to add to your lilo or grub file above could just append the file, and just add ".old" to the title of your oringinal kernel name for you will know the difference. and whether its grub or lilo add "read-only", to the end of the oringinal entries in the lilo.conf, or grub.conf file. |
so why did i do this?
well i figured i would write a completely new guide with detailed explanations on whats going on, and these steps can address a larger crowd then most guides do, with how they are set up.. so if anyone notices anything wrong or feels there is something i missed, then i'll be glady to add to it or fix it... |
Thanks a lot, that's very helpful -- when I'm a grown up ;) Linux person I will try that ...
I think most people are a little nervous, when you ask them to delete their kernel. Or at least I would be. Why not create the new kernel as an alternative (and show the changes in the symlinks, GRUB / LILO), so one has (two or more) different boot options. Oh, yes, what about handling patches? <- more work for you :D |
thank very much ,Drozz~!
I compiled the new kernel ,but there is some puzzle. I compiled the APM in the kernel ,but why i still cant shut the the computer with poweroff ?(it cant shut down with power) if I want to put my modem modules in the kernel ,what should i do? help me please~thanx |
as of the APM laxi i am not too sure about that, hopefully someone can help you with that, i can't see why its not working if you compiled it into the kernel, unless you compiled it as a module and the module is not loaded...so i guess maybe you could try modprobe apm, and then try shutting down to see if that was the case.
and the modem, maybe this applies to the patch section i described above. |
Hey laxi, are you sure your laptop isn't using ACPI instead of APM? A lot of laptops are using ACPI these days..
|
also another alternative thats there if you want to use it is something like this :
cp -R /boot /boot2 mv /usr/src/linux/System.map /boot2 mv /usr/src/linux/arch/i386/boot/bzImage /boot2/vmlinuz mv /usr/src/linux/vmlinux /boot2 before you do any of the steps mentioned above. thats a very brief and quick explanation and i may have missed something but i am sure you'll get the idea if you want to setup your old kernel like so...also making changes to your .conf files of course, etc,etc.... |
What's the use of System.map and initrd-x.x.x.img? My system is working fine without them?
Thanks |
Quote:
Quote:
|
Quote:
PS. there's a file called module-info, what's it? how can I generate it when compiling a new kernel? I'm using Red Hat 9. Thanks |
well i am not quite sure how your system is set up and why it does / doesn't work how it does...what distro are you using, i only wrote this article to be used on alot of distros not all distros....
as of the module-info file it is a link to module-info-{kernel-version} Contains information about all available modules (at least those included in the default kernel config.) might be used by kudzu to determine default parameters for modules when it creates entries in /etc/modules.conf (guessing here) thats all i can gather, maybe someone else has some better answers for you specific question. |
thank you Drozz,i use the old kernel ,and when i modprobe apm
the power can shut down with the command poweroff,but i use the kernel compiled by myself (i add the apm into kernel,when i compiled it),it cant shutdown ,just display Power Down in the end. is there something else i should do when i use the new kernel? thanks everbody~ |
thanks Pcghost,but my computer is not a laptop.the ACPI is a power manage module,all right?can it use in my computer ?
|
did you compile it as a module ? if so is it being started, if not, did you try modprobe apm with the new kernel? you may have meant to answer these things, but i don't seem to see the answers to these questions in what you just said.
|
Why recreate the wheel
|
can i ask what differs on that page compared to what i have written, and how does it answer his question?
|
thank you for Drozz's effort!
i think that article have the same method with what Drozz write . maybe APM can compile for a modules only? can anyone answer me ? |
do you mean maybe it only compiles as a module only?
if so i am not sure, and if it is only a module, then just load it up and set it to startup on bootup. |
yeah, I want to compile apm IN the kernel ,but it cant work.so i use it as a module now.thank you everybody.
|
yah well like i said if its a module just set it to automatically startup, if it works it works, no need to fix what isn't broken :D
|
i browsed through the forum and found this thread. :study:
i just started compiling kernel 2.4.21 to be included in a custom distro, and have done it pretty much successfully. i am thinking of including several patches (BlueZ, LTSP, and Con Kolivas' patch), i tried including only the BlueZ patch and it worked out fine. is it possible to include several patches and produce only one kernel? if it is, how do i do it? if not, is there a work-around for this? thanks in advance. :) |
well before starting everything off by issuing "make mrproper" apply all your patches ...
|
just going to give this a bump, just so that people may notice it before they ask how to do it, cause i noticed a few threads lately being kernel related.
|
Hello, Newbie Here.
Was lucky enough to stumble upon this extremely enlightening link. Then lost it Then found it again. Got up to the make "modules_install" bit and all I get is after entering the command: ln: when making multiple links, last argument must be a directory make: *** [_modinst_] Error 1 and nothing happens...:scratch: I'm running RedHat 9.0 on a Toshiba Satellite 5105-s607 and FINALLY SUCCESSFULLY added ACPI support (the 2.4.20) patch to Kernel 2.4.20. Any suggestions or ideas would be appreciated! Thanks! |
Quote:
Just heard about that... thx |
as opposed to what else?
|
Quote:
|
This is from the initrd.txt and it explains reason you may want to use it.
Usage scenarios --------------- The main motivation for implementing initrd was to allow for modular kernel configuration at system installation. The procedure would work as follows: 1) system boots from floppy or other media with a minimal kernel (e.g. support for RAM disks, initrd, a.out, and the Ext2 FS) and loads initrd 2) /linuxrc determines what is needed to (1) mount the "real" root FS (i.e. device type, device drivers, file system) and (2) the distribution media (e.g. CD-ROM, network, tape, ...). This can be done by asking the user, by auto-probing, or by using a hybrid approach. 3) /linuxrc loads the necessary kernel modules 4) /linuxrc creates and populates the root file system (this doesn't have to be a very usable system yet) 5) /linuxrc invokes pivot_root to change the root file system and execs - via chroot - a program that continues the installation 6) the boot loader is installed 7) the boot loader is configured to load an initrd with the set of modules that was used to bring up the system (e.g. /initrd can be modified, then unmounted, and finally, the image is written from /dev/ram0 or /dev/rd/0 to a file) 8) now the system is bootable and additional installation tasks can be performed The key role of initrd here is to re-use the configuration data during normal system operation without requiring the use of a bloated "generic" kernel or re-compiling or re-linking the kernel. A second scenario is for installations where Linux runs on systems with different hardware configurations in a single administrative domain. In such cases, it is desirable to generate only a small set of kernels (ideally only one) and to keep the system-specific part of configuration information as small as possible. In this case, a common initrd could be generated with all the necessary modules. Then, only /linuxrc or a file read by it would have to be different. A third scenario are more convenient recovery disks, because information like the location of the root FS partition doesn't have to be provided at boot time, but the system loaded from initrd can invoke a user-friendly dialog and it can also perform some sanity checks (or even some form of auto-detection). Last not least, CD-ROM distributors may use it for better installation from CD, e.g. by using a boot floppy and bootstrapping a bigger RAM disk via initrd from CD; or by booting via a loader like LOADLIN or directly from the CD-ROM, and loading the RAM disk from CD without need of floppies. |
ds: no socket drivers loaded!
DrOzz;
Thanks for your excellent newbie guide. I followed your instruction and everything went smoothly until last step, when I did "/sbin/grub-install ", I got an error message saying it's not the right syntax. So I tried "/sbin/grub-install '(hd0)' ", and got no more error messages. But after I reboot the machine and chose to boot into the new kernel (2.4.22), I got the following messages and the computer just hanged there: NET4: Unix domain sockets 1.0/SMP for linux NET4.0 ds: no socket drivers loaded. kernel panic: VFS: unable to mount root fs on 03:40 . When I did the make xconfig, I did choose Yes to every network socket option. So I can not tell what's wrong here. My computer has two hard drives. The first (hda) runs WinXP Pro and the second runs Redhat linux 9.0 (kernel 2.4.20-20.9). The GRUB is installed at MBR on hda. The linux's root partition is at hdb5. Should I do sbin/grub-install at (hd0)? What should I pay attention to during make xconfig to get the drivers loaded? And I have no problem to boot into the original kernel (2.4.20-20.8). Thanks a lot for your help, sean |
I saw a post similar about the APM shutdown problem with slackware elsewhere on LinuxQuestions, you may want to search for it. It describes a few changes that have to be made to a few system files. Wish I could be more help, but I didn't bookmark the the thread.
|
ok sean, boot into your old kernel, and then when logged in, post your grub.conf file for we can see it...
|
Hi ,
I am trying to compile the kernel 2.4.22 on my local workstation for testing purposes before used it on production server. I have tried go to /usr/src and there is no file at this directory.Usually I upgrade the kernel using rpm packages which I downloaded it from Redhat Network. Can I straight away compile the kernel without going through the steps : cd /usr/src **"Change Directory To /usr/src"** ls -alc **"check for symlink (ex. /usr/src/linux->/usr/src/linux-2.4.18)"** file linux **"double check with this command (output ex.) linux: symbolic link to linux-2.4.18-14"** rm linux **"remove symlink"** tar -zxvf linux-x.x.x.tar.gz **"unpack the tarball (new kernel)"** ln -s /usr/src/linux-x.x.x /usr/src/linux **"make a new link to the new kernel"** cd linux **"type this to change to the directory"** ?? Thanks ! |
well your going to need the kernel source to recompile the kernel there is no question about that...so if there is nothing in /usr/src then you will have to go get the source....if you wanted to just recompile the kernel you are currently using then you don't have to go to that site and do all that stuff, because you mentioned redhat and the kernel source is on the distros cd's...you can always type :: redhat-config-packages and install it that way, or manually find it on your cds ....
but if you want to put a newer kernel on your box, then yes you will have to go and do them steps...unless you get an rpm package somewheres with the kernel source, then you may be able to knock off a couple of steps, but again basically you are going to have to do that.... |
Note : save a file ".config" in /usr/src/linux-x.xx if u want to keep old configuration. If u understand much your configuration u will be able to set up your own kernal configration
|
Hi,
I have installed the kernel source and compiled the kernel 2.4.22 on my RH 8.0. I have reach finished the process but when I reboot the box, I was not able to boot the box and getting the kernel panic error message : VFS : Cannot open root device : LABEL=/dev/hdb6 or 00:00 Please append a correct "root" boot option Kernel Panic : VFS : Unable to mount root fs on 00:00 My grub.conf file as follow : # grub.conf generated by anaconda # # Note that you do not have to rerun grub after making changes to this file # NOTICE: You have a /boot partition. This means that # all kernel and initrd paths are relative to /boot/, eg. # root (hd0,0) # kernel /vmlinuz-version ro root=/dev/hdb6 # initrd /initrd-version.img #boot=/dev/hdb default=0 timeout=10 splashimage=(hd0,0)/grub/splash.xpm.gz title Red Hat Linux (2.4.22) root (hd0,0) kernel /vmlinuz-2.4.22 ro root=LABEL=/dev/hdb6 initrd /initrd-2.4.22.img title Red Hat Linux (2.4.20-20.8) root (hd0,0) kernel /vmlinuz-2.4.20-20.8 ro root=LABEL=/ initrd /initrd-2.4.20-20.8.img title Red Hat Linux (2.4.18-14) root (hd0,0) kernel /vmlinuz-2.4.18-14 ro root=LABEL=/ initrd /initrd-2.4.18-14.img I have tried changed the root boot option to root=/dev/hdb6 but the getting the same output. Please advise.Thanks. |
maybe its because you are using the label to point to the actual partition that root is located (i assume thats what /dev/hdb6 is) rather than just saying ::
root=LABEL=/ or did you try that? |
Hi,
Problem fixed ! MY mistakes..the correct hdd should be hda6 and NOT hdb6...:D Sorry guys... I guess I will have to recompile my kernel again as the network port on the PC cannot be detected and iptables seems to be failed ....:mad: What modules should I compile again in the Makefile so that I can set to compile my network? |
Hi,
After login to the root shell : Perhaps iptables or your kernel need to be upgraded iptables v1.2.8 : can't initialize iptables table 'filter' : iptables who?( do you need to insmod?) Running ifconfig eth0 returns the below error message : eth0:error fetching interface info : Device not found. Thank you. |
Hi,
Ok solved it by recompiling the kernel with the on board Ethernet LAN enabled. But I am getting the error message looping on my screen : modprobe : modprobe : Cant locate module net-pf-1 Can I disable this "modprobe"?:confused: |
just look in your /etc/modules.conf file and comment out the line thats trying to load that...to comment out something you put a # in front of the line...so for example something like ::
#alias whateverTHEmoduleIS |
Hi,
No luck :( I have commented most of the entry in /etc/modules.conf.Below is my entry for the modules.conf file : alias parport_lowlevel parport_pc alias eth0 sis900 alias usb-controller usb-ohci alias usb-controller ehci-hcd alias sound_slot-0 i810-audio post-install sound-slot-0 /bin/aumix-minimal -f /etc/aumixrc -L > /dev/null 2 > $ 11 2 > $1 ||; pre-remove sound-slot-0 /bin/aumix-minimal -f /etc/aumixrc -S > /dev/null 2 > $ 2> &1 ||; I have commented out all of the entry except alias eth0 sis900 and rebooted the PC but still the error message keep looping infinity on my screen. Please help....Thanks |
k i was just looking at the file :
/usr/src/linux/Documentation/Configure.help and this comes from it:: Quote:
alias net-pf-1 off best of luck! :D |
I had the same problem as yours. So i had to reinstall RH.
Then, save a file ".config" in /usr/src/linux-x.x.x to other place make mrproper copy .config to /usr/src/linux-x.x.x (n your new kernel) make menuconfig (if u want to change some thing in configuration, but note that u have to know much about kernel configuration) |
Note : do the steps that DrOzz said then make mrproper
|
is that the only way you could fix it electboy, or did you try what i said and it worked?
|
Hi,
alias net-pf-1 off :D worked ! but problem now is that I am not able to ssh to the box from my terminal.There is no error shown and the application that I used for SSH ( putty ) just closed ( within 1 seconds ) after I hit the Open connection button. The ssh services is started and I have tried restart the service as well.... |
Your steps are right but it require have much knowledge about kernel configuration (not for newbie). I did as i said when i didnt know much about kernel configuration, ofcourse i successed.
|
so is the port being blocked, are you connected through a router, that isn't setup to forward the port, and trying to access your box from an outside source.....are you sure its not a windows problem, or a putty problem for that matter....
oh and glad that other problem working out for ya :cool: |
Kernel Meta-Patches and such
Hi there.
Just wondered if anyone could comment on the various kernel meta-patches available, i.e.: Alan Cox, Con Kolivas, etc.. They claim to add performance and features not available in the stock/vanilla kernels. For the purposes of creating primarily a Workstation/Desktop system: 1. Would you recommend using them? 2. Can the Alan Cox patches and the Con Kolivas patches be used together/at the same time? 3. What additional patches or customizations do you recommend? Thanx. |
Can someone tell me how I do this in SuSE 8.2??
..And create the new one: /sbin/mkinitrd /boot/initrd-x.x.x.img x.x.x (Note: ) The last set of x.x.x is the eqivalent to your new kernel version and it looks to /lib/modules for that version. It keeps giving me the error: can't create temp directory rberry88 |
All times are GMT -5. The time now is 07:32 PM. |