How to fix any Linux problem

Finding hardware drivers

Where do I get drivers for my hardware? The accompanying disc includes Windows drivers only.

Most hardware doesn't need separate drivers with Linux: the kernel includes drivers for a massive range of hardware.

Nine times out of ten, the kernel recognises the hardware when you plug it in and loads the appropriate driver without any input from you. Some hardware does have separate drivers, often because they use proprietary code that cannot be included with the kernel.

In such cases, a live CD, such as Knoppix or System Rescue CD, will often recognise the device – these tend to include a lot of extra drivers. If the hardware is an internal device, it will usually show up in the output from lspci, and adding the -k option shows which driver is being used.

Once you know that, you can search for which package provides that driver, either using your package manager or a web search. If it's in a standard package that's not installed by default, as is the case with many wireless drivers, installing the package should be all you need to get the hardware working.

The process is similar with USB devices except you use the lsusb command, and there is no handy -k equivalent.

Note that on some systems, these can only be run as root. If there's no driver support by your kernel or package manager, you have to enter the murky waters of downloading and installing drivers directly from a manufacturer's website.

If they provide a Deb or RPM package suitable for your system, this isn't too bad. Otherwise, make sure you get the right driver for your architecture and follow the installation instructions carefully. Drivers have to be linked into the kernel, so you will probably need the kernel source and build-essentialpackages installed.

Random crashes

My computer is suffering from random crashes and lockups – it doesn't seem to be related to any particular piece of software.

This may well be a hardware issue and there are a number of common causes. Faulty memory can cause this and, because of the way Linux makes use of all available memory, is more likely to do so in Linux that Windows.

Boot from a live CD and select Memtest from the menu. Let this run for at least a couple of passes, preferably overnight. Overheating is also a common cause: try running a system monitor or Taskbar applet that shows your system temperature.

Make sure all vents are clear and, if you are comfortable with taking a screwdriver to your case, check that your CPU heatsink and fan are not clogged with dust. A third cause, for desktop computers, is a substandard power supply.

Cheap units can often fail gradually, giving just this sort of behaviour and damaging other components on their way down. The only reliable test is to try a different PSU.

How to fix any Linux problem

While most distributions have a GUI for managing printers, the CUPS user interface is universal and works well

Printer problems

My distribution hasn't spotted my printer. How do I install the drivers?

How you install drivers – or even if there are any available – depends on your printer. The first place to go is The Linux Foundation's website to check their database. If you do this before buying a printer, it will save you a lot of trouble.

Enter the make and model of printer and their database will tell you if it is supported, and which drivers to use. CUPS, the printing system used by Linux, comes with many drivers, so there's often no need to install anything. There are further drivers in the gutenprint package.

HP provides open source drivers for its printers, so if you have an HP model, install the hplip package to make all HP printer and scanner drivers available.

Other manufacturers provide closed source binary packages. Check whether your distro supplies these as a package, or otherwise, as a last resort, you will need to download and install them by following the instructions on the printer manufacturer's website.

Once you have the proper drivers installed, you can set up the printer using either your distribution's printer administration tool or the CUPS web interface. To use the latter, which will work on any distro, point your browser at https://localhost:631, log in if asked, click on the Administration tab, then Add Printer and follow the prompts, bearing in mind the information you already have about the best driver to use.

The solid option

I'd like to replace my hard drive with an SSD. How do I set it up and is there anything I need to be careful of? I'm thinking about the problems caused by writing to flash memory too often. What about TRIM?

There isn't much different to be done with setting up an SSD compared with a spinning drive these days. Disk partitioning tools default to values that are safe for both types of drive now.

Most of the data around now suggests that an SSD is capable of outlasting a spinning drive. However, it won't hurt to add noatime to your mount options in /etc/fstab, if you don't already: it gives a speed boost too.

You have a couple of options for copying the data. You could back up your home directory and do a fresh installation on the SSD, or you could copy everything across.

You should boot from a live CD to do this, and use a SATA to USB adaptor if you don't have a spare SATA port. Mount each partition, apart from swap, in both drives, and use rsync to copy everything across for each partition:

rsync -a /mnt/old_partition/ /mnt/new_partition/

You'll also need to reinstall Grub to the bootloader, by booting something like Rescatux with only the new drive in the computer. TRIM, cleaning up no-longer-used areas of the storage, can be done in two ways. The easiest is to add relatime,discard to the mount options in /etc/fstab.

The only drawback, however, is that this can slow the drive down while trim operations are ongoing, so many prefer to run fstrim when the computer is lightly loaded. A Cron task that runs fstrim --all once a week should be enough for most usage. The --all option trims all filesystems that support it and silently ignores others. Add the --verbose option and Cron will mail you a summary of what was done.

Deleting files for real

I would like to make sure my hard drive is completely wiped before disposing of it. I understand that simply deleting all files is not enough, so what should I do to clear all trace of my data from the drive?

It depends on how you intend to dispose of the drive. If you are throwing it away, a large hammer is pretty terminal to your data, but there are more sophisticated – if decidedly less satisfying – ways of securely clearing a drive, methods that also leave the drive in a state suitable for resale.

How to fix any Linux problem

If you want to wipe a hard disk beyond all hope of recovery, Darik's Boot and Nuke (DBAN) is a good option

You are right in thinking that deleting files isn't enough, as that only removes their entries from the directory table, and the data is still there. You need to overwrite all the data on the drive. Conventional wisdom states that you need to do this several times, overwriting with different patterns, or random data, to prevent even the most determined of data recovery attempts. For most purposes, overwriting the drive with zeroes will do:

sudo dd if=/dev/zero of=/dev/sdb bs=4k

This cannot be run on the system drive, so if that's the one that you wish to wipe, you'll need to run the command from a live CD instead. You can give yourself further peace of mind by adding in some random data, by using /dev/urandom instead of /dev/zero.

Be aware that the dd command doesn't ask if you are sure or double-check to see if you've given it the right device before pressing Enter – there are no second chances here.

If you still want to go down the route of multiple overwrites for peace of mind, try the Darik's Boot and Nuke (DBAN) live CD which is the next most effective thing to that large hammer you're waving about.

TOPICS