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

From VNX
Jump to: navigation, search
(Compiling old Linux 2.6.28 kernel)
Line 60: Line 60:
  
 
* Download an untar vanilla kernel:
 
* Download an untar vanilla kernel:
 
+
cd /usr/local/src
    # cd /usr/local/src
+
wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.28.10.tar.bz2
    # 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
    # tar xfj linux-2.6.28.10.tar.bz2
+
cd linux-2.6.28.10
    # 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)
 
* 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
    # 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):
 
* 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
    # /usr/share/vnx/kernels/linux-2.6.18.10-1m --showconfig > .config
+
vi .config (and set CONFIG_LOCALVERSION="-Xm")
# vi .config (and set CONFIG_LOCALVERSION="-Xm")
+
make menuconfig ARCH=um SUBARCH=i386 CC=gcc-4.4
    # make menuconfig ARCH=um SUBARCH=i386 CC=gcc-4.4
+
# Select "Load Other Config"
# Select "Load Other Config"
+
# Load .config
# Load .config
+
# Edit Kernel using menu as you need
# Edit Kernel using menu as you need
+
# Exit and save
# Exit and save
 
  
 
* Make the kernel:
 
* Make the kernel:
 
+
nano arch/um/os-Linux/mem.c  
# nano arch/um/os-Linux/mem.c  
+
add "#include <sys/stat.h>" to the Header (e.g. after #include <sys/param.h>)
# add "#include <sys/stat.h>" to the Header (e.g. after #include <sys/param.h>)
+
make ARCH=um SUBARCH=i386 CC=gcc-4.4
    # make ARCH=um SUBARCH=i386 CC=gcc-4.4
+
strip linux
    # strip linux
 
  
 
* Add Modules to UML rootfs:
 
* Add Modules to UML rootfs:
 
+
mkdir /mnt/uml/
# mkdir /mnt/uml/
+
mount  /usr/share/vnx/filesystems/vnx_rootfs_uml-debian-6.0-v022 /mnt/uml/ -o loop
# 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/
# 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
# ls /mnt/uml/lib/modules -> There should be a folder called: 2.6.28.10-Xm according to you CONFIG_LOCALVERSION
+
umount /mnt/uml/
# umount /mnt/uml/
+
rm -rf /mnt/uml/
# rm -rf /mnt/uml/
 
 
 
 
* Make the modules tar:
 
* Make the modules tar:
 
+
make modules_install ARCH=um SUBARCH=i386 CC=gcc-4.4
    # make modules_install ARCH=um SUBARCH=i386 CC=gcc-4.4
+
cd /lib/modules/
    # cd /lib/modules/
+
tar cfv modules-2.6.28.10-Xm.tar 2.6.28.10-Xm/
    # 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)
    # 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)
 
* 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
    # 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/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
    # 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):
 
* Testing the Kernel without VNX (better debugging):
+
cd /usr/share/vnx/kernels/
# 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
# ./linux-2.6.28.10-Xm ubda=/usr/share/vnx/filesystems/vnx_rootfs_uml-debian-6.0-v022 mem=256M
+
# Check out for errors
# Check out for errors
 

Revision as of 01:07, 11 June 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 sith 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
    
  • Download mconsole exec kernel patch:
  • wget 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
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