Header Image - Learn Linux Online

Category Archives

One Article

Add Linux wireless drivers to Debian Install ISOs

TL;DR:

This HowTo shows you the process to find, download, and add linux wireless drivers, network drivers, or other drivers (missing firmware) to a Debian installation ISO, and then remaster it for install from a USB stick.

Background

I recently bought a Lenovo X1 Carbon ultrabook. It’s a slim, lightweight machine with no CD / DVD drive, and a couple of USB ports.  That means I needed to wipe the Windows install that was on there, and install Debian 8. Of course, getting the Debian ISOs was no problem. And creating a bootable USB is easy because they are hybridized. But, I was quickly greeted with a screen that complained it could not find my wifi – i.e., it couldn’t detect my wireless card – because it didn’t have the drivers.


Install or load firmware for missing network drivers on Debian

The problem stems from the way Debian is packaged. They do not include “non-free” drivers in the distribution ISOs. It’s a philosophical choice, and it’s not going to change, so there’s no point in tilting at that windmill.

Normally, you can select the option that says: “Install driers from a USB stick”, but, on an ultrabook, there’s a twist: since you don’t have a CDROM / DVDROM drive, adding those drivers from a secondary USB stick doesn’t work! The anaconda installer does not notice a secondary usb stick has been inserted, and flat does not scan it! So, even though you’ve put the needed drivers on that USB stick, it’s still useless.

The answer is to slipstream (Windows lingo) the drivers into the installation media. Debian offers some relatively simple ways to remaster an installation CD, which will cover in depth here in a moment. First, let’s talk about how to get the drivers in the first place.

Getting Debian Linux Wireless Drivers

In my case, the intel network card caused debian to complain that it was missing iwlwifi-6000g2a-6.ucode. A quick DuckDuckGo search reveals that this is part of the firmware-iwlwifi package in Debian. Specifically, 0.43 or higher.

So, if we scroll to the bottom of that page, we can download the .deb file.

Downloading the Debian Installable ISO

Next, we need to get an ISO that we’ll use to create the installable media from which we’ll install Debian. My preferred choice is to use BitTorrent to download the ISO files. It lessens the load on the servers hosting the ISOs, and helps the community give back to the rest of us by using a peer-to-peer connection. For this tutorial, we’re going to be dealing with the CD image, not the DVD image. So, download the CD image from here.

Setting up our working folder

We need a place to work. So, create the folder /home/youruser/custom, and copy the downloaded ISO there.

Prepare the helper scripts

Now, Debian’s Modify CD page has some technical information about this process, but this article is an attempt to make the instructions a little more palatable. That being said, we are going to be using the helper scripts at the bottom, so, copy / paste those scripts, and put them in the/home/youruser/custom directory as well.

Now, open each one, and do a find / replace to find sudo and replace with nothing (we’re removing the sudo commands because it’s easier to operate as root for the duration of this tutorial).

Become root

Because we need access to “root only” system utilities, su to root for the rest of this tutorial. (Alternatively, you could constantly use sudo for everything, but being root for the duration of this operation is probably easier).

The starting point

Right now, your custom directory should look like this:

Now, run this command:

./diunpk debian-8.2.0-amd64-CD-1.iso src dest

This will unpack the ISO file into a timestamped directory. Rename this directory to “CD” for ease of use, then copy ./dipk into that directory:

The script has created a src and dest directory under the CD directory. “Src” is a readonly version of the ISO image you downloaded, and dest is where we are going to be making changes to add our firmware.

Add the non-free firmware to the image.

Create the a directory named firmware-nonfree using this command:

mkdir ./pool/main/f/firmware-nonfree/

Now, copy our downloaded deb file to this directory:

cp /home/youruser/Downloads/firmware-iwlwifi_0.43_all.deb ./pool/main/f/firmware-nonfree/

Lastly, we need to make a symbolic link from the firmware directory just below the root of the ISO to this file so that that installer can find it during the natural installation process, so change directory to the firmware directory (/home/youruser/custom/dest/firmware), and then create the symbolic link:

cd firmware
ln -s ../pool/main/f/firmware-nonfree/firmware-iwlwifi_0.43_all.deb

Here’s what my whole process looked like:

  1. I used the find command to find existing firmware just to confirm it’s location. As I expected, it was in ./pool/main/f/firmware-free.
  2. I created ./pool/main/f/firmware-nonfree to store the non-free drivers.
  3. I used tab completion (in the red box) to create the correct command to copy the firmware from my Downloads directory to the nonfree directory I just created.
  4. I changed directory to the firmware directory that is just below dest/.
  5. I did a directory listing to ensure I was seeing what I was expecting to see, and to look at the symlink for the existing firmware.
  6. I created a symbolic link to the new, non-free firmware I just added.
  7. I did a directory listing to make sure it was done correctly.

Run dipk to generate the ISO.

Chagnge directories back to CD (the parent directory of dest), and run the following command:

./dipk ../custom.iso src dest

This will create a file called custom.iso in the custom directory  (the parent directory of the CD directory) using the src and dest files that we have been working with.

Preparing the ISO for use with a USB Drive.

In order to use a USB stick to boot this ISO file and install Linux, we need to use the utility isohybrid, so run the follwoing command from the custom directory:

isohybrid custom.iso

This changes the ISO file to allow modern BIOSes to recognize its structure as a bootable disk.

Prepare your USB Stick

Lastly, put your USB stick in the computer, and run dmesg to figure out which device it is. (It’s usually the last /dev/sdX to show up in dmesg). In my case, it was /dev/sdm. Now, just copy the ISO file to that device:

cp custom.iso /dev/sdX

(Note: be sure to replace the “X” with the proper letter that represents your USB drive!).

Enjoy.