Kernel build, install and boot question on ram disk image
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Kernel build, install and boot question on ram disk image
Hi,
I am using Ubuntu 8.04 on Dell D630 laptop and trying to build a barebone kernel using the tar ball from kernel.org. It's 2.6.25.9.
I did the usual things "make config, make, make modules, make module_install, make install".
Now I have read that I need to make an intermediate ram disk image. I finally got a chance to download the mkinitramfs package. It asked me to run "update-initramfs" on the local box. So when I did this I got an error about missing "/etc/modprob.conf" file. My googling didn't produce a lot of clues how I can solve this problem:
Code:
/boot$ sudo update-initramfs -c -k 2.6.25.9
update-initramfs: Generating /boot/initrd.img-2.6.25.9
cp: cannot stat `/etc/modprobe.conf': No such file or directory
------------------
Error has occured!
update-initramfs: failed for /boot/initrd.img-2.6.25.9
I am using Ubuntu 8.04 on Dell D630 laptop and trying to build a barebone kernel using the tar ball from kernel.org. It's 2.6.25.9.
I did the usual things "make config, make, make modules, make module_install, make install".
Now I have read that I need to make an intermediate ram disk image. I finally got a chance to download the mkinitramfs package. It asked me to run "update-initramfs" on the local box. So when I did this I got an error about missing "/etc/modprob.conf" file. My googling didn't produce a lot of clues how I can solve this problem:
Code:
/boot$ sudo update-initramfs -c -k 2.6.25.9
update-initramfs: Generating /boot/initrd.img-2.6.25.9
cp: cannot stat `/etc/modprobe.conf': No such file or directory
------------------
Error has occured!
update-initramfs: failed for /boot/initrd.img-2.6.25.9
And I'll offer my usual observation. If you want to play with a "barebone" kernel, Ubuntu ain't the distro to use.
There is (usually) no intrinsic requirement for in initrd for a home-brewed kernel - when you build the kernel, build it for your system.
There are better environments for learning kernel hacking than Ubuntu - but if you just want to build a new Ubuntu kernel, see the link(s) referenced above.
First off thanks for the suggestion. I have a spare machine that is running Ubuntu and so I 'd like to see if I can build a barebone kernel and boot it up. You are right I am learning the kernel using this. If ubuntu is not the best what else? where do I start?
Second, followed the suggestion to touch /etc/modprob.conf and I did build a init.img-2.6.25.9 But when I tried to boot to my newly built 2.6.25.9 barebone kernel, it failed. Here are some of the last messages I can remember:
Code:
Searching for root device:************************** Failed! Halting system.
Press Enter to halt or Ctrl-Alt-Del to reboot.
/etc/init/.functions: line21: chvt:command not found.
Any ideas?
Quote:
Originally Posted by syg00
And I'll offer my usual observation. If you want to play with a "barebone" kernel, Ubuntu ain't the distro to use.
There is (usually) no intrinsic requirement for in initrd for a home-brewed kernel - when you build the kernel, build it for your system.
There are better environments for learning kernel hacking than Ubuntu - but if you just want to build a new Ubuntu kernel, see the link(s) referenced above.
If there's no root device, then chances are you didn't enable the module for your disk controller. Where did you get your .config file from? Normally you should copy that from /boot/config-`uname -r` (note the backquotes) and then run "make oldconfig" before you make the kernel. This ensures you have at least the modules compiled in that the kernel you're booting from does.
I am learning the kernel using this. If ubuntu is not the best what else? where do I start?
Personally I don't like any of the "mega" distros for playing with the kernel - still leaves lots of choice. I started with Gentoo, but the usual suspects would include Debian and Slackware.
I find myself predominantly using Arch these days. The whole environment is built for i686 (not just the kernel) - it's small, fast and has a good package management system.
If you are just starting out, a visit to kernelnewbies would be worthwhile, as would getting a copy of something like "Linux Kernel in a Nutshell". It's available online - search LQ for other recommendations.
What the hell difference does it make? The man has ubuntu. He has an interest in ubuntu. It would be a good project and learning experience. Why all the negativism? It doesn't make that much difference.
Before I try the new command here is my answer to your question:
I think the .config was generated from make or make modules. After "make install" I can see the file in my boot dir. Here is a snapshot of my current /boot:
Also here is a snapshot of my menu.lst for the GRUB loader:
Code:
title Bare kernel 2.6.25.9
root (hd0,4)
kernel /boot/vmlinuz root=UUID=fe10c020-b90c-48d5-9ed3-c4dce4b78a34 ro quite splash
initrd /boot/initrd.img-2.6.25.9
quite
The only difference between the above and my regular Ubuntu boot are the vmlinuz and initrd.img versions. Everything else was copied over.
Quote:
Originally Posted by Quakeboy02
If there's no root device, then chances are you didn't enable the module for your disk controller. Where did you get your .config file from? Normally you should copy that from /boot/config-`uname -r` (note the backquotes) and then run "make oldconfig" before you make the kernel. This ensures you have at least the modules compiled in that the kernel you're booting from does.
I guess I didn't address the ".config" question directly in my last reply. I don't see a ".config" in my /boot dir. This is weird. How can my Ubuntu bootup without this if it's necessary? Here is the entire snapshot of my /boot:
Before I try the new command here is my answer to your question:
I think the .config was generated from make or make modules. After "make install" I can see the file in my boot dir. Here is a snapshot of my current /boot:
Oh, I see what's confusing you. The compiler uses a ".config" file, but it exports it as "config-kernelversion" for booting. Each kernel needs its own config file, and it's named accordingly. When I told you to run "cp /boot/config-`uname -r` .config", that copies the config for the running kernel to the .config to use to compile the next one.
BTW, when you install a kernel with "dpkg -i" it updates grub and runs update-initramfs for you. When you remove one with "dpkg -r" it removes them for you. Much tidier than having to do it all yourself, but I suppose that you might be at a loss if you went to a different distro and tried it. Still, that's what google is for.
you are asking me to copy the current Ubuntu config file from /boot to my new linux source code dir as .config and recompile the source using "make oldconfig"?
So the config-2.6.25.9 from my previous compile is wrong?
Oh, I see what's confusing you. The compiler uses a ".config" file, but it exports it as "config-kernelversion" for booting. Each kernel needs its own config file, and it's named accordingly. When I told you to run "cp /boot/config-`uname -r` .config", that copies the config for the running kernel to the .config to use to compile the next one.
you are asking me to copy the current Ubuntu config file from /boot to my new linux source code dir as .config and recompile the source using "make oldconfig"?
So the config-2.6.25.9 from my previous compile is wrong?
I guess that was confusing. Let's start from the beginning. You download your kernel. THEN you copy the .config for the currently running kernel; not the one you are trying to make but the one that is running before you do the download. Then you do the "make oldconfig". This step checks to see if there are any new kernel options that have been added since the one you are currently running. If there are, it asks you whether you want to add them or not, and gives you a default: usually N. After that, you run the make-kpkg or whatever command set you choose to use to make your kernel.
The reason you do them in this order is so that you don't start with some random kernel config that doesn't have your device driver enabled. Having said that, it's true that make oldconfig is automatically run if there isn't a .config file found using the ubuntu way. I can't say what happens when you go through all the makes etc using the manual way, as I've never bothered even learning how. If it pestered you with a bunch of questions when you compiled it, then yes, it did run make oldconfig.
OTOH, if you are actually running from 2.6.25.9, remind me what the problem is.
What you may not understand is that those back-quotes in `uname -r` actually run the command "uname -r" and append the version of the running kernel to /boot/config in the copy command I gave you. The back-quote is not a single quote. It is the key to the left of the "1" key which is above and to the left of the "q" key.
Ok, I copied the existing config files, did make oldconfig, did make and make modules. At the end of make modules, there is a warning:
Code:
Building modules, stage 2.
MODPOST 1910 modules
WARNING: modpost: Found 15 section mismatch(es).
To see full details build your kernel with:
'make CONFIG_DEBUG_SECTION_MISMATCH=y'
What does this mean? Something wrong?
Quote:
Originally Posted by Quakeboy02
I guess that was confusing. Let's start from the beginning. You download your kernel. THEN you copy the .config for the currently running kernel; not the one you are trying to make but the one that is running before you do the download. Then you do the "make oldconfig". This step checks to see if there are any new kernel options that have been added since the one you are currently running. If there are, it asks you whether you want to add them or not, and gives you a default: usually N. After that, you run the make-kpkg or whatever command set you choose to use to make your kernel.
The reason you do them in this order is so that you don't start with some random kernel config that doesn't have your device driver enabled. Having said that, it's true that make oldconfig is automatically run if there isn't a .config file found using the ubuntu way. I can't say what happens when you go through all the makes etc using the manual way, as I've never bothered even learning how. If it pestered you with a bunch of questions when you compiled it, then yes, it did run make oldconfig.
OTOH, if you are actually running from 2.6.25.9, remind me what the problem is.
What you may not understand is that those back-quotes in `uname -r` actually run the command "uname -r" and append the version of the running kernel to /boot/config in the copy command I gave you. The back-quote is not a single quote. It is the key to the left of the "1" key which is above and to the left of the "q" key.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.