System maintenance (简体中文)

Tango-preferences-desktop-locale.png本页面或部分需要翻译,部分内容可能已经与英文文章脱节。如果您希望贡献翻译,请访问简体中文翻译组Tango-preferences-desktop-locale.png

附注: please use the first argument of the template to provide more detailed indications.
翻译状态: 本文是英文页面 Arch_Linux_System_Maintenance翻译,最后翻译时间:2015-11-10,点击这里可以查看翻译后英文页面的改动。

Regular system maintenance is necessary for the proper function of Arch over a period of time. Timely-maintenance is a practice many users get accustomed to.

Check for errors

Failed systemd services

Check if any systemd services have entered in a failed state:

$ systemctl --failed

See Systemd#Analyzing the system state for more information.

Logfiles

Look for errors in the log files located at /var/log, as well as high priority errors in the systemd journal:

# journalctl -p 0..3 -xn

See Systemd#Journal for more information.

Backup

Backups may be automated with systemd/Timers.

Configuration files

Merge-arrows-2.pngThis article or section is a candidate for merging with #Important data.Merge-arrows-2.png

Notes: please use the second argument of the template to provide more detailed indications. (Discuss in Talk:System maintenance (简体中文)#)

Before editing any configuration files, create a backup. This way, you can revert to a working version in case of problems. Editors like vim and emacs can do this automatically, as well as tools like etckeeper which keep /etc in a version control system (VCS).

Important data

Create backups of important data at regular intervals. Directories to consider are /etc, /home and /var, and, for server installations, also /srv.

See Backup programs for many alternative applications that may better suit your case. See Category:System recovery for other articles of interest.

List of installed packages

Maintain a list of all installed packages, so that if a complete re-installation is inevitable, it is easier to re-create the original environment.

See Pacman tips#Backing up and retrieving a list of installed packages for details.

Pacman database

See Pacman tips#Back-up the pacman database.

Upgrading the system

It is recommended to perform full system upgrades regularly, to enjoy both the latest bug fixes and security updates, and also to avoid having to deal with too many package upgrades that require manual intervention at once. See Pacman#Upgrading packages for details.

Make sure to have the Arch install media or another Linux "live" CD/USB available so you can easily rescue your system if there is a problem after updating. If you are running Arch in a production environment, or cannot afford downtime for any reason, test changes to configuration files, as well as updates to software packages, on a non-critical duplicate system first. Then, if no problems arise, roll out the changes to the production system.

If the system has packages from the AUR, carefully upgrade all of them.

Avoid certain pacman commands

Avoid doing partial upgrades, i.e. never run pacman -Sy and instead use pacman -Syu.

Avoid using the --force option with pacman, especially in commands such as pacman -Syu --force involving more than one package. The --force option ignores file conflicts and can even cause file loss when files are relocated between different packages! In a properly maintained system, it should only be used when explicitly recommended by the Arch developers (see #Read before upgrading the system).

Avoid using the -d option with pacman. pacman -Rdd package skips dependency checks during package removal. As a result, a package providing a critical dependency could be removed, resulting in a broken system.

不支持部分升级

Arch Linux 是滚动发行版,新 版本将不断被推送到源。开发者和信任用户会按照需要重新构建源中的所有软件包。如果有本地安装的版本(例如 AUR 软件包),需要在它们的依赖关系升级了soname时重新编译。

也就是说,部分升级是不被支持的

不要使用 pacman -Sy package 或等价命令如 pacman -Sy 之后再 pacman -S package。在安装软件包前请更新源并升级。同理请特别注意 IgnorePkg/IgnoreGroup 的使用。

如果进行了部分升级,二进制包因为找不到链接库而损坏,不要通过简单的符号链接进行修正。库升级 soname 是因为它们不再向前兼容。只要 pacman 可以运行,使用更新的源进行 pacman -Syu 就能修复这些问题。

The bash script checkupdates, included with the pacman package, provides a safe way to check for upgrades to installed packages without running a system update at the same time. See also BBS##1563725.

Read before upgrading the system

Before upgrading Arch, always read the latest Arch News to find out if there are any major software or configuration changes with the latest packages. Before upgrading fundamental software (such as the kernel, xorg, systemd, or glibc) to a new version, look over the appropriate forum to see if there have been any reported problems.


在升级Arch前, 一定要阅读Arch News来查看是否有主要的软件更改和最新软件包的是否配置文件的更改. 在更新如:内核,xorg和库文件到一个新版本等重要软件之前, 仔细查看论坛看是否有被报告的出错等问题.

Act on alerts during an upgrade

When upgrading the system, be sure to pay attention to the alert notices provided by pacman. If any additional actions are required by the user, be sure to take care of them right away. If a pacman alert is confusing, search the forums and the recent news posts for more detailed instructions.

当升级系统时, 请一定要注意pacman输出的注意信息。 如果有需要用户手动操作的,请一定要立即搞定。 如果不明白pacman输出的信息, 请去论坛搜索或者看Arch Linux首页的新闻。

Deal promptly with new configuration files

When pacman is invoked .pacnew, .pacsave, and .pacorig files can be created. Pacman provides notice when this happens and users must deal with these files promptly. Users are referred to the Pacnew and Pacsave files wiki page for detailed instructions.

Also, think about other configuration files you may have copied or created. If a package had an example configuration that you copied to your home directory, check to see if a new one has been created.

Revert broken updates

If a package update is expected/known to cause problems, packagers will ensure that pacman displays an appropriate message when the package is updated. If experiencing trouble after an update, double-check pacman's output by looking at /var/log/pacman.log.

At this point, only after ensuring there is no information available through pacman, there is no relative news on https://www.archlinux.org/, and there are no forum posts regarding the update, consider seeking help on the forum, over IRC, or by downgrading the offending package.

使用包管理器安装软件

软件包管理 pacman 可以比你更好的记录安装的文件。如果你手动地安装软件,你会过了一会就不知道你到底安装了什么,到底安装在哪里,安装导致的那些冲突,是否安装在了错误的地方,等等问题. 避免安装自编译的软件包,可以自己创建软件包

要清理自己安装的文件,可以查看这里.

选择开源驱动

尽可能地选择开源驱动。避免私有驱动。大多数时候,开源驱动比私有驱动更加稳定可靠。开源驱动的bugs修改起来比较容易快速,但同时私有驱动提供更多的特性和性能,不过也可能带来稳定性的代价。为了避免这个两难选择,可以选择已知的有很好的开源驱动支持的硬件。关于硬件和开源Linux驱动的信息可以在这里找到:linux-drivers.org.

谨慎使用非官方或测试不足的软件包

在使用 AUR 或 非官方软件仓库中的软件包时应有预防措施。大部分软件包都是由用户提供的,并不能提供和官方软件仓库相同的质量。谨慎使用 AUR helpers ,他们简化了 AUR 中的软件包的安装过程, 在编译和安装 AUR 中的软件包之前,务必检查软件包的 PKGBUILD 确保其中不含有错误或恶意的代码。

只在绝对必要的情况下使用第三方的软件仓库.pacman/Tips and tricks#Maintenance提供了清理软件的方法。

Update the mirrorlist

Update pacman's mirrorlist, as the quality of mirrors can vary over time, and some might go offline or their download rate might degrade.

See mirrors for details.

Clean the filesystem

When looking for files to remove, it is important to find the files that take up the most disk space. Programs that help with this are found in:

Old configuration files

Old configuration files may conflict with newer software versions, or corrupt over time. Remove unneeded configurations periodically, particularly in your home folder and ~/.config. For similar reasons, be careful when sharing home folders between installations.

Look for the following folders:

  • ~/.config/ -- where apps stores their configuration
  • ~/.cache/ -- cache of some programs may grow in size
  • ~/.local/share/ -- old files may be lying there

See XDG Base Directory support for more information.

To keep the home directory clean from temporary files created at the wrong place, it is a good idea to manage a list of unwanted files and remove them regularly, for example with rmshit.py.

rmlint can be used to find and optionally remove duplicate files, empty files, recursive empty directories and broken symlinks.

Unused packages

Remove unused packages from the system to free up disk space and simplify maintenance.

See Pacman/Tips and tricks#Removing unused packages for details.

Package cache

Remove unwanted .pkg files from /var/cache/pacman/pkg/to free up disk space.

See Pacman#Cleaning the package cache for more information.

Broken symlinks

Old, broken symbolic links might be sitting around your system; you should remove them. Examples on achieving this can be found here and here.

To quickly list all the broken symlinks of your system, use:

 # find . -type l -! -exec test -e {} \; -print

Then inspect and remove unnecessary entries from this list.

Tips and tricks

The following tips are generally not required, but certain users may find them useful.

使用经过验证的软件包

Arch's rolling releases can be a boon for users who want to try the latest features and get upstream updates as soon as possible, but they can also make system maintenance more difficult. To simplify maintenance and improve stability, try to avoid cutting edge software and install only mature and proven software. Such packages are less likely to receive difficult upgrades such as major configuration changes or feature removals. Prefer software that has a strong and active development community, as well as a high number of competent users, in order to simplify support in the event of a problem.

避免使用测试仓库,这些软件包都是实验性质,不适合安装到稳定系统。因此对于AUR中的包以及部分 community 中的包需要一些谨慎,这些开发中的包是直接从上游开发版分支中获取到的,通常会在包的名字上注有:dev, devel, svn, cvs, git, hg, 或是 darcs 的信息。

安装内核的长期支持版本

linux-lts 是 Arch 官方提供的 Linux kernel 的长期支持版本。内核上游开发者针对此版本提供了长期支持,包括安全补丁和功能 backports。适用于需要长期支持的用户,也可以将此内核作为新内核升级的后备内核。

需要编辑 bootloader 的启动加载项,启动到 vmlinuz-linux-ltsinitramfs-linux-lts.img