Logging in arch linux

General troubleshooting

This article explains some methods for general troubleshooting. For application specific issues, please reference the particular wiki page for that program.

Contents

General procedures

It is crucial to always read any error messages that appear. Sometimes it may be hard, e.g with graphical applications, to get a proper error message.

  1. Run the application in a terminal so it is possible to inspect the output.
    1. Increase the verbosity (usually —verbose / -v / -V or —debug / -d ) if there is still not enough information to debug.
    2. Sometimes there is no such parameter and it needs to be specified as a directive in the applications’ configuration file.
    3. An application may also use log files, which are usually located in /var/log , $HOME/.cache or $HOME/.local
    4. If there is no way to increase the verbosity, it is always possible to run strace and similar.
  2. Check the journal. It is possible that an error may also leave traces in the journal, especially if it depends on other applications.
    1. dmesg reads from the kernel ring buffer. This is useful if the disk is for some reason inaccessible but this may also result in incomplete logs because the kernel ring buffer is not infinite in size. Use journalctl if possible.
    2. journalctl has more filtering options than dmesg and uses human-readable timestamps by default.
  3. It is always recommended to check the relevant issue trackers to see if there are known issues with already existing solutions.
    1. Depending on upstreams’ choices, there is usually an issue tracker and sometimes also a forum or even e.g an IRC channel.
    2. There is the Arch Linux bugtracker, which should be primarily used for packaging bugs.

Additional support

If you require any additional support, you may ask on the forums or on IRC.

When asking for support post the complete output/logs, not just what you think are the significant sections. Sources of information include:

  • Full output of any command involved — do not just select what you think is relevant.
  • systemd’s journal.
    • For more extensive output, use the systemd.log_level=debug boot parameter. This will produce a tremendous amount of output, so only enable it if it really needed.
    • Do not use the -x parameter because this needlessly clutters the output and makes it harder to read.
    • Use -b unless you need logs from a previous boot. Not specifying this may lead to extremely large pastes that may even be too big for any pastebins.
  • Relevant configuration files
  • Drivers involved
  • Versions of packages involved
  • Kernel: journalctl -k or dmesg (both with root privileges).
  • Xorg: depending on the setup the display manager in use is relevant here, too.
    • Xorg.log may be located in one of several places: the system journal, /var/log/ or $HOME/.local/share/xorg/ .
    • Some display managers like LightDM may also place the Xorg.log in its own log directory.
  • Pacman: If a recent upgrade broke something, look in /var/log/pacman.log .
    • It may be useful to use pacman’s —debug parameter.

One of the better ways to post this information is to use a pastebin.

A link will then be output that you can paste to the forum or IRC.

Additionally, you may wish to review how to properly report issues before asking.

Boot problems

When diagnosing boot problems, it is very important to know in which stage the boot fails.

  1. BIOS/Firmware
    1. Usually only has very basic tools for debugging.
    2. Make sure Secure Boot is disabled.
  2. Bootloader
    1. One of the most common things done here is the changing of kernel parameters.
  3. Initramfs
    1. Usually provides an emergency shell.
    2. Depending on the hooks chosen, either the dmesg or the journal is available within it.
  4. The actual system
    1. Depending on how badly it is broken, a simple invocation of the debug shell may suffice here.

Unfortunately, the debugging tools provided by any stage may not be enough to fix the broken component. The archiso may be used to recover in this case.

Console messages

After the boot process, the screen is cleared and the login prompt appears, leaving users unable to read init output and error messages. This default behavior may be modified using methods outlined in the sections below.

Note that regardless of the chosen option, kernel messages can be displayed for inspection after booting by using journalctl -k or dmesg . To display all logs from the current boot use journalctl -b .

Flow control

This is basic management that applies to most terminal emulators, including virtual consoles (vc):

  • Press Ctrl+s to pause the output
  • And Ctrl+q to resume it
Читайте также:  Решения для windows планшетов

This pauses not only the output, but also programs which try to print to the terminal, as they will block on the write() calls for as long as the output is paused. If your init appears frozen, make sure the system console is not paused.

To see error messages which are already displayed, see Getty#Have boot messages stay on tty1.

Debug output

Most kernel messages are hidden during boot. You can see more of these messages by adding different kernel parameters. The simplest ones are:

  • debug enables debug messages for both the kernel and systemd
  • ignore_loglevel forces all kernel messages to be printed

Other parameters you can add that might be useful in certain situations are:

  • earlyprintk=vga,keep prints kernel messages very early in the boot process, in case the kernel would crash before output is shown. You must change vga to efi for EFI systems
  • log_buf_len=16M allocates a larger (16 MiB) kernel message buffer, to ensure that debug output is not overwritten

There are also a number of separate debug parameters for enabling debugging in specific subsystems e.g. bootmem_debug , sched_debug . Also, initcall_debug can be useful to investigate boot freezes. (Look for calls that did not return.) Check the kernel parameter documentation for specific information.

netconsole

netconsole is a kernel module that sends all kernel log messages (i.e. dmesg) over the network to another computer, without involving user space (e.g. syslogd). Name «netconsole» is a misnomer because it is not really a «console», more like a remote logging service.

It can be used either built-in or as a module. Built-in netconsole initializes immediately after NIC cards and will bring up the specified interface as soon as possible. The module is mainly used for capturing kernel panic output from a headless machine, or in other situations where the user space is no more functional.

Recovery shells

Getting an interactive shell at some stage in the boot process can help you pinpoint exactly where and why something is failing. There are several kernel parameters for doing so, but they all launch a normal shell which you can exit to let the kernel resume what it was doing:

  • rescue launches a shell shortly after the root filesystem is remounted read/write
  • emergency launches a shell even earlier, before most filesystems are mounted
  • init=/bin/sh (as a last resort) changes the init program to a root shell. rescue and emergency both rely on systemd, but this should work even if systemd is broken

Another option is systemd’s debug-shell which adds a root shell on tty9 (accessible with Ctrl+Alt+F9 ). It can be enabled by either adding systemd.debug_shell to the kernel parameters, or by enabling debug-shell.service .

Debugging kernel modules

Debugging hardware

  • You can display extra debugging information about your hardware by following udev#Debug output.
  • Ensure that Microcode updates are applied on your system.
  • To test the RAM, see Stress testing#Stressing memory.

Debugging freezes

Unfortunately, freezes are usually hard to debug and some of them take a lot of time to reproduce. There are some types of freezes which are easier to debug than others:

  • Is sound still playing? If so, just the display may be frozen. This may be a problem with the video driver.
  • Is the machine still responding? Try SSH if switching to another TTY does not work.
  • Is the disk activity LED (if present) indicating that a lot is being written to disk? Heavy swapping may temporarily freeze the system. See this StackExchange answer for information about freezes on large writes.

If nothing else helps, try a clean shutdown. Pressing the power button once may unfreeze the system and show the classic «shutdown screen» which displays all the units that are getting stopped. Alternatively, using the magic SysRq keys may also help to achieve a clean shutdown. This is very important because the journal may contain hints why the machine froze. The journal may not be written to disk on an unclean shutdown. Hard freezes in which the whole machine is unresponsible are harder to debug since logs can not be written to disk in time.

Remote logging may help if the freeze does not permit writing anything to disk. A crude remote logging solution, which needs to be invoked from another device, can be used for basic debugging:

Many fatal freezes in which the whole system does not respond anymore and require a forced shutdown may be related to buggy firmware, drivers or hardware. Trying a different kernel (see Kernel#Debugging regressions) or even a different Linux distribution or operating system, updating the firmware and running hardware diagnostics may help finding the problem.

If a freeze does not permit gathering any kind of logs or other information required for debugging, try reproducing the freeze in a live environment. If a graphical environment is required to reproduce the freeze or if the freeze can be reproduced on the archiso, use the live environment of a different distribution, which is preferably not based on Arch Linux to eliminate the possibility that the freeze is related to the version or patches of the kernel. Should the freeze still happen in a live environment, chances are that it may be hardware-related. If it does not happen anymore, it is necessary to be aware of the differences of both systems. Different configurations, differences in versions and kernel parameters and other, similar changes may have fixed the freeze.

Читайте также:  Linux сменить время системное

However, a blinking caps lock LED may indicate a kernel panic. Some setups may not show the TTY when a kernel panic occurred, which may be confusing and can be interpreted as another kind of freeze.

Debugging regressions

If an update causes an issue but downgrading the specific package fixes it, it is likely a regression. The most important part of debugging regressions is checking if the issue was already fixed, as this can save much time. To do so, first ensure the application is fully updated (e.g ensure the application is the same version as in the official repositories). If it already is or if updating it does not fix the issue, try using the the actual latest version, usually a -git version, which are may be already packaged in the AUR. If this fixes the issue and the version with the fixes is not yet in the official repositories, wait until the new version arrives in them and then switch back to it.

If the issue still persists, debug the issue and/or bisect the application and report the bug on the upstream bugtracker so it can be fixed.

Kernel panics

A kernel panic occurs when the Linux kernel enters an unrecoverable failure state. The state typically originates from buggy hardware drivers resulting in the machine being deadlocked, non-responsive, and requiring a reboot. Just prior to deadlock, a diagnostic message is generated, consisting of: the machine state when the failure occurred, a call trace leading to the kernel function that recognized the failure, and a listing of currently loaded modules. Thankfully, kernel panics do not happen very often using mainline versions of the kernel—such as those supplied by the official repositories—but when they do happen, you need to know how to deal with them.

Examine panic message

If a kernel panic occurs very early in the boot process, you may see a message on the console containing «Kernel panic — not syncing:», but once Systemd is running, kernel messages will typically be captured and written to the system log. However, when a panic occurs, the diagnostic message output by the kernel is almost never written to the log file on disk because the machine deadlocks before system-journald gets the chance. Therefore, the only way to examine the panic message is to view it on the console as it happens (without resorting to setting up a kdump crashkernel). You can do this by booting with the following kernel parameters and attempting to reproduce the panic on tty1:

Example scenario: bad module

It is possible to make a best guess as to what subsystem or module is causing the panic using the information in the diagnostic message. In this scenario, we have a panic on some imaginary machine during boot. Pay attention to the lines highlighted in bold:

  • [1] Indicates the type of error that caused the panic. In this case it was a programmer bug.
  • [2] Indicates that the panic happened in a function called fw_core_init in module firewire_core.
  • [3] Indicates that firewire_core was the latest module to be loaded.
  • [4] Indicates that the function that called function fw_core_init was do_one_initcall.
  • [5] Indicates that this oops message is, in fact, a kernel panic and the system is now deadlocked.

We can surmise then, that the panic occurred during the initialization routine of module firewire_core as it was loaded. (We might assume then, that the machine’s firewire hardware is incompatible with this version of the firewire driver module due to a programmer error, and will have to wait for a new release.) In the meantime, the easiest way to get the machine running again is to prevent the module from being loaded. We can do this in one of two ways:

  • If the module is being loaded during the execution of the initramfs, reboot with the kernel parameter rd.blacklist=firewire_core .
  • Otherwise reboot with the kernel parameter module_blacklist=firewire_core .

Reboot into root shell and fix problem

This article or section is out of date.

The factual accuracy of this article or section is disputed.

You will need a root shell to make changes to the system so the panic no longer occurs. If the panic occurs on boot, there are several strategies to obtain a root shell before the machine deadlocks:

  • Reboot with the kernel parameter emergency , rd.emergency , or -b to receive a prompt to login just after the root filesystem is mounted and systemd is started.
  • Reboot with the kernel parameter rescue , rd.rescue , single , s , S , or 1 to receive a prompt to login just after local filesystems are mounted.
  • Reboot with the kernel parameter systemd.debug_shell to obtain a very early root shell on tty9. Switch to it with by pressing Ctrl+Alt+F9 .
  • Experiment by rebooting with different sets of kernel parameters to possibly disable the kernel feature that is causing the panic. Try the «old standbys» acpi=off and nolapic .
  • As a last resort, boot with the Arch Linux Installation CD and mount the root filesystem on /mnt then execute arch-chroot /mnt as the root user.
  • Disable the service or program that is causing the panic, roll-back a faulty update, or fix a configuration problem.
Читайте также:  Download windows form controls

Package management

Fixing a broken system

If a partial upgrade was performed, try updating your whole system. A reboot may be required.

If you usually boot into a GUI and that is failing, perhaps you can press Ctrl+Alt+F1 through Ctrl+Alt+F6 and get to a working tty to run pacman through.

If the system is broken enough that you are unable to run pacman, boot using a monthly Arch ISO from a USB flash drive, an optical disc or a network with PXE. (Do not follow any of the rest of the installation guide.)

Mount your root filesystem:

Mount any other partitions that you created separately, adding the prefix /mnt to all of them, i.e.:

Try using your system’s pacman:

If that fails, exit the chroot, and try:

If that fails, try:

IRC collaborative debugging

This article or section is a candidate for moving to IRC.

When requesting help from an IRC help channel (like #archlinux), it is inappropriate to paste logs into the channel and this may even get you kicked. Use a pastebin instead, you can use phriks factoid !paste to see which pastebins are acceptable. Acceptable pastebins usually work without enabling Javascript. Some require enabling Javascript for posting from a web browser, which is still acceptable because it does not affect the viewer. They should not display advertising or other disrupting content and should also not require a login. Excellent pastebins usually provide a way to paste output via piping.

An example list of acceptable pastebins:

  • https://0x0.st — supports pasting of almost any filetype. May have slightly broken MIME type detection.
  • https://paste.rs — supports pasting of images, but MIME type will be off.
  • https://bpa.st — good for people who want something graphical.
  • http://ix.io — http-only. Popular, but it is useful when debugging an SSL issue which means that https-only pastebins can not be used.

IRC usage

When first entering the channel, there is no need to say hello. State the problem you are experiencing and make sure to be verbose and to provide logfiles. It also helps to search for any error messages you are getting first to not waste anybodys time. It is also worth it to search for issues on any of the bugtrackers of the relevant software. The more helpful and verbose you are, the quicker you are going to receive help.

If this is a problem or question which is very specific to a specific software, consider visiting the dedicated IRC channel for it if there is one. It is more likely to receive a good answer there.

Output errors/messages to a file

Sometimes it is not possible to pipe the output to a pastebin directly and it should be written into a file before.

This is useful if pasting logs that contain sensitive data, e.g serial numbers in smartctl output, which have to be manually edited out.

fuser

This article or section needs expansion.

fuser is a command-line utility for identifying processes using resources such as files, filesystems and TCP/UDP ports.

fuser is provided by the psmisc package, which should be already installed as a dependency of the base meta package. See fuser(1) for details.

Session permissions

First, make sure you have a valid local session within X:

This should contain Remote=no and Active=yes in the output. If it does not, make sure that X runs on the same tty where the login occurred. This is required in order to preserve the logind session.

Basic polkit actions do not require further set-up. Some polkit actions require further authentication, even with a local session. A polkit authentication agent needs to be running for this to work. See polkit#Authentication agents for more information on this.

Message: «error while loading shared libraries»

If, while using a program, you get an error similar to:

Use pacman or pkgfile to search for the package that owns the missing library:

In this case, the libusb-compat package needs to be installed. Alternatively, the program requesting the library may need to be rebuilt following a soname bump.

The error could also mean that the package that you used to install your program does not list the library as a dependency in its PKGBUILD: if it is an official package, report a bug; if it is an AUR package, report it to the maintainer using its page in the AUR website.

Источник

Оцените статью