Ath9k is the latest wireless driver for the newer Atheros chipsets and just like the MadWifi driver could be used to put your NIC in a promiscuous mode, do packet injection, etc. in order to crack WEP.

Check the compatibility of your wireless NIC first.
To find out what kind of chipset you have, run:

lspci | grep -i wireless

The ath9k driver is present in any kernel starting with version 2.6.27. The oldest supported ath9k version comes with kernel 2.6.32. That means most likely you already have the driver and there is no need to download it, all you have to do is enable it.

The general steps in order to enable ath9k are:

  1. Get the kernel source and some necessary packages
  2. Configure the kernel
  3. Compile and install the kernel
  4. Configure grub to boot from the new kernel image

Some steps might sound a bit intimidating, but actually they are very easy to do.

Since you will be running a lot of commands as root, it would be more convenient to open a bash shell as root instead of preceding all commands with sudo. The easiest way to do this is to run the following command it terminal:

$ sudo bash

Note: The above command has nothing to do with enabling the root login. I strongly recommend to never enable the root login due to serious security risks! Some blogs might ask you to do that, but there is hardly ever any reason to do this.

1. Get the kernel source and some necessary packages

# aptitude install git-core build-essential kernel-package qt3-dev-tools libqt3-mt-dev fakeroot
# apt-get install linux-source 

The above command downloaded the kernel source tarball in /usr/src.
In my case the kernel version I am working with is 2.6.32 (patch level 15). Replace these numbers with the version of your kernel source.
Now lets cd to the place we downloaded the kernel source:

# cd /usr/src

Uncompress and extract the kernel source:

# tar xjvf linux-source-2.6.32.tar.bz2
# cd linux-source-2.6.32

2. Configure the kernel

Before configuring the kernel, lets import the configuration of the currently running kernel. This way we do not miss to enable something we currently have and need:

# cp -vi /boot/config-`uname -r` .config

Now we are ready to add a few configurations to the kernel:

# make xconfig

This opens up an xwindow with a hierarchical structure representing the kernel settings:

Linux Kernel Configuration
Linux Kernel Configuration

First enable mac80211:

Networking  --->
  Wireless  --->
     Improved wireless configuration API
     Generic IEEE 802.11 Networking Stack (mac80211)

You can then enable ath9k in the kernel configuration under:

Device Drivers  --->
  [*] Network device support  --->
        Wireless LAN  --->
             Atheros 802.11n wireless cards support

If you re-used the existing configuration, note that Ubuntu kernels build with debugging information on, which makes the resulting kernel modules (*.ko files) much larger than they would otherwise be. To turn this off, go into “Kernel hacking”; then, under “Kernel debugging”, turn OFF “Compile the kernel with debug info”.

Save changes and exit.

3. Compile and install the kernel

First, let’s ensure a “clean” build:

# make-kpkg clean

Since the kernel compilation might take some time, it is best to set the CONCURRENCY_LEVEL variable, so that it can take a full advantage of the multiple processors or mulitple CPU cores on the machine. The CONCURRENCY_LEVEL variable is equal to the number of processors on the machine plus one. So if your machine has a dual core processor the variable will be equal to 3. To find out how many processors or cores your computer has run:

# lshw -C CPU

In my case I get cpu:0 and cpu:1, which means that I have a dual core processor.
Besides the CONCURRENCY_LEVEL, the only other thing we need to pay attention to here is the “–append-to-version” option. It basically adds that string to the end of the kernel name and could be set to anything. That gives you the opportunity to put there something meaningful to distingush the kernel from the other ones. In this case I called it “-mykernel”.

Now you are ready to compile:

# CONCURRENCY_LEVEL=3 fakeroot make-kpkg --initrd --append-to-version=-mykernel kernel-image kernel-headers

If you want to see the ubuntu splash screen (or use text mode) before you get to X instead of just a black screen, you’ll want to make sure the framebuffer driver loads:

# echo vesafb >> /etc/initramfs-tools/modules
# echo fbcon >> /etc/initramfs-tools/modules

Now install the kernel and the headers from the created Debian packages:

# dpkg -i linux-image-
# dpkg -i linux-headers-

Now let’s generate an initramfs (initrd) image, that will be loaded up by grub on boot:

# cd /boot

To avoid confusion with the next command, here is what my /boot directory contains before I run the mkinitramfs command:

# ls -altr
total 27700
-rw-r--r--  1 root root  160280 2010-03-23 05:37 memtest86+.bin
-rw-r--r--  1 root root 4034976 2010-08-20 14:22 vmlinuz-2.6.32-24-generic
-rw-r--r--  1 root root 1689036 2010-08-20 14:22
-rw-r--r--  1 root root  115905 2010-08-20 14:22 config-2.6.32-24-generic
-rw-r--r--  1 root root  651618 2010-08-20 14:22 abi-2.6.32-24-generic
-rw-r--r--  1 root root    1196 2010-08-20 14:24 vmcoreinfo-2.6.32-24-generic
drwxr-xr-x 22 root root    4096 2010-09-04 15:27 ..
-rw-r--r--  1 root root       0 2010-09-07 22:11 initrd.img-2.6.31-wl
-rw-r--r--  1 root root 7977082 2010-09-07 22:49 initrd.img-2.6.32-24-generic
-rw-r--r--  1 root root  115845 2010-09-08 02:13 config-
-rw-r--r--  1 root root 3999488 2010-09-08 07:38 vmlinuz-
-rw-r--r--  1 root root 1644782 2010-09-08 07:38
drwxr-xr-x  3 root root    4096 2010-09-08 16:01 .

Run the mkinitramfs to generate the initrd:

# mkinitramfs -k -o initrd.img-

4. Configure grub to boot from the new kernel image

# update-grub2

The last thing to do is to ensure that the ath9k module loads on boot. That will avoid running modprobe ath9k after each reboot.
So lets add the line ath9k to the end of the /etc/modules file:

# echo ath9k >> /etc/modules

Now reboot your computer and chose the new kernel to boot into from the grub menu.

Your wireless NIC should be working now using the ath9k driver.


How to enable the ath9k wireless driver on Ubuntu Lucid (10.04)

15 thoughts on “How to enable the ath9k wireless driver on Ubuntu Lucid (10.04)

  • October 19, 2010 at 4:48 pm

    Hello, ive been following this excellent guide but im encoutering problems when installing the custom kernel (mykernel). I can compile everything but when i get to this point:
    Now install the kernel and the headers from the created Debian packages:
    dpkg -i linux-image-

    Returns error: cannot find /lib/modules/

    dont know what to do now :-/ any help would be appreciated!

  • October 19, 2010 at 7:06 pm

    @ Robert,

    What I think happened is that you probably have a slightly different version of the kernel when you did “apt-get install linux-source”. And this is completely normal and expected.
    So if you copy and paste the command exactly like it is in the tutorial it would fail.

    Please, look at what you have in the /usr/src directory. When you compiled the custom kernel in the previous steps it created a file that starts with “linux-image-2.6” and ends with “.deb”
    This is the file (Debian package) you need to use in the “dpkg -i” command. So substitute “linux-image-” with your file. Same is valid for the linux headers in the next command.
    Then when you get to the point of generating an initramfs image, you also need to substitute the kernel version with yours in the mkinitramfs command.

  • October 19, 2010 at 11:23 pm

    dimitar thanks for such a quick answer! you were right hehe i cant believe i didnt notice i was using a slightly different version that the one on the guide 😛 hehe

    btw everything went well after that but when trying to boot into mykernel i get a kernel panic, its probably cuz i thought i had the kernel source already and didnt download it as the guide says in step one lol hehe mybad will have to do everything again.. not that it bothers me, on the contrary i’ve been learning so much since i started using linux! its very exciting i love it

    thanks again! hope to get everything working soon

    ps: how can i remove mykernel from the os boot menu when i start my pc?

  • October 20, 2010 at 1:56 pm

    @ Robert,

    Just do:

    sudo apt-get remove your_kernel

    Where “your_kernel” is the custom kernel you installed in the dpkg -i step.

    That should automatically update your grub2 and you should not see it in the boot options any more.

  • November 19, 2010 at 6:16 am


    I tried your excellent guide too, but it only seemed to do the trick once. i am able to connect wep, cable but no wpa. after i followed your guide i managed to connect once and after next reboot same issue again. i am using atheros ar9285 802.11 b/g Wifi Adapter and Realtek RTL 8102E/8103E Family PCI-E Fast Ethernet NIS. Any idea what I could do next?

  • November 20, 2010 at 12:20 am

    @ Patrick,

    If you connected once, but after the next reboot you are having the same issue that most likely means one of two things:

    1. You are not loading your new custom kernel image. Make sure that you are booting that new image. Run “uname -r” in terminal and make sure that this is the right kernel. If not, reboot and select the custom one.

    2. You did not add ath9k to the end of the /etc/modules file (see the end of the post). To test this, just run “sudo modprobe ath9k”. If after this you can connect, then you are running the right kernel, but you are not loading the ath9k module on boot.

  • November 20, 2010 at 9:52 pm

    Hi, I’ve been messing with Linux for a while but never got even close to this deep into it. I think I may be way over my head here. I’m stuck at

    root@Laptop:/usr/src/linux-source-2.6.35# make xconfig
    make: *** No rule to make target `xconfig’. Stop.


  • November 20, 2010 at 11:11 pm

    @ Mark,

    It could fail if you don’t have qt installed. Make sure that you run “aptitude install qt3-dev-tools”. It was in one of the steps above.

    Also, you can configure the kernel with “make gconfig” or “make menuconfig”. The former is a Gtk based and the latter is text based. They will do the exact same thing as “make xconfig” jut the interface will be different.

  • November 23, 2010 at 1:30 pm

    I got to the part where I do a make xconfig but can’t get a window to pop up. Here’s a copy of my terminal

    ark@Laptop:~$ cd /usr/src/linux-source-2.6.35
    ark@Laptop:/usr/src/linux-source-2.6.35$ cp -vi /boot/config-`uname -r` .config
    cp: try to overwrite `.config’, overriding mode 0644 (rw-r–r–)? yes
    `/boot/config-2.6.35-22-generic’ -> `.config’
    cp: cannot create regular file `.config’: Permission denied
    ark@Laptop:/usr/src/linux-source-2.6.35$ sudo bash
    [sudo] password for ark:
    root@Laptop:/usr/src/linux-source-2.6.35# cp -vi /boot/config-`uname -r` .configcp: overwrite `.config’? yes
    `/boot/config-2.6.35-22-generic’ -> `.config’
    root@Laptop:/usr/src/linux-source-2.6.35# make sconfig
    make: *** No rule to make target `sconfig’. Stop.
    root@Laptop:/usr/src/linux-source-2.6.35# make xconfig
    make: *** No rule to make target `xconfig’. Stop.

    Any help would be greatly appreciated!! I’m a little familiar with Linux but I’m in over my head here. Thanks,

  • November 23, 2010 at 1:48 pm

    Thanks for the quick reply. I didn’t see it till after I posted again. lol I tried your suggestion and got 2 packeages to install “aptitude” and “aptitude-gtk” They both seemed to install just fine. Or at least a whole bunch of stuff happened in the terminal. Too much to past here. Tried all 3 of the commands and same thing happened. I also went back and ran the
    cp -vi /boot/config-`uname -r` .config

    again and retried but still the same.

  • November 24, 2010 at 2:38 pm

    @ Mark,

    Are you sure you have the kernel source uncompressed and untarred in the /usr/src/linux-source-2.6.35 directory? The path looks right, but it seems that your source might not be there.

  • November 24, 2010 at 11:38 pm

    You were right, it wasn’t unpacked. I was surprised how long the terminal ran, well over an hour doing all kinds of weird stuff. lol Now I”m stuck trying to install the kernel. It made another linux-source-2.6.35 directory under the first one. all the files it using seem to be 2 deep in the 2nd directory it made. That may be causing me some trouble. Here’s the last bunch of information I got:

    dpkg-gencontrol -isp -DArchitecture=amd64 -plinux-headers- \
    create_md5sums_fn () { cd $1 ; find . -type f ! -regex ‘./DEBIAN/.*’ ! -regex ‘./var/.*’ -printf ‘%P’ | xargs -r0 md5sum > DEBIAN/md5sums ; if [ -z “DEBIAN/md5sums” ] ; then rm -f “DEBIAN/md5sums” ; fi ; } ; create_md5sums_fn /usr/src/linux-source-2.6.35/linux-source-2.6.35/debian/linux-headers-
    chown -R root:root /usr/src/linux-source-2.6.35/linux-source-2.6.35/debian/linux-headers-
    chmod -R og=rX /usr/src/linux-source-2.6.35/linux-source-2.6.35/debian/linux-headers-
    dpkg –build /usr/src/linux-source-2.6.35/linux-source-2.6.35/debian/linux-headers- ..
    dpkg-deb: building package `linux-headers-’ in `../linux-headers-’.
    cp -pf debian/control.dist debian/control
    make[2]: Leaving directory `/usr/src/linux-source-2.6.35/linux-source-2.6.35′
    make[1]: Leaving directory `/usr/src/linux-source-2.6.35/linux-source-2.6.35′
    root@Laptop:/usr/src/linux-source-2.6.35/linux-source-2.6.35# echo vesafb >> /etc/initramfs-tools/modules
    root@Laptop:/usr/src/linux-source-2.6.35/linux-source-2.6.35# echo fbcon >> /etc/initramfs-tools/modules
    root@Laptop:/usr/src/linux-source-2.6.35/linux-source-2.6.35# echo vesafb >> /etc/initramfs-tools/modules
    root@Laptop:/usr/src/linux-source-2.6.35/linux-source-2.6.35# dpkg -i linux-image-
    dpkg: error processing linux-image- (–install):
    cannot access archive: No such file or directory
    Errors were encountered while processing:
    root@Laptop:/usr/src/linux-source-2.6.35/linux-source-2.6.35# dpkg -1 linux-headers-2.6.35-22
    dpkg: unknown option -1

    Type dpkg –help for help about installing and deinstalling packages [*];
    Use `dselect’ or `aptitude’ for user-friendly package management;
    Type dpkg -Dhelp for a list of dpkg debug flag values;
    Type dpkg –force-help for a list of forcing options;
    Type dpkg-deb –help for help about manipulating *.deb files;

    Options marked [*] produce a lot of output – pipe it through `less’ or `more’ !
    Thanks again!

  • November 25, 2010 at 2:45 pm

    @ Mark,

    If you have already compiled the kernel with the make-kpkg can now install it with the dpkg -i command. Just follow the instructions in the blog. I noticed that you had the digit “1” instead of the letter “i” in the dpkg command. Also, make sure that you are typing the name of the .deb file correctly. Copy and paste is probably best. That should be it.

  • November 25, 2010 at 7:05 pm

    I got all the way through and rebooted but wireless is still disabled. everything in the terminal seed to run correctly, at least I ddin’t see any errors. I wonder since I had so much trouble if I should reload ubuntu and do over. Would like to use Super OS or Ultimate edition version of Ubuntu 10.10 anyway. Then I would have a fresh install and kind of know what I’m doing. Maybe I could get all the way through the process without backtracking and redoing steps.

  • November 27, 2010 at 6:48 pm

    I did do a fresh install and went through the whole procedure again. I got all the way through and the way I understand it there is supposed to be a kernel option at boot up but I don’t get an option. It just boots up I’m guessing to the old kernel. I must have missed something somewhere. I’m not sure where it would be, the whole process seems to run without a hitch. Didn’t see any errors or “file not found” Not sure what to do next.

Leave a Reply

Your email address will not be published. Required fields are marked *