Linux Kernel cross compilation recipe on amd64 for i386 on Debian

  • Article Currently 3.31/5
  • 1
  • 2
  • 3
  • 4
  • 5

 Rating : 3.3/5 (13 votes cast)

Following my Linux Kernel compilation recipe on Debian here is another tip on how to cross compil a kernel on an amd64 machine for an i386 one.
 ##install necessary packages 
iman@debian:~$ sudo apt-get install libncurses5 libncurses5-dev libssl-dev kernel-package fakeroot build-essential util-linux
##get kernel 3.19.3
iman@debian:~$ wget

iman@debian:~$ tar -xvf linux-3.19.3.tar.xz
iman@debian:~$ cd linux-3.19.3

##config-3.16.0-4-686-pae is Debian config file from its current kernel (available in the distribution linux-image .deb)
iman@debian:~/linux-3.19.3$ cp ~/config-3.16.0-4-686-pae .config && yes "" | linux32 make oldconfig

##optional : configure kernel
#iman@debian:~/linux-3.19.3$ make menuconfig
##if not first compilation
#iman@debian:~/linux-3.19.3$ make-kpkg clean

##set compil at full speed
iman@debian:~/linux-3.19.3$ export CONCURRENCY_LEVEL=`grep "cpu cores" /proc/cpuinfo | head -1 | cut -d":" -f2 | cut -c2-`
##compil kernel image and kernel headers (headers are optional)
iman@debian:~/linux-3.19.3$ fakeroot linux32 make-kpkg --cross-compile - --arch=i386 --initrd --revision=1+i --append-to-version=-`date +%Y%m%d` kernel-image kernel-headers

##at this point you have a 32bit kernel inside a linux-image-3.19.3-20150326_1+i_amd64.deb package and headers in linux-headers-3.19.3-20150326_1+i_amd64.deb but both labeled for 64bit arch

##let's label it i386
iman@debian:~/linux-3.19.3$ cd ..
iman@debian:~$ mkdir linux-image-3.19.3-20150326_1+i_i386 && cd linux-image-3.19.3-20150326_1+i_i386
##extract .deb
iman@debian:~/linux-image-3.19.3-20150326_1+i_i386$ ar x ../linux-image-3.19.3-20150326_1+i_amd64.deb
##extract control.tar.gz & data.tar.xz
iman@debian:~/linux-image-3.19.3-20150326_1+i_i386$ mkdir DEBIAN && tar xf control.tar.gz -C DEBIAN && rm control.tar.gz
iman@debian:~/linux-image-3.19.3-20150326_1+i_i386$ tar xf data.tar.xz && rm data.tar.xz
iman@debian:~/linux-image-3.19.3-20150326_1+i_i386$ rm debian-binary

##edit DEBIAN/control and replace "Architecture: amd64" by "Architecture: i386"
iman@debian:~/linux-image-3.19.3-20150326_1+i_i386$ sed -i 's/Architecture: amd64/Architecture: i386/g' DEBIAN/control
cd ..

##repackage the modified .deb
iman@debian:~$ dpkg-deb -b linux-image-3.19.3-20150326_1+i_i386
##now you've got your linux-image-3.19.3-20150326_1+i_i386.deb
##same method applies for linux-headers-3.19.3-20150326_1+i_amd64.deb

##copy .deb to your 32bit machine and install :
iman@msiwind:~$ sudo dpkg -i linux-image-3.19.3-20150326_1+i_i386.deb linux-headers-3.19.3-20150326_1+i_i386.deb

##reboot then :
iman@msiwind:~$ uname -a
Linux msiwind 3.19.3-20150326 #1 SMP Thu Mar 26 20:10:01 CET 2015 i686 GNU/Linux

ThnxX :


  • Article Currently 2.90/5
  • 1
  • 2
  • 3
  • 4
  • 5

 Rating : 2.9/5 (21 votes cast)

DATE : 2013
DESCRiPTiON : Russ D reggae selections a.k.a. Disciples Broadcasts Archives

  • PHP (stream, archives, administration)
  • HTML
  • JavaScript
  • TODO : sampler + shoutbox
  • MySQL database interface
  • maintenance.