How to fix any Linux problem

How to fix any Linux problem

Everyone has a problem with Linux at some point. The important thing is how quickly that problem gets solved. An amazing element of the open source and computing community is the vast network of help available online in the form of blogs, websites and forums.

Without doubt this is of huge importance in getting issues known and fixed, and it's wonderful to see how willing the community is to help out complete strangers and beginners alike. That being said, there's nothing that beats a bit of prior knowledge.

To help arm you with the knowledge you need to keep your Linux systems cheerfully ticking over, we've taken our years of experience answering all manner of reader questions and distilled this into a rich brew of condensed Linux knowledge, which will target the top issues that Linux users regularly run into.

In many ways computers are this wobbling tower of intertwined standards, protocols, interfaces and files. Considering just how complex a modern Linux system is, it's astonishing that a Linux PC manages to successfully complete the delicate dance of powering up, launching the bootloader, handing over to the kernel, loading files of its file system, hopping through init and establishing an X graphical interface with interactive graphical desktop manager, wireless internet connection and all the other services that modern systems provide.

At any stage this wobbling tower can crash down – and when it does, we're here to help you pick up the pieces! Our guide starts at the beginning with troubleshooting the boot process, moving through basic hardware and system issues, then on to more generic hardware, networking and finally classic desktop problems.

Hopefully you'll come out of the darkness with at least a few invaluable nuggets of Linux knowledge to help make your Linux experience that little bit smoother and even more enjoyable. So lets turn the page and get fixing!

Boot problems

Got boot problems? We tackle the common issues.

Stalled boot

My computer won't boot. The splash screen comes up and then it just sits there.

The first thing to do is be patient – the boot process may be trying to initialise a piece of hardware, or access the network before it's available. These can time out after a few minutes, either allowing boot to proceed or at least giving you an error message to work with.

In the good old days, distros used to stream reams of text up the screen as they were booting, until it became fashionable to hide this with a splash screen. Unfortunately, the splash screen also hides any error messages. You can disable the splash screen at the boot menu: if your computer starts booting without showing a menu, hold down Esc when it boots to call up the menu.

If there's a recovery or safe option, pick that, as it disables the splash screen and often sets safer (if potentially less efficient) boot options. Otherwise, put the highlight on your normal boot option and press E for edit. Find the line that starts with linux and look for options like quiet, splash or theme.

Delete these options and press F10 to continue booting. This won't fix your problem (unless the problem is the splash screen itself), but it will let you see what is going on and either get an error message or an idea of which stage of the boot is failing at. Then you can investigate further. If it appears to be a hardware detection issue, try disconnecting all unnecessary hardware, such as printers, scanners or USB rocket launchers. Once you can get past the problem, you can start to fix it.

How to fix any Linux problem

Disable your distribution's boot splash to see what's really going on, or failing to go on, when your system is booting up

Boot errors

When I boot I see error messages along the lines of

Pci Express Device Error. Severity NN. Uncorrected non Fatal. Pci Bus Error

Type:N Transaction Layer. Flow Control Protocol N:First.

Receiver 1

This is a problem I'm experiencing on a newly bought motherboard that works fine with Windows.

Hardware working with Windows is no indication that it's fault free. The "It works with Windows, ship it and we'll fix any other problems with an update" attitude is not uncommon. With anything motherboard related, the first step is to check whether there's a BIOS update available.

Even with a brand new motherboard, by the time it has travelled through the shipping and distribution process to get from the Far East to your computer's manufacturer and then to the shop and finally to you, there is usually a new BIOS available.

Flashing a new BIOS can fix a lot of boot problems but if yours persist, there is more you can do. You can change the way the kernel addresses the hardware with a number of parameters you can pass to it at boot time. At the Grub boot menu (press Esc if it does not show up by default), highlight your normal boot option and press E (for edit).

Edit the line starting with kernel by adding some or all of these options to the end of the line, separated by a space:

noapic

or

noapictimer, acpi=off

or

acpi=force

irqpoll

pci=nommconf

pci=nomsi

Note the difference in spelling between the second and third set of options – about all that acpi and apic have in common is the letters in their names. Press F10 to boot with the options you added. Once you find a combination that has the kernel and your hardware co-operating with one another, make the change permanent by adding the options to GRUB_CMDLINE_LINUX_DEFAULT and GRUB_CMDLINE_LINUX in /etc/default/grub, saving the file and updating Grub with one of these commands.

Which one depends on your distro – if the first one fails, try the second and then the third.

sudo update-grub2

sudo grub2-mkconfig -o /boot/grub2/grub.cfg

sudo grub2-mkconfig -o /boot/grub/grub.cfg

Re-installing Windows broke Linux

I installed Linux onto my Windows computer and it gave me the choice of which to use when I turned it on. I recently had to reinstall Windows and now Linux has disappeared.

I don't want to reinstall Linux as I would lose all my documents and settings. Is there any way to get my Linux back?

Linux uses the Grub bootloader to choose between different boot options, but Windows uses its own bootloader. A bootloader is a small piece of code embedded at the start of your hard drive that kickstarts the process of loading your operating system.

When you installed Windows, it installed its own bootloader, overwriting your existing Grub. Don't worry, it's only the bootloader code that's gone – your Linux system and files are still there, and all you need to do is restore Grub. Some distro install discs have an option to repair the bootloader, or there's a more generic option in Rescatux.

Boot from the Rescatux CD and select the Restore Grub option. This will search for your Linux partitions and ask you to choose the partition that contains the root filesystem of your Linux installation and then ask which hard disk you want to install Grub on – usually /dev/sda, the first disk. The window may go blank for a worrying amount of time but do not panic or reboot: wait until it tells you Grub was re-installed before rebooting, and you should then get your old boot menu back, with access to your untouched Linux system.

How to fix any Linux problem

To make permanent changes to your Grub menu, edit /etc/default/grub and run grub2-mkconfig or update-grub

Dual-booting more than one distro

I know I can dual-boot between Linux and Windows, but can I do the same with more than one Linux distro? If so, how do I share my data between them? How should I partition my disk?

Yes, it is possible. Each distro needs its own root partition but you can share the same swap between them all. Having a separate partition for /home is recommended – you don't want to tie your data to a single distro you may later decide to stop using.

While a separate /home partition is desirable, don't use the same home directory for each distro as there may be incompatibilities between different versions of the software used. I prefer to put the distro name in the username, as in "fred-ubuntu", "fred-debian", etc. As long as each user has the same UID – most installers make the first user 1000 – you'll have write access to all of them, then you can create symlinks for important data directories, like documents, music, photos and so on, to share these files between all distros while keeping the configuration files separate.

As far as the boot menu is concerned, pick one distro as your main one and let that handle booting. Every time you install a new distro, skip the option to install a bootloader if possible. Then reboot into the main one and run:

sudo grub-mkconfig -o /boot/grub/grub.cfg

to update the boot menu.

Removing a distro broke everything

I deleted Linux partitions from my computer, in preparation for installing something else. Now I cannot boot it. All I get is a message that Grub cannot find files and a prompt saying 'grub rescue>'. I can't even boot into Windows.

While the initial boot code for Grub is stored in the Master Boot Record (MBR) at the start of your hard disk, this is a very small space. So the initial Grub code loads files and configuration information from the grub or grub2 directory on your Linux boot partition.

When you removed that partition, you left Grub nowhere to go. If you are planning on installing another distro in the now-empty space, simply run the installer and it will set up Grub for you, detecting your Windows system too, and all will be well after a reboot.

How to fix any Linux problem

The Rescatux live CD has a handy Restore Grub button, which saves you having to remember rarely-used shell commands

If you are using the space for an existing Windows or Linux installation, you need to either set up Grub for the other Linux system or reinstall the Windows bootloader. The easiest way to reset Grub is use the Restore Grub option on the Rescatux live CD – choose the Linux installation you want to be responsible for holding the Grub files.

Restoring the Windows bootloader involves booting the Windows disc (or rescue partition) and running one of these commands, depending on the Windows version. For Windows XP it's the following:

fixboot

fixmbr

For Windows Vista and Windows 7, Windows 8 and Windows 10 it's:

bootrec /fixboot

bootrec /fixmbr

bootrec /rebuildbcd

When your computer won't even boot, a live CD is a godsend, so it pays to always have one handy. A live CD is a complete Linux environment that boots from a CD and needs no installation, or even access to a hard drive.

Apart from being very handy for being used as a portable distro or as a sampler to try a different distro without installing it, a live CD is ideal for a rescue system. There are some dedicated rescue CDs, such as System Rescue CD, Rescatux and Grml, but most distro installer discs nowadays boot into a live environment that contains enough software to fix many problems.

For more solutions to Linux boot problems, check out our guides on how to repair Ubuntu if it won't boot.