Difference between revisions of "Vnx-rootfs-uml-kernel"

From VNX
Jump to: navigation, search
(Creating a Linux 3.X kernel)
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
{{Title|How to create a User-Mode-Linux Kernel for VNX}}
 
{{Title|How to create a User-Mode-Linux Kernel for VNX}}
  
This document describes how to create a 32 bits UML kernel to be used with VNX. The procedure has been mainly tested for version 3.3.8, although it should work sith minor changes with previous 3.X versions (it does not with 3.4 version).
+
== Creating a Linux 3.X kernel ==
 +
 
 +
This document describes how to create a 32 bits UML kernel to be used with VNX. The procedure has been mainly tested for version 3.3.8, although it should work with minor changes with previous 3.X versions (it does not with 3.4 version).
  
 
This procedure has been tested over a system with Ubuntu 10.04.4 32 bits. Although the procedure should work over a 64 bits system (installing gcc-multilib and using the SUBARCH variable should do the work), we had some problems trying to compile the 32 bits kernel over a 64 bits system (mainly when linking some libraries, for example, VDE ones).
 
This procedure has been tested over a system with Ubuntu 10.04.4 32 bits. Although the procedure should work over a 64 bits system (installing gcc-multilib and using the SUBARCH variable should do the work), we had some problems trying to compile the 32 bits kernel over a 64 bits system (mainly when linking some libraries, for example, VDE ones).
Line 10: Line 12:
 
  tar xfvz linux-3.3.8.tar.gz
 
  tar xfvz linux-3.3.8.tar.gz
 
  cd linux-3.3.8
 
  cd linux-3.3.8
<li>Download mconsole exec kernel patch:</li>
+
<li>'''NOTE: mconsole exec patch does not work properly. Do not apply it.''' Download mconsole exec kernel patch:</li>
  wget vnx.dit.upm.es/vnx/kernels/mconsole-exec-3.3.8.patch
+
  wget http://vnx.dit.upm.es/vnx/kernels/mconsole-exec-3.3.8.patch
 
<li>Apply mconsole-exec patch:</li>
 
<li>Apply mconsole-exec patch:</li>
 
  patch -p1 < mconsole-exec-3.3.8.patch
 
  patch -p1 < mconsole-exec-3.3.8.patch
Line 40: Line 42:
 
  cd ..
 
  cd ..
 
  tar cfvz linux-um-3.3.8.tgz linux-um-3.3.8-src
 
  tar cfvz linux-um-3.3.8.tgz linux-um-3.3.8-src
 +
</ul>
 +
 +
== Compiling old Linux 2.6.28 kernel ==
 +
 +
Recipe contributed by Markus Gegenfurtner (mgegenfu at hm.edu, mgegenfurtner at gmail.com)
 +
 +
Global Requirments:
 +
gcc-4.4 or below (using gcc-4.5 or higher will not work)
 +
libc6-dev-i386
 +
ncurses-dev
 +
 +
Requirements for 64bit Hostsystem build a 32bit kernel:
 +
gcc-4.4-multilib
 +
 +
This is the receipt for building the 32bit Kernel on a 64bit Machine
 +
(this is not verbatim from actually executed commands, so be careful with possible typos!)
 +
<ul>
 +
<li>Download an untar vanilla kernel:</li>
 +
cd /usr/local/src
 +
wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.28.10.tar.bz2
 +
tar xfj linux-2.6.28.10.tar.bz2
 +
cd linux-2.6.28.10
 +
 +
<li>Apply the mconsole patch (can be get from http://wiki.strongswan.org/repositories/changes/strongswan/src/dumm/patches/mconsole-exec-2.6.28.patch)</li>
 +
patch -p1 < mconsole-exec-2.6.28.patch
 +
 +
<li>Configure (based on the previous UML kernel, if you are using a 32bit Host you can leave the SUBARCH command):</li>
 +
/usr/share/vnx/kernels/linux-2.6.18.10-1m --showconfig > .config
 +
vi .config (and set CONFIG_LOCALVERSION="-Xm")
 +
make menuconfig ARCH=um SUBARCH=i386 CC=gcc-4.4
 +
# Select "Load Other Config"
 +
# Load .config
 +
# Edit Kernel using menu as you need
 +
# Exit and save
 +
 +
<li>Make the kernel:</li>
 +
nano arch/um/os-Linux/mem.c
 +
add "#include <sys/stat.h>" to the Header (e.g. after #include <sys/param.h>)
 +
make ARCH=um SUBARCH=i386 CC=gcc-4.4
 +
strip linux
 +
 +
<li>Add Modules to UML rootfs:</li>
 +
mkdir /mnt/uml/
 +
mount  /usr/share/vnx/filesystems/vnx_rootfs_uml-debian-6.0-v022 /mnt/uml/ -o loop
 +
make modules_install ARCH=um SUBARCH=i386 CC=gcc-4.4 INSTALL_MOD_PATH=/mnt/uml/
 +
ls /mnt/uml/lib/modules -> There should be a folder called: 2.6.28.10-Xm according to you CONFIG_LOCALVERSION
 +
umount /mnt/uml/
 +
rm -rf /mnt/uml/
 +
 +
<li>Make the modules tar:</li>
 +
make modules_install ARCH=um SUBARCH=i386 CC=gcc-4.4
 +
cd /lib/modules/
 +
tar cfv modules-2.6.28.10-Xm.tar 2.6.28.10-Xm/
 +
rm -rf /lib/modules/2.6.28.10-Xm (you don't need the modules in the host)
 +
 +
<li>Put the modules and the kernel where you want (for example, /usr/share/vnx/kernels)</li>
 +
mv /lib/modules/modules-2.6.28.10-Xm.tar /usr/share/vnx/kernels
 +
cp /usr/local/src/linux-2.6.28.10/linux /usr/share/vnx/kernels/linux-2.6.28.10-Xm
 +
cp /usr/local/src/linux-2.6.28.10/.config /usr/share/vnx/kernels/config-2.6.28.10-Xm
 +
 +
<li>Testing the Kernel without VNX (better debugging):</li>
 +
cd /usr/share/vnx/kernels/
 +
./linux-2.6.28.10-Xm ubda=/usr/share/vnx/filesystems/vnx_rootfs_uml-debian-6.0-v022 mem=256M
 +
# Check out for errors
 
</ul>
 
</ul>

Latest revision as of 23:11, 26 November 2012

How to create a User-Mode-Linux Kernel for VNX

Creating a Linux 3.X kernel

This document describes how to create a 32 bits UML kernel to be used with VNX. The procedure has been mainly tested for version 3.3.8, although it should work with minor changes with previous 3.X versions (it does not with 3.4 version).

This procedure has been tested over a system with Ubuntu 10.04.4 32 bits. Although the procedure should work over a 64 bits system (installing gcc-multilib and using the SUBARCH variable should do the work), we had some problems trying to compile the 32 bits kernel over a 64 bits system (mainly when linking some libraries, for example, VDE ones).

  • Download and uncompress kernel sources:
  • wget http://www.kernel.org/pub/linux/kernel/v3.x/linux-3.3.8.tar.gz
    tar xfvz linux-3.3.8.tar.gz
    cd linux-3.3.8
    
  • NOTE: mconsole exec patch does not work properly. Do not apply it. Download mconsole exec kernel patch:
  • wget http://vnx.dit.upm.es/vnx/kernels/mconsole-exec-3.3.8.patch
    
  • Apply mconsole-exec patch:
  • patch -p1 < mconsole-exec-3.3.8.patch
    
  • Configure kernel options (do not forget to enable support in kernel for ISO9660 and EXT4 file system format support):
  • make defconfig ARCH=um SUBARCH=i386
    make menuconfig ARCH=um SUBARCH=i386
    
  • Compile the kernel
  • make ARCH=um SUBARCH=i386
    strip linux
    
  • Check the kernel having a look at the version and options:
  • ./linux --version
    ./linux --showconfig
    
  • Or, better, starting a virtual machine with that kernel:
  • ./linux ubda=rootfs mem=128M
    

    Note: change 'rootfs' by the root filesystem filename you will use to test the kernel.

  • Optionally, if you want to create a tar file with the kernel, modules and config file for distribution:
  • mkdir linux-um-3.3.8-src
    cp linux linux-um-3.3.8-src/linux-um-3.3.8
    mkdir linux-um-3.3.8-src/modules
    make modules_install INSTALL_MOD_PATH=linux-um-3.3.8-src/modules/ ARCH=um SUBARCH=i386
    cd linux-um-3.3.8-src/modules/lib/modules/
    tar cfv modules-3.3.8.tar 3.3.8
    mv modules-3.3.8.tar ../../../
    cd ../../../
    rm -rf modules
    vi README-linux-um-3.3.8
    cp ../.config config-linux-um-3.3.8
    cd ..
    tar cfvz linux-um-3.3.8.tgz linux-um-3.3.8-src
    

Compiling old Linux 2.6.28 kernel

Recipe contributed by Markus Gegenfurtner (mgegenfu at hm.edu, mgegenfurtner at gmail.com)

Global Requirments: gcc-4.4 or below (using gcc-4.5 or higher will not work) libc6-dev-i386 ncurses-dev

Requirements for 64bit Hostsystem build a 32bit kernel: gcc-4.4-multilib

This is the receipt for building the 32bit Kernel on a 64bit Machine (this is not verbatim from actually executed commands, so be careful with possible typos!)

  • Download an untar vanilla kernel:
  • cd /usr/local/src
    wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.28.10.tar.bz2
    tar xfj linux-2.6.28.10.tar.bz2
    cd linux-2.6.28.10
    
  • Apply the mconsole patch (can be get from http://wiki.strongswan.org/repositories/changes/strongswan/src/dumm/patches/mconsole-exec-2.6.28.patch)
  • patch -p1 < mconsole-exec-2.6.28.patch
    
  • Configure (based on the previous UML kernel, if you are using a 32bit Host you can leave the SUBARCH command):
  • /usr/share/vnx/kernels/linux-2.6.18.10-1m --showconfig > .config
    vi .config (and set CONFIG_LOCALVERSION="-Xm")
    make menuconfig ARCH=um SUBARCH=i386 CC=gcc-4.4
    # Select "Load Other Config"
    # Load .config
    # Edit Kernel using menu as you need
    # Exit and save
    
  • Make the kernel:
  • nano arch/um/os-Linux/mem.c 
    add "#include <sys/stat.h>" to the Header (e.g. after #include <sys/param.h>)
    make ARCH=um SUBARCH=i386 CC=gcc-4.4
    strip linux
    
  • Add Modules to UML rootfs:
  • mkdir /mnt/uml/
    mount  /usr/share/vnx/filesystems/vnx_rootfs_uml-debian-6.0-v022 /mnt/uml/ -o loop
    make modules_install ARCH=um SUBARCH=i386 CC=gcc-4.4 INSTALL_MOD_PATH=/mnt/uml/
    ls /mnt/uml/lib/modules -> There should be a folder called: 2.6.28.10-Xm according to you CONFIG_LOCALVERSION
    umount /mnt/uml/
    rm -rf /mnt/uml/
    
  • Make the modules tar:
  • make modules_install ARCH=um SUBARCH=i386 CC=gcc-4.4
    cd /lib/modules/
    tar cfv modules-2.6.28.10-Xm.tar 2.6.28.10-Xm/
    rm -rf /lib/modules/2.6.28.10-Xm (you don't need the modules in the host)
    
  • Put the modules and the kernel where you want (for example, /usr/share/vnx/kernels)
  • mv /lib/modules/modules-2.6.28.10-Xm.tar /usr/share/vnx/kernels
    cp /usr/local/src/linux-2.6.28.10/linux /usr/share/vnx/kernels/linux-2.6.28.10-Xm
    cp /usr/local/src/linux-2.6.28.10/.config /usr/share/vnx/kernels/config-2.6.28.10-Xm
    
  • Testing the Kernel without VNX (better debugging):
  • cd /usr/share/vnx/kernels/
    ./linux-2.6.28.10-Xm ubda=/usr/share/vnx/filesystems/vnx_rootfs_uml-debian-6.0-v022 mem=256M
    # Check out for errors