Friday, November 11, 2011

ubuntu 11.10: fix for laptop-mode-utils "unhandled kernel version" bug on 3.0 kernel

I have found a fix for the bug you may find on ubuntu 11.10 where laptop-mode-utils complains about the kernel version. It has been annoying me a hell of a lot as certain features of this package (e.g. cpu scaling) doesnt work because of this. I decided to download the source package and investigate. The problem is in the shell script: /usr/sbin/laptop_mode.

I restart laptop mode and I get this error message:

Unhandled kernel version: 3.0 ('uname -r' = '3.0.0-12-generic')

The solution is as simple as this:

you do not need the source code as it is a shell script.

1. edit /usr/sbin/laptop_mode as root with your favourite text editor(you dont have to use gedit).
"sudo gedit /usr/sbin/laptop_mode"
I recommend you back up the origional first by:
"sudo cp /usr/sbin/laptop_mode /usr/bin/laptop_mode.bak"

2. look for the lines:

case "$KLEVEL" in
        "2.4" ) ;;
        "2.6" ) ;;
        *)
            log "ERR" "Unhandled kernel version: $KLEVEL ('uname -r' = '$(uname -r)')" >&2
            exit 1
            ;;

and replace:

case "$KLEVEL" in
        "2.4" ) ;;
        "2.6" ) ;;
        *)

with:

case "$KLEVEL" in
        "2.4" ) ;;
        "2.6" ) ;;
        "3.0" ) ;;
        *)

NOTE: replace 3.0 with whatever kernel version yours is. You can find out using "uname -r" (the first two numbers only). 

3. problem solved. you can now use cpu scaling! I sure hope they fix this bug.

if you did anything wrong, just restore the backup by running:
"sudo rm /usr/sbin/laptop_mode"
"sudo cp /usr/sbin/laptop_mode.bak /usr/bin/laptop_mode"

or if you didnt back up, reinstall the laptop-mode-utils package by running:
"sudo apt-get --reinstall install laptop-mode-utils"

No comments:

Post a Comment