# [SOLVED PEBKAC] invalid magic number - unable to boot kernel

## Veldrin

Hi everyone,

I am not exactly sure, what changed, but any recently built kernel will not boot. Grub gives the following error:

```
error: invalid magic number

error: you need to load the kernel first

Press any key to continue ...
```

I recently did a gcc upgrade (4.6.1 -> 4.6.2), but also more recently rebuilt the entire toolchain. 

Even rebuilding the exact same config of the working kernel, causes the error. 

I am not sure if this is related, but at that time I was first aware of this issue (I had not rebooted the system after a week's worth of updates), I also had a udev error (udev been unable to start), which had been resolved by a udev rebuild.

tested kernel is 3.1.0-gentoo and 3.1.0-vanilla. 

system is fully ~amd64 (but using gcc-4.6.2), using genkernel to build my kernels (especially due to the initramfs).

any hints, on where to look further.

V.

PS. I you need more information, or details just ask - I am not quite sure where to start, and don't want to spam the forum with useless information.

----------

## Hu

What version of sys-devel/binutils are you using?  Has it changed recently?  If you use gcc-config to switch to a gcc 4.5.x, can you build working kernels?

----------

## Veldrin

binutils-2.21.1-r1 since several weeks. and not recent 'minor' gcc upgrade, only the 4.6.1 to 4.6.2 upgrade.

I'll reinstall gcc:4.5 from tinderbox to verify that. Just give me 30 mins.

I cloned the system from my previous one, switching from cflags core2 to native (implicitly corei7-avx), but I haven't done a complete rebuild (yet).

What I forgot to mention, the system in running on a hardened profile.

V.

----------

## Veldrin

nope - same error with gcc-4.5.3 (from tinderbox).

I posted the emerge --info for reference. 

graphite, ppl and -floop-interchange -floop-strip-mine -floop-block have been in use for some time (3 months?)

To give you a loose timeline: 

* the last working kernel has been built on Oct. 27th. 

* gcc-4.6.2 upgrade was on the Nov.1st. 

* since then I did at least a complete kde upgrade without hickup. 

* boot issues were noticed around 3rd or 4th Nov. 

Meanwhile, I rebuild the system set. I am not sure, if that weird udev issue I had I related, and that way I can excluded any corrupted package. 

I only remember vaguely the constellation, I was primarily concerned to get the system booting again. IIRC the 'new' kernel was not booting (showing the mentioned grub error) and the old one would barely boot as udev would not start. rebuilding udev 'fixed' that. But I never properly investigated the issue. 

```
root@belshirash ~ # emi

Portage 2.2.0_alpha72 (hardened/linux/amd64/desktop, gcc-4.6.2, glibc-2.13-r4, 3.1.0-gentoo x86_64)

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

System uname: Linux-3.1.0-gentoo-x86_64-Intel-R-_Core-TM-_i7-2620M_CPU_@_2.70GHz-with-gentoo-2.1

Timestamp of tree: Sun, 06 Nov 2011 23:45:01 +0000

app-shells/bash:          4.2_p10

dev-java/java-config:     2.1.11-r3

dev-lang/python:          2.7.2-r3, 3.2.2

dev-util/cmake:           2.8.6-r3

dev-util/pkgconfig:       0.26

sys-apps/baselayout:      2.1

sys-apps/openrc:          0.9.4

sys-apps/sandbox:         2.5

sys-devel/autoconf:       2.13, 2.68

sys-devel/automake:       1.11.1-r1

sys-devel/binutils:       2.21.1-r1

sys-devel/gcc:            4.5.3-r1, 4.6.2

sys-devel/gcc-config:     1.4.1-r1

sys-devel/libtool:        2.4-r4

sys-devel/make:           3.82-r3

sys-kernel/linux-headers: 2.6.39 (virtual/os-headers)

sys-libs/glibc:           2.13-r4

Repositories: gentoo kde local

Installed sets: @kde-4.7, @kdeaccessibility-4.7, @kdeadmin-4.7, @kdeartwork-4.7, @kdebase-4.7, @kdeedu-4.7, @kdegames-4.7, @kdegraphics-4.7, @kdelibs-4.7, @kdemultimedia-4.7, @kdenetwork-4.7, @kdepim-4.7, @kdetoys-4.7, @kdeutils-4.7, @system

ACCEPT_KEYWORDS="amd64 ~amd64"

ACCEPT_LICENSE="* -@EULA"

CBUILD="x86_64-pc-linux-gnu"

CFLAGS="-march=native -O2 -pipe -floop-interchange -floop-strip-mine -floop-block"

CHOST="x86_64-pc-linux-gnu"

CONFIG_PROTECT="/etc /usr/share/config /usr/share/gnupg/qualified.txt /usr/share/openvpn/easy-rsa"

CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"

CXXFLAGS="-march=native -O2 -pipe -floop-interchange -floop-strip-mine -floop-block"

DISTDIR="/usr/portage/distfiles"

EMERGE_DEFAULT_OPTS="--misspell-suggestions=n"

FEATURES="assume-digests binpkg-logs distlocks ebuild-locks fixlafiles news parallel-fetch preserve-libs protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch usersandbox usersync"

FFLAGS=""

GENTOO_MIRRORS="http://sunsite.cnlab-switch.ch/mirror/gentoo/  http://www.ibiblio.org/pub/Linux/distributions/gentoo"

LANG="en_US.UTF-8"

LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,--sort-common -Wl,-z,relro -Wl,-z,now"

LINGUAS="en en_US"

MAKEOPTS="-j5"

PKGDIR="/usr/portage/packages"

PORTAGE_COMPRESS="xz"

PORTAGE_COMPRESS_FLAGS="--extreme"

PORTAGE_CONFIGROOT="/"

PORTAGE_RSYNC_EXTRA_OPTS="--exclude=/.snapshot --exclude=/lost+found"

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="/var/lib/layman/kde /usr/local/portage"

SYNC="rsync://blakharaz.schlumberger.soho/gentoo-portage"

USE="X a52 aac acl acpi alsa amd64 bash-completion berkdb bluetooth branding bzip2 cairo caps cli consolekit cracklib crypt cups cxx dbus dri dts dvd emboss encode exif expat fam ffmpeg fftw firefox flac gdbm gdu gif gpm gstreamer handbook hardened iconv icu idn ipv6 jpeg justify kde kerberos lcms ldap libedit libnotify logrotate lzma mad mmx mng modules mp3 mp4 mpeg mpi mudflap multilib mysql ncurses nls nptl nptlonly ogg openexr opengl openmp pam pango pax_kernel pcre pdf png policykit ppds pppd pulseaudio qt3support qt4 sdl semantic-desktop session smp spell sqlite sse sse2 ssl svg sysfs syslog tcpd theora threads tiff truetype udev unicode urandom usb v4l v4l2 vim-syntax vorbis x264 xattr xcb xml xorg xulrunner xv xvid zeroconf zlib" ALSA_CARDS="hda-intel" 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 cgi cgid 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" CALLIGRA_FEATURES="kexi words flow plan stage tables krita karbon braindump" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ubx" GRUB_PLATFORMS="efi-64 pc" INPUT_DEVICES="evdev synaptics" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="en en_US" PHP_TARGETS="php5-3" RUBY_TARGETS="ruby18" USERLAND="GNU" VIDEO_CARDS="intel vesa v4l v4l2" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"

Unset:  CPPFLAGS, CTARGET, INSTALL_MASK, LC_ALL, PORTAGE_BUNZIP2_COMMAND
```

V.

----------

## Veldrin

could someone please shoot me - not once, twice....

just some excerpt from my bash history...

```
  466  cd /boot/

  467  cp kernel-genkernel-x86_64-3.1.0 efi/efi/linux-3.1.0-1

  468  cp initramfs-genkernel-x86_64-3.1.0 efi/efi/linux-3.1.0-1

  469  cp System.map-genkernel-x86_64-3.1.0 efi/efi/System.map 

  470  cp /usr/src/linux/.config efi/efi/config-3.1.0-1
```

V.

Sorry for the noise.

----------

