LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-30-2006, 01:06 AM   #1
vmlinuz.gz
Member
 
Registered: Nov 2005
Posts: 123

Rep: Reputation: 15
When I recompile the kernel, is it necessary to delete any files?


Hello,

I plan on recompiling my current version of the kernel. Is it necessary to delete any current files, or will make take care of replacing the files for me?
 
Old 03-30-2006, 07:27 AM   #2
berbae
Member
 
Registered: Jul 2005
Location: France
Distribution: Arch Linux
Posts: 540

Rep: Reputation: Disabled
Hello,

Have you a README file in your kernel source directory?
Generally it is in /usr/src/linux.

To start building a kernel anew, go to /usr/src/linux and run
make mrproper
before reconfiguring it.

If you speak about replacing your current kernel in /boot, it's safer to keep the current with the new one, in case of problems with the new one.

After compiling, run
make install
make modules_install

That should add your new kernel without erasing the current one.
Then change the grub or lilo boot loader menu to be able to choose to start with the new or the old kernel.
But you should read the docs yourself for more details.

Good luck.

Last edited by berbae; 03-30-2006 at 07:40 AM.
 
Old 03-30-2006, 09:07 AM   #3
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 8,455
Blog Entries: 4

Rep: Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920
The main purpose of make is to be able to determine exactly what needs to be compiled, and to compile only that. The same goes for other actions such as deleting and replacing files.
 
Old 03-30-2006, 10:35 AM   #4
vmlinuz.gz
Member
 
Registered: Nov 2005
Posts: 123

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by sundialsvcs
The main purpose of make is to be able to determine exactly what needs to be compiled, and to compile only that. The same goes for other actions such as deleting and replacing files.
Okay, that answered my question! Thank you for your help.
 
Old 03-30-2006, 01:20 PM   #5
vmlinuz.gz
Member
 
Registered: Nov 2005
Posts: 123

Original Poster
Rep: Reputation: 15
hmm. Not quite, actually. I ran into problems after rebooting directly into my new kernel. It worked multiple times before. I tried cleaning out my build directory. No luck. I do have a few other ideas; I'll write back after I've tried them.

My main problems my kernel keeps paniking if I reboot directly into the new kernel. It says something about it trying to kill init.
 
Old 03-30-2006, 02:00 PM   #6
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD, Raspbian
Posts: 2,192

Rep: Reputation: 339Reputation: 339Reputation: 339Reputation: 339
For the kernel panics, check grub's menu.lst file for correctness (or the lilo equivalent if you're using that). If you did all this manually you could have easily fat-fingered something.

---

I see you list your distribution as Debian. It's pretty easy to compile a kernel with Debian. First, install the "kernel-package" package. Then download and install the kernel source and headers from the Debian repository. Create a symlink from your kernel source directory to "/usr/src/linux". Cd to /usr/src/linux. Run "make clean". Then "make-kpkg clean". Next, copy your current kernel's config from /boot. This will be something like "cp /boot/config-2.6.14-1-686 /usr/src/linux/.config" Obviously, adjust what you copy based on the kernel you're currently running.

Now, I'd recommend looking at /boot/grub/menu.lst and familiarizing yourself with it's contents. Because when you go to install your new kernel, these contents may not be updated correctly. I can tell you that just two days ago when I compiled a kernel, my menu.lst was incorrectly updated - resulting in a grub failure on boot (for both the old kernel and the new one!) Specifically, I had lines like "root (hd0,8)" in my menu.lst and these were erroneously changed to "root (hd0,7)". Similar screwups were found for the "root" specification on the "kernel" lines. You may or may not need to fix things before rebooting.

...back to the compilation... You're in /usr/src/linux. If you want to change the configuration of your new kernel, run "make menuconfig" and set your options. Be prepared for a LOT of learning in this regard if you haven't ventured into configuratoin before - there are one heck of a lot of options! Now edit Makefile and set EXTRAVERSION to something unique (so you can easily identify your new kernel). I set mine like this: "EXTRAVERSION = -1-686-custom".

Finally ... we're ready to start compiling!

Run "make-kpkg --initrd --revision=20060330 kernel_image". That "revision" is just today's date, so I can further identify what I've done at a later date. It is optional. Now, go get a cup of coffee while it compiles. As a point of reference, it took me about 40 minutes to recompile standard Debian SID kernel source (no config modifications) on an Athlon64 3000+ with 1Gb ram.

After your compile has finished, "cd .." to put yourself in /usr/src. If all was successful, you should have a new .deb file containing your new kernel. Install this with "dpkg -i blahblah.deb" (that "blahblah" part being your new kernel name!) Now is when you go look at /boot/grub/menu.lst and verify things look good. Modify as required.

Another thing before you attempt to boot. If you're using nVidia drivers, they may not work with your new kernel. They need to be compiled against the specific kernel you are using. If you know what I'm talking about here, you probably already know what you need to do to update (since you would have already installed them at least once). For added protection at boot, I also edit /etc/inittab and change the default runlevel to 1. Once booted to single user mode with the new kernel you can run "telinit 2" to start X and see if your nVidia driver stuff was done right. Alternately, you could edit your X config file and change the driver to "vesa" temporarily (before booting!)

Now, last thing before you do the big reboot ... make sure you have a bootable Knoppix CD handy (or Kanotix or Slax, etc.) Just in case.

Good luck!
 
Old 03-30-2006, 05:40 PM   #7
vmlinuz.gz
Member
 
Registered: Nov 2005
Posts: 123

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by haertig
For the kernel panics, check grub's menu.lst file for correctness (or the lilo equivalent if you're using that). If you did all this manually you could have easily fat-fingered something.

---

I see you list your distribution as Debian. It's pretty easy to compile a kernel with Debian. First, install the "kernel-package" package. Then download and install the kernel source and headers from the Debian repository. Create a symlink from your kernel source directory to "/usr/src/linux". Cd to /usr/src/linux. Run "make clean". Then "make-kpkg clean". Next, copy your current kernel's config from /boot. This will be something like "cp /boot/config-2.6.14-1-686 /usr/src/linux/.config" Obviously, adjust what you copy based on the kernel you're currently running.

Now, I'd recommend looking at /boot/grub/menu.lst and familiarizing yourself with it's contents. Because when you go to install your new kernel, these contents may not be updated correctly. I can tell you that just two days ago when I compiled a kernel, my menu.lst was incorrectly updated - resulting in a grub failure on boot (for both the old kernel and the new one!) Specifically, I had lines like "root (hd0,8)" in my menu.lst and these were erroneously changed to "root (hd0,7)". Similar screwups were found for the "root" specification on the "kernel" lines. You may or may not need to fix things before rebooting.

...back to the compilation... You're in /usr/src/linux. If you want to change the configuration of your new kernel, run "make menuconfig" and set your options. Be prepared for a LOT of learning in this regard if you haven't ventured into configuratoin before - there are one heck of a lot of options! Now edit Makefile and set EXTRAVERSION to something unique (so you can easily identify your new kernel). I set mine like this: "EXTRAVERSION = -1-686-custom".

Finally ... we're ready to start compiling!

Run "make-kpkg --initrd --revision=20060330 kernel_image". That "revision" is just today's date, so I can further identify what I've done at a later date. It is optional. Now, go get a cup of coffee while it compiles. As a point of reference, it took me about 40 minutes to recompile standard Debian SID kernel source (no config modifications) on an Athlon64 3000+ with 1Gb ram.

After your compile has finished, "cd .." to put yourself in /usr/src. If all was successful, you should have a new .deb file containing your new kernel. Install this with "dpkg -i blahblah.deb" (that "blahblah" part being your new kernel name!) Now is when you go look at /boot/grub/menu.lst and verify things look good. Modify as required.

Another thing before you attempt to boot. If you're using nVidia drivers, they may not work with your new kernel. They need to be compiled against the specific kernel you are using. If you know what I'm talking about here, you probably already know what you need to do to update (since you would have already installed them at least once). For added protection at boot, I also edit /etc/inittab and change the default runlevel to 1. Once booted to single user mode with the new kernel you can run "telinit 2" to start X and see if your nVidia driver stuff was done right. Alternately, you could edit your X config file and change the driver to "vesa" temporarily (before booting!)

Now, last thing before you do the big reboot ... make sure you have a bootable Knoppix CD handy (or Kanotix or Slax, etc.) Just in case.

Good luck!
I am familiar with the kernel compiling process. I have already the obtained the kernel source from www.kernel.org. I've successfully compiled the kernel many times before. It just seems to not be working now, unfortunately. ): Perhaps "make clean" in the kernel source would have a positive effect, I will try that. But it is very strange that it simply doesn't work this time, though it seems that I'm doing the same thing I've done multiple times before. Anyways, here is what I'm currently doing (using 2.6.16 source from kernel.org):

Code:
cd /usr/src/kernel-2.6.16
sudo make mrproper
sudo make O=<build dir> menuconfig
sudo make O=<build dir>
sudo make O=<build dir> modules_install install
It still seems to panic though. I will try a few more things. In the mean time, any ideas as to why it may not work correctly? I will definately double-check my menu.lst.

Edit: Also, it may be worth noting that I already have a compiled kernel (of the exact same version) on my system. That was what my question was about; I was wondering if files from existing kernels could cause problems.

Last edited by vmlinuz.gz; 03-30-2006 at 05:44 PM.
 
Old 03-30-2006, 05:53 PM   #8
philix
Member
 
Registered: Sep 2005
Location: India
Distribution: Redhat Debian
Posts: 36

Rep: Reputation: 15
Hi vmlinuz.gz,

I too had a similiar problem,
Kernel 2.6 supports EXT3 during the booting process.
Please find the .config file under the /usr/src/linux-version try to edit the EXT3 entry as required and try all the kernel compilation procedure once again
Hope this might help you

Could please elobrate on the error messages that you find during the boot process ?
This might help us to pin point to the actual problem as there are lots of reasons to Kernel panic

Thanks
Philix
 
Old 03-30-2006, 06:17 PM   #9
vmlinuz.gz
Member
 
Registered: Nov 2005
Posts: 123

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by philix
Could please elobrate on the error messages that you find during the boot process ?
This might help us to pin point to the actual problem as there are lots of reasons to Kernel panic
I will elaborate on the errors:

Code:
modprobe: FATAL: Error inserting unix (/lib/modules/2.6.16/kernel/net/unix.ko): Invalid file format

modprobe: FATAL: Error inserting unix (/lib/modules/2.6.16/kernel/net/unix.ko): Invalid file format

modprobe: FATAL: Error inserting unix (/lib/modules/2.6.16/kernel/net/unix.ko): Invalid file format

modprobe: FATAL: Error inserting unix (/lib/modules/2.6.16/kernel/net/unix.ko): Invalid file format

modprobe: FATAL: Error inserting unix (/lib/modules/2.6.16/kernel/net/unix.ko): Invalid file format

modprobe: FATAL: Error inserting ext3 (/lib/modules/2.6.16/kernel/fs/ext3/ext3.ko): Invalid file format

umount: devfs: not mounted
pivot_root: No such file or directory
/sbin/init: 432: cannot open dev/console: No such file
Kernel panic - not syncing: Attempted to kill init!
There may be many more messages, but they scroll by far too rapidly to be visible.
 
Old 03-30-2006, 08:14 PM   #10
philix
Member
 
Registered: Sep 2005
Location: India
Distribution: Redhat Debian
Posts: 36

Rep: Reputation: 15
Hi vmlinuz.gz

I recommend to try to compile with EXT3 entry as required from the config file due to the following error (modprobe: FATAL: Error inserting ext3 (/lib/modules/2.6.16/kernel/fs/ext3/ext3.ko): Invalid file format)
That might resolve the problem

Philix
 
Old 03-30-2006, 08:25 PM   #11
vmlinuz.gz
Member
 
Registered: Nov 2005
Posts: 123

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by philix
Hi vmlinuz.gz

I recommend to try to compile with EXT3 entry as required from the config file due to the following error (modprobe: FATAL: Error inserting ext3 (/lib/modules/2.6.16/kernel/fs/ext3/ext3.ko): Invalid file format)
That might resolve the problem

Philix
Philix, thanks for your assistance. I figured out the problem. Solving it was actually a very complex and intricate process.

1. Delete the old initrd.

2. Make a new one.

*sigh* Well, at least I got it working. Again, thanks to all who tried to help.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
delete old kernel files after recompile? DeltaXFX Linux - Software 3 01-15-2006 12:14 PM
How to delete files that won't delete? di11rod Linux - Security 7 10-19-2005 09:14 PM
Can't find kernel files for recompile jerrit Linux - Newbie 1 02-08-2004 06:46 PM
Kernel recompile for NVIDIA needed .h files? britishnemesis Linux - General 2 11-03-2003 01:43 AM
How to delete the destination files while the source files deleted in cp -u ? myunicom Linux - General 4 09-26-2003 01:13 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:21 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration