Compiling Non-Default Kernel Drivers for Linux Preboot ( LinPE )

book

Article ID: 185041

calendar_today

Updated On:

Products

Deployment Solution

Issue/Introduction

Compiled drivers for Linux Preboot from ITMS 7.6 having kernel version 2.6.32-358.51.1.el6. Linux distro used for this tutorial is “Debian 7.8 32-Bit”.
Note: Before continuing ensure that following tools are installed on build machine:
gcc, make, rpm, tar

Resolution

  1. Download the kernel source code package
    Use the URL that follows to download the kernel source code
    http://ftp.redhat.com/pub/redhat/linux/enterprise/6Server/en/os/SRPMS/kernel-2.6.32-358.51.1.el6.src.rpm


     
  2. Install source package
    Execute the commands that follow from the terminal in current user’s home directory:
    mkdir -p rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
    echo "%_topdir $(pwd)/rpmbuild" > ~/.rpmmacros
    Now change directory to where kernel source rpm is present and execute below command
    rpm –i kernel-2.6.32-358.51.1.el6.src.rpm

    If you get “cpio: MD5 sum mismatch” error then use below command
    rpm --nomd5 -i kernel-2.6.32-358.51.1.el6.src.rpm

    This will extract all the required source files from the package to the “rpmbuild/SOURCES” folder under current user’s home directory.

     
  3. Extract source code from the package
    Copy linux-2.6.32-358.51.1.el6.tar.bz2 to some other folder

    Now extract its contents
    tar –xvf linux-2.6.32-358.51.1.el6.tar.bz2
  4. Copy the config file to the extracted location
    “Config.x86” file is located on NS at below location
    <InstallDir>\Altiris\Deployment\BDC\bootwiz\Platforms\Linux\x86\Build
  5. Execute “make oldconfig"
  6. Execute “make menuconfig” and select the required module. Save and exit.
  7. Type “make modules” to start building the codeThis will generate .ko driver file which can be included into Linux Preboot Environment ( LinPE ). 


Loading Driver in Linux Preboot ( LinPE )

  1. Driver can be loaded into Linux Preboot using following commands:
    Create opt/ folder under /lib/modules/2.6.32/kernel/
    And copy driver file ( .ko ) to Linux Preboot (eg. /lib/modules/2.6.32/kernel/opt/ )
  2. Navigate to the directory where the driver is copied.
  3. Execute depmod –ae
  4. Execute modprobe <dirvername> ( eg modprobe usb-storage) 


Important: The drivers you just compiled will only work with the kernel version that they were compiled with. If you upgrade the Linux automation kernel, you will have to re-setup your Linux computer and recompile the drivers.
Note:
Fixing Error - implicit declaration of function “rh_key_invalidate”
Open “include/linux/key.h” file and add empty definition for “rh_key_invalidate” for the unset case of CONFIG_KEYS.
Add below line to “key.h” file
 
#define rh_key_invalidate(k)        do { } while(0)

Attachments