Compile kernel module on Linode Debian VPS

Connection to linode hosts from within China can be poor from time to time. Choosing a suitable TCP congestion algorithm may alleviate that from insignificant to a great deal, your mileage may vary. Trying it out is always the best way to find out. Here I will show you how to do that step by step.

  1. Login to your VPS and find out the version of the running kernel

    # uname -a
    Linux jhelom 3.12.6-x86_64-linode36 #2 SMP Mon Jan 13 18:54:10 EST 2014 x86_64 GNU/Linux
    

    That is 3.12.6.

  2. Go get the 3.12.6 from kernel.org at https://www.kernel.org/pub/linux/kernel/v3.x/
  3. Extract it and copy the kernel config over from the current one.

    # tar xf linux-3.12.6.tar.xz
    # zcat /proc/config.gz > .config
    # make oldconfig
    
  4. Now, edit .config with an editor such as vi, look for the line CONFIG_TCP_CONG_ADVANCED, remove the line, and add the following lines there:

    CONFIG_TCP_CONG_ADVANCED=y
    CONFIG_TCP_CONG_BIC=m
    CONFIG_TCP_CONG_WESTWOOD=m
    CONFIG_TCP_CONG_HTCP=m
    CONFIG_TCP_CONG_HSTCP=m
    CONFIG_TCP_CONG_HYBLA=m
    CONFIG_TCP_CONG_VEGAS=m
    CONFIG_TCP_CONG_SCALABLE=m
    CONFIG_TCP_CONG_LP=m
    CONFIG_TCP_CONG_VENO=m
    CONFIG_TCP_CONG_YEAH=m
    CONFIG_TCP_CONG_ILLINOIS=m
    CONFIG_DEFAULT_CUBIC=y
    # CONFIG_DEFAULT_RENO is not set
    
  5. Now compile the kernel and the modules.

    # make -j4
    # make modules SUBDIRS=net/ipv4
    
  6. If everything goes well, you will be able to load the module.

    # sudo insmod net/ipv4/tcp_hybla.ko
    

    Check with lsmod and make sure the kernel module is loaded successfully. If not, check dmesg for any errors.

That’s it!