[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: error: code model 'kernel' not supported in the 32 bit mode

saf wrote:

I tried to compile a Linux kernel in 64 bits mode.

From old version of FAQ:


*Crosscompiling a 64bit kernel on a 32bit host*

In order to get full advantage of the x86_64 architecture, you need to build a kernel which supports the 64bit extensions.

You should use the latest 2.6 kernel, since the amd64 support is much better than in the 2.4 series.

You may not want to use the debian kernel, since support for the widely-used tigon3 based network interfaces (some 3Com 940s, Broadcom 57xx) has been dropped by the debian kernel maintainer, but this depends on which mainboard and network interface card you are going to install.

*Installing the woody chroot*

Since the cross-compile packages on alioth are built from old Sarge versions, you need to install a woody chroot first. Note that you need woody and not Sarge, because the biarch packages are based on an old Sarge version no longer in the archive. As a result, you will not be able to install the alioth biarch packages into an actual testing or unstable chroot. Upgrading an already installed biarch chroot to unstable or testing will "upgrade" the toolchain to a non-biarch version at least, if not render your chroot entirely unusable.

Follow the instructions found at Debian Reference Manual 8.6.33 or the (c)debootstrap documentation for a complete explanation of how to set up a chroot environment.

In short:

*  mkdir /chroot-woody ;
cdebootstrap woody /chroot-woody http://ftp.de.debian.org/debian

* cp /etc/resolv.conf /etc/hostname /chroot-woody/etc/

* chroot /chroot-woody

* mount -t proc proc /proc

* unset LC_CTYPE ; base-config

Installing the cross-compile environment

* add
deb http://debian-amd64.alioth.debian.org/biarch/ sarge main
to your /etc/apt/sources.list which should already point to woody.

* run
apt-get update ; apt-get install libc6 libc6-dev lib64c6
lib64c6-dev libncurses5 libncurses5-dev \
lib64ncurses5 lib64ncurses5-dev gcc gcc-3.3 g++-3.3 patch make
devscripts dpkg-dev wget bzip2

* wget the latest 2.6 kernel from http://www.kernel.org/ and untar it
to /usr/src, or wherever you usually build your kernels.

*The gcc wrapper*

You need to get a gcc wrapper in order to crosscompile on a i386 host.
This wrapper is found at
You can simply delete the /usr/bin/gcc symlink and move the wrapper
there. Configuring the kernel

make HOSTCC="gcc -m32" ARCH="x86_64" menuconfig

Be sure to include IA32 emulation, otherwise you will not be able to run multiarch or i386 binaries on your host system or in a chroot. And for simplicity, build a monolithic kernel without any modules.

make HOSTCC="gcc -m32" ARCH="x86_64" bzImage

If everything goes well, you will end up with the following message:

Kernel: arch/x86_64/boot/bzImage is ready

You can now install the kernel as usual. Keep your old 32bit kernel in the lilo/grub configuration, so you can switch back if something went wrong. Be sure to load the initrd only with your old debian-installer kernel, if you installed that way. If everything goes well, you will be running a 32bit userland with a 64bit kernel, and can proceed with the installation of pure64 if you want to.


Reply to: