Friday, 17 September 2010

Wireless Networking on an Ubuntu LiveCD

I have two PCs which I regularly like to boot to a LiveCD environment. One is a Desktop machine with a Linksys WMP54GS wireless card, the other is a Compaq Mini 700 netbook. The linksys uses Broadcom's 4306 chipset and I think the netbook uses the 4312. I would like them both to work with a LiveCD. Neither of them work with a LiveCD. Using Ubuntu there is a simple solution for each machine. All you do is run (on the desktop):
sudo apt-get install b43-fwcutter
or on the netbook:
sudo apt-get install bcmwl-kernel-source
and the system will connected to Ubuntu's servers through the internet and will automatically download all the software it needs to configure your internet connection which lets you connect to Ubuntu's servers and ... hang on a fucking minute, I've spotted a flaw.

So how else do I solve this thorny little problem BEFORE the LiveCD gets an internet connection. There are two separate solutions - one for each machine. For the Desktop machine, I just need to load the firmware onto the running LiveCD system. The B43 driver is installed by Ubuntu as a kernel module. Using a different operating system (windows is fine for this because the USB Key is FAT32) I dump a copy of the b43 folder (which I have painstakingly explained how to get a hold of elsewhere) containing the firmware onto the USB Key. I can then run the following commands in the terminal (or ideally put them into an executable script on the USB Key).

sudo cp -r "/cdrom/b43" /lib/firmware/
sudo rmmod b43
sudo modprobe b43

What that does is copy the b43 folder from the USB Key (ubuntu mounts the LiveCD medium to /cdrom, no matter what it actually is) to the /lib/firmware directory. The next two commands remove and then reinstall the b43 module to activate the firmware. Wireless networks should now show up in Network Manager.

OK, second solution for the netbook, and a bit trickier. First of all, the above b43 based solution did work. Sometimes. Other times it would come up with error messages visible using [dmesg], and then refuse to work. It would also sometimes cause the interface to fail even when rebooting into a perfectly working installed operating system, resulting in the need to shut the whole thing down and take out its battery before trying again. So, not entirely reliable then. Lets use the proper driver.

First of all, we are going to want to build the driver from source code, so we must have the following packages built into the USB Key:


This means that you need to generate a custom LiveCD image. There is simply no point in following these instructions if you are using a vanilla LiveCD image.

Next we want to download the driver. I stuck the USB Key in a running version of Ubuntu and ran the following commands:

cd /media/2G

My USB Stick is called [2G] so Ubuntu automounts it into a directory with the same name in [/media]. The next command downloads the latest version of the hybrid driver. I am not sure what a hybrid driver is, but if I had to guess I would say it is a driver AND firmware contained in the same package. Incidentally, you could just use the same URL in windows and save the file to the USB Key. You then reboot to the USB Key and run the following commands (ideally from a script):

cd /tmp
cp /cdrom/hybrid-portsrc-x86_32-v5.60.48.36.tar.gz .
mkdir hybrid_wl 
cd hybrid_wl 
tar -xzvf ../hybrid-portsrc-x86_32-v5.60.48.36.tar.gz 
make clean
sudo rmmod b43 
sudo rmmod b44 
sudo rmmod b43legacy
sudo rmmod wl
sudo rmmod ssb 
sudo rmmod ndiswrapper 
sudo rmmod lib80211
sudo modprobe lib80211
sudo insmod wl.ko

The [cp] commands [c]o[p]ys the file we downloaded into the current [.] directory, which is [/tmp] because we just moved into it.

There are lots of [r]e[m]ove [mod]ules commands, because there are so many modules which potentially interfere with the [wl] driver. Again, once this script has finished, the interface should be up and running. This one will take a little longer to run because it is building the module from source code each time.

No comments:

Post a Comment