lkubuntu

A listing of random software, tips, tweaks, hacks, and tutorials I made for Ubuntu

How to fix rfkill Issues

I recently tried making wireless work on a laptop, but I got problems with rfkill showing that it was hard blocked. In fact, the wireless switch was off, but when I set it on, it still showed that it was hard blocked.

Here is a solution that I found that works:

  1. Make sure that your wireless switch is on
  2. Type in a Terminal window:
    sudo rfkill unblock all
    for x in `for i in \`lspci -nn | grep 02[80] | awk '{print $1}' | tr ' ' '\n'\`; do lspci -vvvs $i; done | grep "Kernel driver in use:" | awk '{print $NF}'`; do sudo rmmod $x; sudo modprobe $x; done
    sudo sed -i 's:false:true:g' /var/lib/NetworkManager/NetworkManager.state
    sudo rfkill unblock all
    sudo rm /dev/rfkill
  3. Reboot

If you still can’t connect after the reboot, type this into a Terminal window:
sudo rfkill unblock all
for x in `for i in \`lspci -nn | grep 02[80] | awk '{print $1}' | tr ' ' '\n'\`; do lspci -vvvs $i; done | grep "Kernel driver in use:" | awk '{print $NF}'`; do sudo rmmod $x; sudo modprobe $x; done
sudo rfkill unblock all

If you had any problems with this post, feel free to leave a comment!

16 responses to “How to fix rfkill Issues

  1. Alexander E. Patrakov September 7, 2011 at 6:54 am

    None of the commands in step 2 can have effects that survive a reboot. So I wonder why you needed steps 2 and 3 at all.

    • Anonymous Meerkat September 7, 2011 at 2:55 pm

      Actually, they do have effects after reboot, especially the rm /dev/rfkill command.

      • Alexander E. Patrakov September 7, 2011 at 3:20 pm

        rm /dev/rfkill cannot have effect after the reboot, because /dev is a tmpfs. If you insist that it does, please explain the mechanism.

      • Anonymous Meerkat September 7, 2011 at 3:25 pm

        For some reason, it does fix some rfkill problems (there were many blog posts using it). I guess that somehow it resets it? I don’t exactly know how it works, but all that I know is that it can help the problem.

        • Alexander E. Patrakov September 7, 2011 at 3:43 pm

          Well, here is how that “rm /dev/rfkill” command works.

          Applications such as NetworkManager control the rfkill state by opening the /dev/rfkill device and writing some pre-defined sequences of bytes into it. By removing that device, you make them unable to change the current rfkill state. This definitely works (although it is not a proper solution), I am just saying that after the reboot udev will create the device again, thus undoing your work.

          Your real problem is that, for some reason, NetworkManager (or some other program – e.g. the laptop-mode script, please find that out) thinks that your radio should be off, and periodically tries to enforce its viewpoint via /dev/rfkill. You should politely (i.e. via configuration files or checkboxes in the GUI) convince that program to change its decision instead of working around its delusion.

      • Anonymous Meerkat September 7, 2011 at 3:47 pm

        The problem can be caused by what you said, but rebooting after removing /dev/rfkill will reset rfkill. Usually, the problem has nothing to do with rfkill, but has to do with a driver thinking that the wireless switch is off.
        Removing /dev/rfkill, then rebooting, only works for some rare problems.

  2. Rainer September 7, 2011 at 7:15 am

    Thanks for posting these scripts – they are very useful.

    Just one question: could you add some information what they are doing, as I usualy want to understand what I am doing when executing a script?

    Cheers and thanks for an interesting blog,

    Rainer

    • Anonymous Meerkat September 7, 2011 at 2:59 pm

      The first command tries to unblock the soft blocked.
      The second command (the longest one) tries to find all of the network drivers currently in use, then it disables and re-enables the drivers (It almost always works).
      The third command repeats what the first one did.
      The fourth command simply resets rfkill.

      I hope this clarifies it!

  3. Pingback: Blair Armeau » How to fix rfkill Issues « lkubuntu

  4. Mathieu Trudel-Lapierre September 7, 2011 at 11:41 pm

    Please make sure /var/lib/NetworkManager/NetworkManager.state shows “true” for all the items. If not, then yes, NM might be overriding rfkill, though the default setting definitely isn’t to have anything disabled (but you may have run into an old bug if in Lucid).

    Otherwise, that’s most likely a kernel bug, you really should file a bug report in Launchpad.

  5. Pingback: SIOCSIFFLAGS: Operation not possible due to RF-kill « Hayi no Tabi…. another story….

  6. Evan November 13, 2011 at 9:36 am

    It worked first time!
    I am really impressed by this Ubuntu Forum and the Ubuntu program and the people behind it .

    Thank you for an excellent product and a first class service

  7. Bredgeo July 22, 2012 at 12:32 pm

    AWESOME!!!!!! Thank you!!!!!!!

  8. Matt October 7, 2012 at 9:08 pm

    Thank you so much!!!!

  9. Jose June 19, 2013 at 2:24 pm

    Thank you. That do the job.

Leave a comment