# Genkernel: Deriving ${KERNEL_SOURCE_DIR} failed [SOLVED]

## Illiander

Not sure if I should post this here or in "Portage and Programming"

I'm changing hardware out underneath my gentoo install (same processor family) and I'm having issues with genkernel.

My old kernel doesn't seem to be recognising the keyboard off the new motherboard, so I figure all I need to do is boot off a liveCD, chroot into my old system, and recompile my kernel.

So I boot, mount everything, chroot in, and run genkernel, and I get this error message:

```
ERROR: Deriving ${KERNEL_SOURCE_DIR} failed
```

What's going wrong?Last edited by Illiander on Sun Oct 05, 2014 4:38 pm; edited 1 time in total

----------

## DONAHUE

from chroot:

```
eselect kernel list

ls -l /usr/src
```

is /usr/src/linux symlink present and valid?

----------

## Illiander

kernel 3.14.14 is installed and selected.

ls -l crashes me out of the chroot with the message "Illegal Instruction", but running the same test from the un-chrooted environment shows that the link is pointing in the right place.

----------

## Roman_Gruber

did you switch from amd => intel or intel => amd?

it may help when you post your old make.conf before changing your cpus and post new and old cpu here.

you may have a newer cpu which does not support the instructions of the previous cpu.

if you only want to build a kernel, you could build it anywhere and move it to the boot partition. you do notneed to build it in the gentoo chroot at all. you may also take the kernel from the livecd and boot from it into your chroot (that should be possible too)..

----------

## Illiander

Both machines are AMD.

The new machine may actually be older hardware (my previous hardware died, this is a patchwork rig to keep me going until the proper replacement finds it's way through the mail in a few weeks)

Old Machine: AMD Phenom II (x6)

New Machine: AMD Athlon 64 (x2)

old make.conf:

```
# These settings were set by the catalyst build script that automatically

# built this stage.

# Please consult /usr/share/portage/config/make.conf.example for a more

# detailed example.

#CFLAGS="-O2 -march=native"

CFLAGS="-O2 -pipe -march=native"

CXXFLAGS="${CFLAGS}"

# WARNING: Changing your CHOST is not something that should be done lightly.

# Please consult http://www.gentoo.org/doc/en/change-chost.xml before changing.

CHOST="x86_64-pc-linux-gnu"

# These are the USE flags that were used in addition to what is provided by the

# profile used for building.

USE="-kde -qt4 mmx sse sse2 X a52 aac aalib acl acpi aim alsa apache2 apm atm audiofile bash-completion bidi bindist bluetooth bzip cairo canna caps cdda cddb cdinstall cdparanoia cdr cjk cgi crypt css ctype cups cvs cxx dbus dbx dga djvu dri dv dvb dvd dvdr emacs encode enscript esd evo examples exif expat fbcon ffmpeg flac flatfile fltk freetds freewnn fontconfig ftp gcj gd gdbm geoip gif gimp glut glib -gnome gnome-keyring gnuplot gps gsm gstreamer gtk gtkhtml hal hardened hddtemp icq idn ieee1394 imagemagic imap ipv6 jabber java java6 javascript jingle joystick jpeg jpeg2k kerberos lame latex ldap libwww lirc lm_sensors lua lzo mate mad mailwrapper matroska matrox migemo mikimod mime mmap mng -mono mp3 mp4 mpeg msn mtp mule multilib musepack musicbrainz mysql mysqli nas ncurses nntp nocd nsplugin offensive ogg openal openexr opengl openmp oscar pcre pdf perl php png portaudio python qmail-spp raw readline rss ruby samba sasl scanner sdl seamonkey firefox sharedext sharedmem shorten simplexml smp sockets socks5 source sox speex spell ssl startup-notification subversion svg svga symlink tcl tcpd theora tiff tokenizer truetype unicode usb v4l v4l2 vcd videos vorbis wavpack win32codecs wmf wxwidgets xine libdvdread libdvdcss xinerama xml xosd xmp xscreensaver xv xvid yahoo zeroconf zlib zsh-completion quicktime real gif jpeg mpeg matroska xanim png tiff svg a52 aac exif mp3 ogg vorbis theora xpm wmf win32codecs x264 flac postscript xvid mad mp2 divx encode apache2 php mysql unicode ssl crypt ctype pcre session pulseaudio -systemd"

#MAKEOPTS="-j1"

MAKEOPTS="-j4"

GENTOO_MIRRORS="rsync://ftp.df.lth.se/pub/gentoo/ ftp://gd.tuwien.ac.at/opsys/linux/gentoo/ rsync://de-mirror.org/gentoo/"

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

INSTALL_MASK="${INSTALL_MASK} /usr/lib/systemd"

VIDEO_CARDS="nvidia noveau vesa"

INPUT_DEVICES="evdev keyboard mouse"

ACCEPT_LICENSE="* -@EULA NVIDIA"

# If you have >=app-portage/layman-1.3.0

source "/var/lib/layman/make.conf"

# Set PORTDIR for backward compatibility with various tools:

#   gentoo-bashcomp - bug #478444

#   euse - bug #474574

#   euses and ufed - bug #478318

PORTDIR="/usr/portage"

FEATURES="splitdebug"

source /var/lib/layman/make.conf

```

Edit:

I also tried going through the steps for manually building a kernel, and "make oldconfig" also drops me out of the chroot with an "Illegal instruction" message

Edit2:

Or I could try working this through from another direction: When I try to run my system now, I get the following errors at the end of the boot process (plus some about alsactrl not finding stuff farther up, but they scroll off the top of my screen too fast to make out much more than that):

```
 * Starting local

INIT: Id "c6" respawning too fast: disabled for 5 minutes

INIT: Id "c1" respawning too fast: disabled for 5 minutes

INIT: Id "c2" respawning too fast: disabled for 5 minutes

INIT: Id "c3" respawning too fast: disabled for 5 minutes

INIT: Id "c5" respawning too fast: disabled for 5 minutes

INIT: Id "c4" respawning too fast: disabled for 5 minutes

INIT: no more processes left in this runlevel
```

I'm currently assuming that this is because I was on a 6-core machine, and now I'm on a 2-core machine. But if there's something else going on, I'm all ears.

----------

## Illiander

And I tried building kernels from the liveCD, both 3.14.14 (what I was running) and the one on the livecd (2.something).

Neither of those work either.

----------

## Illiander

On the liveCD, -nofb kernels shouldn't start kdm, right?

----------

## DONAHUE

"illegal instruction" means you are telling the cpu to do something it cannot do. Appears that code compiled for a Phenom II is attempting to execute on an Athlon X64

 *Quote:*   

> * Starting local 
> 
> INIT: Id "c6" respawning too fast: disabled for 5 minutes 
> 
> INIT: Id "c1" respawning too fast: disabled for 5 minutes 
> ...

  is probably occurring because the handbook says  *Quote:*   

>  If you need serial console access (which is possible in case of remote servers), you might need to uncomment the serial console section in /etc/inittab if it has not been done already automatically.
> 
> Code Listing 4.2: Editing /etc/inittab
> 
> # nano -w /etc/inittab
> ...

  and it seemed like a good idea

----------

## Illiander

ok, so portage isn't likeing the older processor either (I tried rebuilding GCC in prep for rebuilding @system, and it hung before calling gcc) So I guess I'm going to be rebuilding from a stage3 tarball.

What files do you recommend I grab before overwriting the drive, and would you recomend overwriting or wiping and starting over?

Files I've already grabbed: make.conf, world, and my portage overrides folder ( /etc/portage/package.* )

----------

## DONAHUE

get /home also

the easier way to avoid losing something you may want is described by Neddy Seagoon here: https://forums.gentoo.org/viewtopic-p-7601832.html#7601832

basically a chroot with a stage 3 and portage with a binpkg directory populated by using quickpkg then use the binpkg directory with the old install to rebuild system

----------

## Illiander

/home is on a seperate hdd that I'm not mounting until I have a working system. (I've done that for as long as I can remember, makes things *so* much safer)

Thanks for that link, that looks like exactly what I was asking for.

----------

## Illiander

ok, that seems to have gotten me farther, or it's not working at all (not sure which)

emerge -k portage and gcc seem to work, but glibc is complaining about nonfatal() not existing at the EAPI level being used (*after* the emerge -k portage and gcc goes through)

And trying to emerge glibc with the binary gcc and portage crashes out complaining about "configure: error: linker with -z relro support required" which doesn't show up anything useful with google.

Also, after rebuilding nano in the rescue chroot, quickpkg-ing it, and installing the binary to my main system, it's still crashing out with an "Illegal Instruction" message, but *only* in /mnt/gentoo, not /mnt/gentoo/home/rescue. ("gcc --help" is doing the same, which is tending me towards the "not done anything at all" side)

What am I missing here?

----------

## DONAHUE

Dependencies still have phenom instructions. 

I would revert to profile 1 (if I could), quickpackage world,  emerge -e --usepkg system, emerge -e --usepkg world

then increment back to the desired profile.

when frustration tolerance level is reached revert to plan a.

this has to be at least as annoying as trying to update a couple of year old system (in fact updating old may be complicating the problem).

----------

## Illiander

Frustration tolerence has definitely been reached. root wiped and starting a fresh install.

How robust is portage in handling the world file? (Will I need to do a manual merge of everything, or can I just dump my old one at the end of the new one and "emerge @world" will handle everything? (I might do a manual merge anyway, it's as good a time as any to clean it up, but it would be good to know))

---

Please tell me that newer processors are backwards compatible, so I don't need to do this all again in a couple of weeks.

----------

## DONAHUE

just gut feeling, but I'd favor diff or meld world file versus backup world file, try to segregate accidental  world packages (should have used emerge -1 but didn't), and then manual emerge.

----------

## Illiander

ok, that's me back up and running on the temp machine. I ended up doing a manual merge, this was my first gentoo install (lasted me ~5 years before the hardware died), and I forgot the --oneshot flag a *lot* early on., so most of my world file was extrainious.

Thank you everyone for all the help, it was very much appreciated.

Advice for anyone else finding this thread and needing to move to an older processor: Just grab world, package.* make.conf, /home and anything else you need, and rebuild everything from a stage3 tarball.  It will save you a lot of time and frustration.

----------

