# [SOLVED] cannot (re)compile working kernel anymore

## jmrk

Hi everyone, 

something really strange happened to my ~amd64 system, and I'm out of ideas as to how to fix it. For a few weeks now, I have not been able to build any gentoo-sources-2.6.30(-rX) kernel that's able to boot; no matter what I tried, the system freezes right after grub passes control to the new kernel. Previously built kernels (up to and including 2.6.30) boot up OK. 

History:

- I updated to gentoo-sources-2.6.30-r1 when they became available about a month ago. When I tried to reboot into the new kernel, it wouldn't boot. So I used an older kernel (.29-r5) to boot (because I had already deleted 2.6.30, not expecting any major breakage from a -r1 update), reinstalled gentoo-sources-2.6.30, compiled that, booted it, everything went fine, and I ignored the issue for a while. 

- When 2.6.30-r2 became available, I updated to this version, compiled it, tried to boot it -- same problem as with -r1. I got worried, and started investigating into the problem. 

Problem status:

- My kernel compiles fine as always, there are no perceptible problems with the compile process. 

- When I try to boot with the new kernel, the system freezes immediately. There are no error messages displayed, only grub's info message about the kernel image it found.

- When I try to boot via the grub command line, entering the following commands:

```
root (hd0,4)

kernel /boot/kernel-<whatever> root=/dev/sda5 ro

boot
```

then after pressing return, the cursor jumps to the beginning of the next line and nothing else happens (i.e. I have to press the reset button). 

- I'm quite sure it's not a problem with my kernel configuration (see below why)

- I'm quite sure it's not a problem with my grub (see below why)

- I'm quite sure it's not a problem with a specific kernel version (2.6.30 did compile before and is running right now)

What I tried (IIRC in that order):

- I searched these forums and the bug database, but didn't find anything that seemed related to my problem. 

- I played around with my kernel configuration (which worked for .30!). In particular, I tried pappy's seed (https://forums.gentoo.org/viewtopic-t-707499.html, adjusted for my hardware) as well as the default settings (again, adjusted to my hardware). No change, kernels won't boot.

- emerge @preserved-rebuild. Did not rebuild anything. 

- revdep-rebuild. Did not rebuild anything. 

- emerge -eav system, and recompiled my kernel afterwards. Problem persisted. 

- emerge -eav world, and recompiled my kernel afterwards. Problem persisted. 

- booting from the Ubuntu installation I have on another partition, I did an fsck.jfs -v -f /dev/sda5 which found a few filesystem inconsistencies, but did not affect my problem (I recompiled my kernel after this).

- I tried to boot using the grub that belongs to said Ubuntu installation. Same situation as with Gentoo's grub. 

- I checked the forums again to see if a relevant thread had popped up by now. None that I could see, so I guess I'm (at least right now) the only one experiencing this problem, which confirms my belief that the current version itself has nothing to do with it.

Somewhere along the way of my tests, I noticed this Really Weird Thing:

```
cd /usr/src/linux-`uname -r`

make mrproper

cat /proc/config.gz | gunzip > .config

make && make modules_install && cp arch/x86/boot/bzImage /boot/kernel-`uname -r`-rebuild
```

This should exactly rebuild the currently running kernel, right? So if the currently running kernel was able to boot, so should the newly built kernel, right? Well, it doesn't  :Sad: 

It seems that my system is completely unable to produce working kernel images, be it updates or previously-working old versions (I haven't yet tried rebuilding .29, though). But since there are no error messages whatsoever, and 'emerge world' didn't help, I don't know where to look for a cause or workaround. 

Any ideas what I could try to fix this issue? Although 2.6.30 (as compiled on June 15) runs fine for now, I don't want to be stuck with it forever...

If you need any other info, just ask. Any help would be greatly appreciated.

emerge --info:

```
Portage 2.2_rc33 (default/linux/amd64/2008.0, gcc-4.3.3, glibc-2.10.1-r0, 2.6.30-gentoo x86_64)

=================================================================                              

System uname: Linux-2.6.30-gentoo-x86_64-Intel-R-_Core-TM-2_Duo_CPU_E8400_@_3.00GHz-with-gentoo-2.0.1

Timestamp of tree: Sat, 11 Jul 2009 23:45:01 +0000                                                   

app-shells/bash:     4.0_p24                                                                         

dev-java/java-config: 2.1.8-r1                                                                       

dev-lang/python:     2.6.2-r1                                                                        

dev-util/cmake:      2.6.4                                                                           

sys-apps/baselayout: 2.0.1                                                                           

sys-apps/openrc:     0.4.3-r3                                                                        

sys-apps/sandbox:    2.0                                                                             

sys-devel/autoconf:  2.13, 2.63-r1                                                                   

sys-devel/automake:  1.5, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2, 1.10.2, 1.11                                 

sys-devel/binutils:  2.19.1-r1                                                                       

sys-devel/gcc-config: 1.4.1                                                                          

sys-devel/libtool:   2.2.6a                                                                          

virtual/os-headers:  2.6.30                                                                          

ACCEPT_KEYWORDS="amd64 ~amd64"                                                                       

CBUILD="x86_64-pc-linux-gnu"                                                                         

CFLAGS="-O2 -march=native -pipe -fomit-frame-pointer"                                                

CHOST="x86_64-pc-linux-gnu"                                                                          

CONFIG_PROTECT="/etc /usr/share/config"                                                              

CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php5/ext-active/ /etc/php/cgi-php5/ext-active/ /etc/php/cli-php5/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c /etc/udev/rules.d"                                                                                                      

CXXFLAGS="-O2 -march=native -pipe -fomit-frame-pointer"

DISTDIR="/usr/portage/distfiles"

FEATURES="distlocks fixpackages parallel-fetch preserve-libs protect-owned sandbox sfperms strict unmerge-orphans userfetch"

GENTOO_MIRRORS="http://ftp.uni-erlangen.de/pub/mirrors/gentoo http://mirror.cambrium.nl/pub/os/linux/gentoo/ http://ftp-stud.fht-esslingen.de/pub/Mirrors/gentoo/ http://distfiles.gentoo.org"

LANG="de_DE.UTF-8"

LDFLAGS="-Wl,-O1"

LINGUAS="en"

MAKEOPTS="-j1"

PKGDIR="/usr/portage/packages"

PORTAGE_CONFIGROOT="/"

PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"

PORTAGE_TMPDIR="/var/tmp"

PORTDIR="/usr/portage"

PORTDIR_OVERLAY="/usr/local/portage/layman/sunrise /usr/local/portage/layman/arcon /usr/local/portage"

SYNC="rsync://rsync5.de.gentoo.org/gentoo-portage"

USE="X a52 aac aalib acl acpi alsa amd64 apache2 apm ass audiofile avahi bash-completion berkdb blas bs2b bzip2 cairo cdinstall cdparanoia cdr cli cracklib crypt cups dbus dga dio directfb dri dts dv dvd dvdr dvdread encode fat fbcon ffmpeg firefox flash ftp gcj gdbm gif glitz glut gnuplot google-gadgets gpm graphviz gtk gtk2 gutenprint hal hddtemp htmlhandbook iconv icq imagemagick imap innodb ipv6 jack java java6 javascript jfs jikes jpeg jpeg2k kde kpathsea latex ldap libcaca libwww lm_sensors lyx mad matroska midi mime mmx mozbranding mozdevelop mp3 mp4 mpeg mplayer mudflap multilib musicbrainz mysql mysqli ncurses nls nocd nptl nptlonly nsplugin ntfs ocaml ogg openal opengl openmp oscar pam pcre pdf perl php plasma png posix ppds pppd python qt qt3support qt4 quicktime readline reflection reiserfs rtf samba scanner sdl session slang smp sndfile snmp speex spell spl sse sse2 sse3 ssl ssse3 svg symlink sysfs tcpd theora threads tidy tiff truetype unicode usb vcd videos vorbis webkit wifi wmf wxwindows x264 xcomposite xine xml xorg xosd xpm xscreensaver xv xvid zeroconf zlib" ALSA_CARDS="oxygen" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" ELIBC="glibc" FOO2ZJS_DEVICES="hp2600n" INPUT_DEVICES="evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="en" USERLAND="GNU" VIDEO_CARDS="radeon"

Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, FFLAGS, INSTALL_MASK, LC_ALL, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS

```

kernel config: http://pastebin.com/m31886e61

/var/log/dmesg (with working .30 kernel): http://pastebin.com/m6e88b8a1

----------

## NeddySeagoon

jmrk,

Tell us the commands you used to configure the new kernel please.

You are correct in your diagnosis that its not a grub issue. grub has done it job when the kernel gets control and begins to decompress itself. At that time there is only the kernel.

----------

## jmrk

 *Quote:*   

> Tell us the commands you used to configure the new kernel please.

 

well, in the first attempt: (with comments after the #)

```
emerge -avuDN world # this installed gentoo-sources-2.6.30-r2

cd /usr/src/linux # USE="symlink" is set, so this directory is correct

cp ../linux-`uname -r`/.config . # copy .config of currently running kernel

make oldconfig # no new options in this case (only minor rev bump)

make && make modules_install && cp arch/x86/boot/bzImage /boot/kernel-2.6.30-gentoo-r2

ln -sf /boot/kernel-2.6.30-gentoo-r2 /boot/kernel # my grub.conf always points to /boot/kernel
```

I always do my kernel updates like that (since 2.6.16 afair), and never experienced any problems.

Since that, I've tried (as I said in the original post) other configs, which I created by 

```
cd /usr/src/linux

make mrproper # return kernel sources to pristine condition, almost equivalent to 'make clean'

cp /path/to/new/.config .config # if applicable; I also tried default settings, i.e. no pre-existing config file

make menuconfig # enable drivers my hardware needs

make && make modules_install && cp arch/x86/boot/bzImage /boot/kernel-2.6.30-gentoo-r2
```

I can post the other configs, of course, but I don't think that would be much use, 

(1) because they're really just a pappy seed customized to my hardware (as described on pappy's website http://62.3.120.141/~pappy/working.html), and then the same done without a seed (using upstream default options)

(2) because the kernel config of my currently running 2.6.30 kernel really should work with 2.6.30-r[12] as well, but it doesn't (meaning resulting kernels won't boot).

But if you think otherwise I will post them.

 *Quote:*   

> You are correct in your diagnosis that its not a grub issue. grub has done it job when the kernel gets control

 

Yeah, well, I can't be positive that the kernel has received control, because I don't get any output. But if it was a grub issue, I guess older kernels wouldn't work either. 

 *Quote:*   

> begins to decompress itself

 

 :Idea:  maybe kernel decompression is broken; I could try one of the new compression algorithms... I stuck with the 'tried and true' gzip so far, but it's sure worth a try to choose bzip2.

----------

## NeddySeagoon

jmrk,

I'm using lmz compression and it just worked for me.  I did not try the others.

Your build steps are correct. I suspected that you skipped the make oldconfig step but its not the case.

----------

## krinn

 *NeddySeagoon wrote:*   

> 
> 
> Your build steps are correct

 

if /boot is already mount or not on another partition neddy  :Smile: 

Else it's again the "i install a kernel in /sda2/boot because i forgot to mount /sda1 in /sda2/boot"

----------

## krinn

 *jmrk wrote:*   

> 
> 
> cd /usr/src/linux # USE="symlink" is set, so this directory is correct
> 
> 

 

<eselect kernel list> could also help you do the symlink, or just to check

 *jmrk wrote:*   

> 
> 
> make menuconfig # enable drivers my hardware needs

 

more userfriendly <make gconfig> or <make xconfig>

Without blaming pappy's work, a simple <make allmodconfig> + the necessary steps to tune the kernel to your hardware is basically nearly the same (in my opinion, even better as you may don't know some modules your hardware could use).

It's slower to compile as a drawback.

 *jmrk wrote:*   

> make && make modules_install && cp arch/x86/boot/bzImage /boot/kernel-2.6.30-gentoo-r2

 

<make install> : kernel will copy itself to boot as vmlinuz-kernelversion, also renaming the old kernel if already present as <vmlinuz-kernelversion.old> and will also copy config-kernelversion (with .old support too) and System.map-kernelversion (also with a .old backup).

If you craft a grub entry with vmlinuz.kernelversion you will always load your latest kernel, but if you're smart you also have an entry in grub.lst for previous kernel pointing to vmzlinuz-kernelversion.old (it's really a good idea to keep an entry for an old kernel in case of trouble).

Without the troubles of 'course of a mistake you could done by cp arch/x86/boot/bzImage /bot/blabhlah (bot not boot = trouble...° (i mean typo mistake)

And to say the last: you don't even need to know where your kernel is, as make install will find the good one and do the job for you.

This is to be more constructive than the previous "you forget to mount /boot"  :Smile: 

----------

## jmrk

hey guys, 

good news first: I just booted a brand spanking new 2.6.30-r2 kernel  :Smile: 

Some more history:

- I tried bzip2 compression for the kernel image. Didn't help, same situation as before. I also tried disabling framebuffer support, didn't help either. 

- based on the assumption that somehow my toolchain was broken, I booted up Ubuntu and compiled my kernel from there. I then did a chroot in order to run "make modules_install". 

- the kernel compiled with Ubuntu's gcc/toolchain worked! 

- next, I tried to do the same thing again using Gentoo (which I strongly prefer; Ubuntu is only installed for testing purposes) - bingo! worked just as well!

Note that I didn't change the kernel config, so it's definite now that the config wasn't at fault. 

The big question remains: what was broken, and why did the problem suddenly disappear after two weeks of unsuccessful fiddling? Well, I'm not sure, but I'm guessing that 'env-update' as part of chrooting did the trick - it's the only thing that might have affected my toolchain. I'm surprised, though, that even after a complete re-emerge (emerge -e world) it's still necessary to do env-update manually, and AFAIR there was no elog message about this. 

 *NeddySeagoon wrote:*   

> I suspected that you skipped the make oldconfig step but its not the case.

 

During my first few months with gentoo, I did indeed skip 'make oldconfig' regularly (because I didn't know about it), but that never caused any problems. It's just more comfortable than using 'make menuconfig' and looking for changed/new options manually. Besides, when updating from foo to foo-r1, there shouldn't be any new options.

 *krinn wrote:*   

> if /boot is already mount or not on another partition neddy

 

/boot was mounted. I'm not a noob. Besides, if installing the kernel to /boot failed for whatever reason, I wouldn't have the problem that the newly installed kernel doesn't boot (because there wouldn't be any newly installed kernel). 

 *krinn wrote:*   

> <eselect kernel list> could also help you do the symlink, or just to check

 

Yeah, I know, but it's not faster than creating the symlink by hand (or, better yet, having it created automatically when installing the sources), and equally not faster than checking by hand using "l /usr/src/" (I have "l" aliased to "ls -Ahl")

 *krinn wrote:*   

> more userfriendly <make gconfig> or <make xconfig>

 

'make gconfig' doesn't work for me, complains about not being able to connect to display :0.0. I know about 'make xconfig', but I don't use it, because I'm happy with 'make menuconfig'  :Wink: 

 *krinn wrote:*   

> <make install> : kernel will copy itself to boot as vmlinuz-kernelversion, also renaming the old kernel if already present as <vmlinuz-kernelversion.old> and will also copy config-kernelversion (with .old support too) and System.map-kernelversion (also with a .old backup).

 

Good to know, I wasn't aware of how 'make install' works for kernels and therefore didn't use it (the official gentoo kernel upgrade guide recommends manual copying). Especially when something doesn't work, however, I still prefer to have manual control over every filename; but in the future I'll just use 'make install'. 

 *krinn wrote:*   

> If you craft a grub entry with vmlinuz.kernelversion you will always load your latest kernel, 

 

True, but I still like to have the grub entry point to an eternally constant filename like "kernel" which is a symlink to the kernel image that I want to use. I find it easier to update a symlink than grub's config file. 

 *krinn wrote:*   

> but if you're smart you also have an entry in grub.lst for previous kernel pointing to vmzlinuz-kernelversion.old (it's really a good idea to keep an entry for an old kernel in case of trouble).

 

Yep, I've been doing that for ages. On the other hand, non-booting kernels are rare (at least in my experience), and in that case you can always press 'c' in grub to get a command line where you can specify which kernel to boot. 

 *krinn wrote:*   

> Without the troubles of 'course of a mistake you could done by cp arch/x86/boot/bzImage /bot/blabhlah (bot not boot = trouble...° (i mean typo mistake)

 

tab completion rocks! Firstly, it saves you some typing effort; secondly, it prevents typos  :Smile: 

Anyway, thanks a lot for your support, both of you! The Gentoo learning experience never ends...

----------

