To compile kernel modules on a Cloud Server you need to complete the following steps, making sure to change the kernel version and directories where appropriate (–for example, extracts to linux-, whereas extracts to

  1. Grab the patched kernel source for your kernel from the repository (check your kernel version with uname -a).
  2. Extract the kernel to /usr/src.
    sudo tar xpf -C /usr/src
  3. Create a link to /usr/src/linux and link to build in /lib/modules
    sudo rm -rf /usr/src/linux
    sudo ln -s /usr/src/ /usr/src/linux
    sudo rm -rf /lib/modules/
    sudo ln -s /usr/src/linux /lib/modules/
  4. Create the configuration file and prepare the modules
    zcat /proc/config.gz | sudo tee /usr/src/linux/.config > /dev/null
    sudo make oldconfig
    sudo make modules_prepare
    sudo make INSTALL_HDR_PATH=/usr headers_install

If all went well you can now build custom kernel modules.

« »