804 lines
604 KiB
HTML
804 lines
604 KiB
HTML
|
<!DOCTYPE html>
|
|||
|
<html lang="zh"><head><title>Linux 无法启动排查指南</title><meta charset="utf-8"/><link rel="preconnect" href="https://fonts.googleapis.com"/><link rel="preconnect" href="https://fonts.gstatic.com"/><link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=IBM Plex Mono&family=Noto Serif Simplified Chinese:wght@400;700&family=Source Sans Pro:ital,wght@0,400;0,600;1,400;1,600&display=swap"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><meta property="og:title" content="Linux 无法启动排查指南"/><meta property="og:description" content="本指南提供Linux无法启动时的系统性排查与解决方法,涵盖BIOS/UEFI设置、引导加载、内核加载、文件系统修复、服务管理、用户环境、硬件兼容性和系统重装等。."/><meta property="og:image" content="https://wiki.7wate.com/static/og-image.png"/><meta property="og:width" content="1200"/><meta property="og:height" content="675"/><link rel="icon" href="../../../../static/icon.png"/><meta name="description" content="本指南提供Linux无法启动时的系统性排查与解决方法,涵盖BIOS/UEFI设置、引导加载、内核加载、文件系统修复、服务管理、用户环境、硬件兼容性和系统重装等。."/><meta name="generator" content="Quartz"/><link href="../../../../index.css" rel="stylesheet" type="text/css" spa-preserve/><link href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.9/katex.min.css" rel="stylesheet" type="text/css" spa-preserve/><script src="../../../../prescript.js" type="application/javascript" spa-preserve></script><script type="application/javascript" spa-preserve>const fetchData = fetch("../../../../static/contentIndex.json").then(data => data.json())</script></head><body data-slug="Technology/OperatingSystem/Linux/2.安装/Linux-无法启动排查指南"><div id="quartz-root" class="page"><div id="quartz-body"><div class="left sidebar"><h2 class="page-title"><a href="../../../..">🪴 X·Eden</a></h2><div class="spacer mobile-only"></div><div class="search"><button class="search-button" id="search-button"><p>搜索</p><svg role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 19.9 19.7"><title>Search</title><g class="search-path" fill="none"><path stroke-linecap="square" d="M18.5 18.3l-5.4-5.4"></path><circle cx="8" cy="8" r="7"></circle></g></svg></button><div id="search-container"><div id="search-space"><input autocomplete="off" id="search-bar" name="search" type="text" aria-label="搜索些什么" placeholder="搜索些什么"/><div id="search-layout" data-preview="true"></div></div></div></div><button class="darkmode" id="darkmode"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="dayIcon" x="0px" y="0px" viewBox="0 0 35 35" style="enable-background:new 0 0 35 35" xml:space="preserve" aria-label="暗色模式"><title>暗色模式</title><path d="M6,17.5C6,16.672,5.328,16,4.5,16h-3C0.672,16,0,16.672,0,17.5 S0.672,19,1.5,19h3C5.328,19,6,18.328,6,17.5z M7.5,26c-0.414,0-0.789,0.168-1.061,0.439l-2,2C4.168,28.711,4,29.086,4,29.5 C4,30.328,4.671,31,5.5,31c0.414,0,0.789-0.168,1.06-0.44l2-2C8.832,28.289,9,27.914,9,27.5C9,26.672,8.329,26,7.5,26z M17.5,6 C18.329,6,19,5.328,19,4.5v-3C19,0.672,18.329,0,17.5,0S16,0.672,16,1.5v3C16,5.328,16.671,6,17.5,6z M27.5,9 c0.414,0,0.789-0.168,1.06-0.439l2-2C30.832,6.289,31,5.914,31,5.5C31,4.672,30.329,4,29.5,4c-0.414,0-0.789,0.168-1.061,0.44 l-2,2C26.168,6.711,26,7.086,26,7.5C26,8.328,26.671,9,27.5,9z M6.439,8.561C6.711,8.832,7.086,9,7.5,9C8.328,9,9,8.328,9,7.5 c0-0.414-0.168-0.789-0.439-1.061l-2-2C6.289,4.168,5.914,4,5.5,4C4.672,4,4,4.672,4,5.5c0,0.414,0.168,0.789,0.439,1.06 L6.439,8.561z M33.5,16h-3c-0.828,0-1.5,0.672-1.5,1.5s0.672,1.5,1.5,1.5h3c0.828,0,1.5-0.672,1.5-1.5S34.328,16,33.5,16z M28.561,26.439C28.289,26.168,27.914,26,27.5,26c-0.828,0-1.5,0.672-1.5,1.5c0,0.414,0.168,0.789,0.439,1.06l2,2 C28.711,30.832,29.086,31,29.5,31c0.828,0,1.5-0.672,1.5-1.5c0-0.414-0.168-0.789-0.439-1.061L28.561,26.439z M17.5,29 c-0.8
|
|||
|
<p>本文档系统性地介绍了 Linux 操作系统在无法正常启动时的排查与解决方法。本文档旨在为系统管理员和高级用户提供一套全面的方法论,以有效识别、诊断和解决操作系统启动过程中可能遇到的问题。该手册涵盖了从引导加载器到用户环境的各个层面,并提供了详细的操作步骤和解决方案。</p>
|
|||
|
<h2 id="1-引言">1. 引言<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#1-引言" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h2>
|
|||
|
<p>Linux 系统广泛应用于服务器、工作站和嵌入式设备中。尽管 Linux 被誉为稳定和可靠的操作系统,但启动失败的问题仍然可能由于多种原因而发生。排查 Linux 系统启动问题是一个复杂且具有挑战性的过程,涉及多种系统组件的协同工作。为了帮助用户更有效地解决此类问题,本文档将详细探讨从 BIOS/UEFI 设置到用户空间环境的各个阶段,并提供系统化的排查与修复指南。</p>
|
|||
|
<h2 id="2-引导加载阶段的排查">2. 引导加载阶段的排查<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#2-引导加载阶段的排查" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h2>
|
|||
|
<h3 id="21-biosuefi-设置问题">2.1 BIOS/UEFI 设置问题<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#21-biosuefi-设置问题" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
|
|||
|
<h4 id="211-问题描述">2.1.1 问题描述<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#211-问题描述" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<p>BIOS(基本输入输出系统)或 UEFI(统一可扩展固件接口)是启动过程中最先被执行的固件程序。错误的设置可能导致系统无法正确加载 Linux 操作系统。</p>
|
|||
|
<h4 id="212-解决方案">2.1.2 解决方案<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#212-解决方案" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<ol>
|
|||
|
<li><strong>检查启动顺序</strong>:
|
|||
|
<ul>
|
|||
|
<li>进入 BIOS/UEFI 设置界面(通常通过按下 <code>Del</code>, <code>F2</code>, <code>Esc</code> 或 <code>F10</code> 键)。</li>
|
|||
|
<li>确保硬盘或 SSD 被设置为第一启动设备。</li>
|
|||
|
<li>如果使用 UEFI,请确保选择了正确的引导模式(UEFI 或 Legacy)。</li>
|
|||
|
</ul>
|
|||
|
</li>
|
|||
|
<li><strong>UEFI/Legacy 模式</strong>:
|
|||
|
<ul>
|
|||
|
<li>确保与系统安装时的启动模式一致。如果系统是以 UEFI 模式安装的,则需要在 UEFI 模式下启动;反之亦然。</li>
|
|||
|
</ul>
|
|||
|
</li>
|
|||
|
</ol>
|
|||
|
<h3 id="22-grub-引导加载器问题">2.2 GRUB 引导加载器问题<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#22-grub-引导加载器问题" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
|
|||
|
<h4 id="221-问题描述">2.2.1 问题描述<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#221-问题描述" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<p>GRUB(Grand Unified Bootloader)是常用的引导加载器,它负责加载 Linux 内核。如果 GRUB 配置文件损坏或丢失,可能导致无法进入操作系统。</p>
|
|||
|
<h4 id="222-解决方案">2.2.2 解决方案<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#222-解决方案" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<ol>
|
|||
|
<li>
|
|||
|
<p><strong>GRUB 命令行修复</strong>:如果系统停留在 GRUB 命令行界面,可以手动引导:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">set</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> root=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">hd0,1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># 设置根分区,可能需要调整分区编号</span></span>
|
|||
|
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">linux</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /vmlinuz-xxx</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> root=/dev/sda1</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> ro</span></span>
|
|||
|
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">initrd</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /initrd.img-xxx</span></span>
|
|||
|
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">boot</span></span></code></pre></figure>
|
|||
|
<p>若手动引导成功,需在进入系统后重新安装和配置 GRUB:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> grub-install</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /dev/sda</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 安装到主硬盘</span></span>
|
|||
|
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> update-grub</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 更新 GRUB 配置</span></span></code></pre></figure>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>使用 Live CD/USB 修复 GRUB</strong>:从 Live CD/USB 启动系统,打开终端:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> mount</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /dev/sda1</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /mnt</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 假设 /dev/sda1 是根分区</span></span>
|
|||
|
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> grub-install</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --root-directory=/mnt</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /dev/sda</span></span>
|
|||
|
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> chroot</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /mnt</span></span>
|
|||
|
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">update-grub</span></span></code></pre></figure>
|
|||
|
<p>重启系统,检查问题是否解决。</p>
|
|||
|
</li>
|
|||
|
</ol>
|
|||
|
<h3 id="23-mbr-和-gpt-分区表问题">2.3 MBR 和 GPT 分区表问题<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#23-mbr-和-gpt-分区表问题" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
|
|||
|
<h4 id="231-问题描述">2.3.1 问题描述<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#231-问题描述" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<p>MBR(Master Boot Record)和 GPT(GUID Partition Table)是两种主要的分区表格式。系统启动失败有时可能与损坏的分区表或不兼容的分区表格式有关。如果分区表损坏或引导记录丢失,系统将无法正确引导。</p>
|
|||
|
<h4 id="232-解决方案">2.3.2 解决方案<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#232-解决方案" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<ol>
|
|||
|
<li>
|
|||
|
<p><strong>检查分区表类型与兼容性</strong>:</p>
|
|||
|
<ul>
|
|||
|
<li>在 BIOS/UEFI 中,确认是否与系统的分区表格式(MBR 或 GPT)兼容。如果使用 UEFI 模式,则应使用 GPT 分区表;而 Legacy 模式通常需要 MBR 分区表。</li>
|
|||
|
<li>使用 <code>fdisk -l</code> 或 <code>gdisk -l</code> 检查当前硬盘的分区表格式。</li>
|
|||
|
</ul>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>修复 MBR</strong>:如果使用的是 MBR 分区表并且怀疑其损坏,可以使用以下命令修复 MBR:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> dd</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> if=/usr/lib/syslinux/mbr/mbr.bin</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> of=/dev/sda</span></span></code></pre></figure>
|
|||
|
<p>或者通过 Windows 的 <code>bootrec</code> 工具修复:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">bootrec</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /fixmbr</span></span></code></pre></figure>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>修复 GPT</strong>:对于 GPT 分区表,如果有损坏,可以使用 <code>gdisk</code> 工具修复:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> gdisk</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /dev/sda</span></span></code></pre></figure>
|
|||
|
<p>在 <code>gdisk</code> 提示符下输入 <code>v</code> 检查 GPT 的一致性,输入 <code>w</code> 写入并退出。</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>重建分区表</strong>:如果分区表严重损坏且无法修复,可能需要从头创建新的分区表。这将导致数据丢失,因此建议先备份数据,然后使用 <code>parted</code> 或 <code>gparted</code> 重建分区表。</p>
|
|||
|
</li>
|
|||
|
</ol>
|
|||
|
<h3 id="24-efi-引导文件问题">2.4 EFI 引导文件问题<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#24-efi-引导文件问题" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
|
|||
|
<h4 id="241-问题描述">2.4.1 问题描述<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#241-问题描述" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<p>在 UEFI 系统中,EFI 引导文件(通常存储在 EFI 系统分区内)负责引导操作系统。如果 EFI 引导文件丢失或损坏,系统将无法启动。</p>
|
|||
|
<h4 id="242-解决方案">2.4.2 解决方案<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#242-解决方案" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<ol>
|
|||
|
<li>
|
|||
|
<p><strong>确认 EFI 系统分区的挂载</strong>:使用以下命令检查 EFI 系统分区是否正确挂载:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">ls</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /boot/efi</span></span></code></pre></figure>
|
|||
|
<p>如果 EFI 分区未挂载,手动挂载它:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> mount</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /dev/sda1</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /boot/efi</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 假设 /dev/sda1 是 EFI 分区</span></span></code></pre></figure>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>重建 EFI 引导文件</strong>:使用 <code>efibootmgr</code> 工具重建 EFI 引导条目:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> efibootmgr</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --create</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --disk</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /dev/sda</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --part</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 1</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --label</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "Linux"</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --loader</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> \\</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">EFI</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">\\</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">debian</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">\\</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">grubx64.efi</span></span></code></pre></figure>
|
|||
|
<p>在某些情况下,可能需要手动复制 GRUB EFI 文件到 EFI 分区:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> cp</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /boot/grub/x86_64-efi/grub.efi</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /boot/efi/EFI/ubuntu/grubx64.efi</span></span></code></pre></figure>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>修复 EFI 引导条目</strong>:如果 BIOS/UEFI 无法检测到正确的 EFI 引导条目,使用 Live CD/USB 重新安装 GRUB 到 EFI 分区:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> grub-install</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --target=x86_64-efi</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --efi-directory=/boot/efi</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --bootloader-id=GRUB</span></span>
|
|||
|
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> update-grub</span></span></code></pre></figure>
|
|||
|
</li>
|
|||
|
</ol>
|
|||
|
<h3 id="25-引导配置文件如-grubcfg损坏">2.5 引导配置文件(如 <code>grub.cfg</code>)损坏<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#25-引导配置文件如-grubcfg损坏" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
|
|||
|
<h4 id="251-问题描述">2.5.1 问题描述<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#251-问题描述" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<p>GRUB 的引导配置文件 <code>grub.cfg</code> 可能因配置错误或损坏而导致系统无法正常启动。</p>
|
|||
|
<h4 id="252-解决方案">2.5.2 解决方案<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#252-解决方案" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<ol>
|
|||
|
<li>
|
|||
|
<p><strong>重建 <code>grub.cfg</code></strong>:进入恢复模式或使用 Live CD/USB 启动,重新生成 <code>grub.cfg</code> 文件:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> grub-mkconfig</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -o</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /boot/grub/grub.cfg</span></span></code></pre></figure>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>检查和修复 <code>grub.cfg</code></strong>:手动检查 <code>grub.cfg</code> 文件中的启动条目,确保路径和分区设置正确,特别是内核和 initrd 的路径。</p>
|
|||
|
</li>
|
|||
|
</ol>
|
|||
|
<h3 id="26-其他引导加载器问题如-lilo-syslinux">2.6 其他引导加载器问题(如 LILO, Syslinux)<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#26-其他引导加载器问题如-lilo-syslinux" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
|
|||
|
<h4 id="261-问题描述">2.6.1 问题描述<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#261-问题描述" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<p>虽然 GRUB 是最常见的引导加载器,但在某些系统中可能使用 LILO 或 Syslinux。如果这些引导加载器配置错误,也会导致无法正常启动。</p>
|
|||
|
<h4 id="262-解决方案">2.6.2 解决方案<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#262-解决方案" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<ol>
|
|||
|
<li>
|
|||
|
<p><strong>LILO 修复</strong>:如果使用 LILO 作为引导加载器,可以通过 Live CD/USB 启动系统,并使用以下命令修复 LILO 配置:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> lilo</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -M</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /dev/sda</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> mbr</span></span>
|
|||
|
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> lilo</span></span></code></pre></figure>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>Syslinux 修复</strong>:对于使用 Syslinux 的系统,可以使用 <code>syslinux-install_update</code> 工具重新安装引导加载器:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> syslinux-install_update</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -i</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -a</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -m</span></span></code></pre></figure>
|
|||
|
</li>
|
|||
|
</ol>
|
|||
|
<h2 id="3-内核加载阶段的排查">3. 内核加载阶段的排查<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#3-内核加载阶段的排查" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h2>
|
|||
|
<h3 id="31-内核崩溃kernel-panic">3.1 内核崩溃(Kernel Panic)<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#31-内核崩溃kernel-panic" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
|
|||
|
<h4 id="311-问题描述">3.1.1 问题描述<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#311-问题描述" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<p>Kernel Panic 是 Linux 内核在遇到无法恢复的错误时发生的现象。可能是由于不兼容的硬件驱动或损坏的内核模块引起。</p>
|
|||
|
<h4 id="312-解决方案">3.1.2 解决方案<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#312-解决方案" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<ol>
|
|||
|
<li><strong>进入安全模式</strong>:在 GRUB 菜单中选择<strong>高级选项</strong>,然后选择一个带有 <code>(recovery mode)</code> 的内核版本。</li>
|
|||
|
<li><strong>禁用 <code>quiet</code> 和 <code>splash</code> 参数</strong>:编辑 GRUB 启动参数(在 GRUB 菜单中按 <code>e</code>),删除 <code>quiet</code> 和 <code>splash</code> 选项,以便详细查看启动日志。</li>
|
|||
|
<li><strong>使用旧版本内核</strong>:选择旧版本的内核启动系统。如果旧内核可以正常启动,说明问题可能出在新内核或新模块上。可以通过移除或重新编译问题模块来解决。</li>
|
|||
|
</ol>
|
|||
|
<h3 id="32-内核模块加载失败">3.2 内核模块加载失败<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#32-内核模块加载失败" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
|
|||
|
<h4 id="321-问题描述">3.2.1 问题描述<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#321-问题描述" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<p>内核模块加载失败通常与硬件不兼容或模块配置错误有关。</p>
|
|||
|
<h4 id="322-解决方案">3.2.2 解决方案<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#322-解决方案" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<ol>
|
|||
|
<li>
|
|||
|
<p><strong>检查内核日志</strong>:使用 <code>dmesg</code> 或 <code>cat /var/log/kern.log</code> 查看内核日志,查找模块加载失败的相关错误信息。</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>禁用或重新编译模块</strong>:如果确定是某个特定模块导致问题,可以尝试禁用该模块。例如,编辑 <code>/etc/modprobe.d/blacklist.conf</code> 文件,将模块加入黑名单:</p>
|
|||
|
</li>
|
|||
|
</ol>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> blacklist</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 模块名</span></span></code></pre></figure>
|
|||
|
<p>或者重新编译内核并调整模块配置,以确保模块的兼容性。</p>
|
|||
|
<h3 id="33-内核参数错误">3.3 内核参数错误<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#33-内核参数错误" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
|
|||
|
<h4 id="331-问题描述">3.3.1 问题描述<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#331-问题描述" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<p>内核启动参数是影响内核行为的关键因素。配置错误或不兼容的内核参数可能导致系统无法正常启动。</p>
|
|||
|
<h4 id="332-解决方案">3.3.2 解决方案<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#332-解决方案" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<ol>
|
|||
|
<li><strong>检查并修改内核启动参数</strong>:
|
|||
|
<ul>
|
|||
|
<li>在 GRUB 菜单中,按 <code>e</code> 编辑启动条目,检查 <code>linux</code> 行中的启动参数。</li>
|
|||
|
<li>确保没有冲突的参数,如过度调优的内存参数或与硬件不兼容的选项。常见的参数包括 <code>nomodeset</code>(禁用内核模式设置)、<code>acpi=off</code>(禁用 ACPI)等。</li>
|
|||
|
<li>如果怀疑参数有问题,尝试移除或调整特定参数并启动系统。</li>
|
|||
|
</ul>
|
|||
|
</li>
|
|||
|
<li><strong>恢复默认启动参数</strong>:如果内核启动参数被修改,导致系统无法启动,可以通过 GRUB 菜单恢复到默认启动参数。例如,通过选择不带特殊参数的内核版本或恢复模式启动。</li>
|
|||
|
</ol>
|
|||
|
<h3 id="34-内核升级或降级问题">3.4 内核升级或降级问题<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#34-内核升级或降级问题" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
|
|||
|
<h4 id="341-问题描述">3.4.1 问题描述<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#341-问题描述" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<p>在内核升级或降级过程中,可能会引入不兼容的问题,导致系统在加载新的或旧的内核时失败。</p>
|
|||
|
<h4 id="342-解决方案">3.4.2 解决方案<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#342-解决方案" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<ol>
|
|||
|
<li>
|
|||
|
<p><strong>切换到不同版本的内核</strong>:在 GRUB 菜单中选择<strong>高级选项</strong>,然后选择<strong>不同版本的内核</strong>进行启动。确认问题是否与特定内核版本相关。</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>回退到上一个工作内核</strong>:如果新内核导致问题,使用以下命令卸载问题内核并安装上一个稳定的内核:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> apt-get</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> remove</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> linux-image-版本号</span></span>
|
|||
|
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> apt-get</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> install</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> linux-image-旧版本号</span></span></code></pre></figure>
|
|||
|
<p>更新 GRUB 并重启系统:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> update-grub</span></span>
|
|||
|
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> reboot</span></span></code></pre></figure>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>检查内核依赖</strong>:内核升级或降级过程中,可能需要更新或回退与内核相关的驱动程序或模块。使用 <code>dkms</code> 工具管理这些模块,并确保它们与当前内核版本兼容:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> dkms</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> status</span></span>
|
|||
|
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> dkms</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> install</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 模块名/版本号</span></span></code></pre></figure>
|
|||
|
</li>
|
|||
|
</ol>
|
|||
|
<h3 id="35-内核和初始内存盘initramfs问题">3.5 内核和初始内存盘(initramfs)问题<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#35-内核和初始内存盘initramfs问题" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
|
|||
|
<h4 id="351-问题描述">3.5.1 问题描述<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#351-问题描述" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<p><code>initramfs</code> 是一个临时文件系统,负责在根文件系统挂载之前提供必要的驱动和工具。如果 <code>initramfs</code> 文件损坏或配置错误,系统可能无法启动。</p>
|
|||
|
<h4 id="352-解决方案">3.5.2 解决方案<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#352-解决方案" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<ol>
|
|||
|
<li>
|
|||
|
<p><strong>重建 <code>initramfs</code></strong>:使用 Live CD/USB 启动系统或进入恢复模式,重建 <code>initramfs</code>:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> update-initramfs</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -u</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -k</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> all</span></span></code></pre></figure>
|
|||
|
<p>确保所有必要的驱动程序和模块被正确包含在 <code>initramfs</code> 中。</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>检查 <code>initramfs</code> 配置</strong>:确保 <code>/etc/initramfs-tools/conf.d/</code> 中的配置文件没有错误,特别是 <code>MODULES</code> 和 <code>BOOT</code> 参数是否设置正确。</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>检查 <code>initramfs</code> 损坏情况</strong>:检查 <code>/boot</code> 目录下的 <code>initrd.img</code> 文件是否存在并正确。可以通过重新生成或从备份中恢复损坏的文件:</p>
|
|||
|
</li>
|
|||
|
</ol>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> mkinitramfs</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -o</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /boot/initrd.img-</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">$(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">uname</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -r</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span></code></pre></figure>
|
|||
|
<h3 id="36-硬件兼容性与内核驱动问题">3.6 硬件兼容性与内核驱动问题<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#36-硬件兼容性与内核驱动问题" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
|
|||
|
<h4 id="361-问题描述">3.6.1 问题描述<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#361-问题描述" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<p>某些硬件设备可能与当前内核不兼容,或者需要特定的驱动程序支持。如果缺少必要的驱动,内核可能无法正常加载或初始化设备,导致启动失败。</p>
|
|||
|
<h4 id="362-解决方案">3.6.2 解决方案<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#362-解决方案" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<ol>
|
|||
|
<li>
|
|||
|
<p><strong>检查硬件兼容性</strong>:使用 <code>lspci</code>、<code>lsusb</code>、<code>dmidecode</code> 等工具查看系统硬件信息,并确认是否与内核兼容。特别注意新安装的硬件设备是否需要额外的驱动支持。</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>安装或更新硬件驱动</strong>:如果硬件设备无法正常工作,尝试安装或更新驱动程序。例如,对于图形设备:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> apt-get</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> install</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> nvidia-driver-版本号</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 对于 NVIDIA 显卡</span></span></code></pre></figure>
|
|||
|
<p>对于其他硬件设备,可能需要从厂商获取并编译驱动程序。</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>内核调试与测试</strong>:</p>
|
|||
|
<ul>
|
|||
|
<li>启用内核调试选项(如 <code>debug</code> 参数),捕获详细的内核日志,并分析硬件初始化过程中可能存在的问题。</li>
|
|||
|
<li>使用 <code>modprobe</code> 命令手动加载或卸载驱动模块,测试硬件设备与内核的兼容性。</li>
|
|||
|
</ul>
|
|||
|
</li>
|
|||
|
</ol>
|
|||
|
<h2 id="4-文件系统的排查与修复">4. 文件系统的排查与修复<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#4-文件系统的排查与修复" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h2>
|
|||
|
<h3 id="41-文件系统完整性检查">4.1 文件系统完整性检查<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#41-文件系统完整性检查" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
|
|||
|
<h4 id="411-问题描述">4.1.1 问题描述<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#411-问题描述" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<p>文件系统损坏会导致系统启动失败,通常表现为无法挂载根分区或其他关键分区。</p>
|
|||
|
<h4 id="412-解决方案">4.1.2 解决方案<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#412-解决方案" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<ol>
|
|||
|
<li>
|
|||
|
<p>使用 <code>fsck</code> 修复文件系统:进入恢复模式或使用 Live CD/USB 启动,并运行以下命令:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> fsck</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /dev/sda1</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 假设 /dev/sda1 是根分区</span></span></code></pre></figure>
|
|||
|
<p>如果提示修复错误,按照提示进行操作。</p>
|
|||
|
</li>
|
|||
|
</ol>
|
|||
|
<h3 id="42-分区挂载问题">4.2 分区挂载问题<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#42-分区挂载问题" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
|
|||
|
<h4 id="421-问题描述">4.2.1 问题描述<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#421-问题描述" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<p>系统无法正确挂载分区可能导致启动失败,通常由 <code>/etc/fstab</code> 配置错误引起。</p>
|
|||
|
<h4 id="422-解决方案">4.2.2 解决方案<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#422-解决方案" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<ol>
|
|||
|
<li>
|
|||
|
<p>检查并修复 <code>/etc/fstab</code>:</p>
|
|||
|
<ul>
|
|||
|
<li>
|
|||
|
<p>使用 Live CD/USB 启动系统并编辑 <code>/etc/fstab</code>,确保挂载点和分区设置正确。</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p>手动尝试挂载分区,验证是否存在问题:</p>
|
|||
|
</li>
|
|||
|
</ul>
|
|||
|
</li>
|
|||
|
</ol>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> mount</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /dev/sda1</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /mnt</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 假设 /mnt 是临时挂载点</span></span></code></pre></figure>
|
|||
|
<ul>
|
|||
|
<li>如果挂载失败,检查分区是否存在物理损坏。</li>
|
|||
|
</ul>
|
|||
|
<h3 id="43-文件系统类型不兼容">4.3 文件系统类型不兼容<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#43-文件系统类型不兼容" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
|
|||
|
<h4 id="431-问题描述">4.3.1 问题描述<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#431-问题描述" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<p>在某些情况下,系统可能尝试挂载一个不支持的文件系统类型,或者文件系统类型在内核中未被正确加载。这通常会导致系统启动失败或某些分区无法挂载。</p>
|
|||
|
<h4 id="432-解决方案">4.3.2 解决方案<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#432-解决方案" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<ol>
|
|||
|
<li>
|
|||
|
<p><strong>确认文件系统类型</strong>:使用 <code>lsblk -f</code> 或 <code>blkid</code> 命令检查分区的文件系统类型,确认分区是否使用了 Linux 支持的文件系统(如 ext4, xfs, btrfs 等)。</p>
|
|||
|
<p>检查内核模块是否支持该文件系统类型。例如 <code>btrfs</code> 文件系统需要 <code>btrfs</code> 模块:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> modprobe</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> btrfs</span></span></code></pre></figure>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>转换文件系统类型</strong>:如果文件系统类型不兼容或需要更换,可以使用工具将文件系统转换为兼容的格式,但在操作前务必备份数据。例如,从 ext2 转换到 ext4:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> tune2fs</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -O</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> extents,uninit_bg,dir_index</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /dev/sda1</span></span>
|
|||
|
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> e2fsck</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -f</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /dev/sda1</span></span></code></pre></figure>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>重新格式化分区</strong>:如果文件系统已损坏且不可修复,可以考虑重新格式化分区(这将清空数据):</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> mkfs.ext4</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /dev/sda1</span></span></code></pre></figure>
|
|||
|
<p>之后,编辑 <code>/etc/fstab</code>,确保系统能够正确挂载该分区。</p>
|
|||
|
</li>
|
|||
|
</ol>
|
|||
|
<h3 id="44-lvm-逻辑卷管理问题">4.4 LVM 逻辑卷管理问题<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#44-lvm-逻辑卷管理问题" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
|
|||
|
<h4 id="441-问题描述">4.4.1 问题描述<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#441-问题描述" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<p>LVM(逻辑卷管理)使得磁盘分区的管理更加灵活,但如果逻辑卷或物理卷出现问题,可能导致系统无法启动或某些分区无法挂载。</p>
|
|||
|
<h4 id="442-解决方案">4.4.2 解决方案<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#442-解决方案" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<ol>
|
|||
|
<li>
|
|||
|
<p><strong>检查 LVM 状态</strong>:使用以下命令检查 LVM 卷组和逻辑卷的状态:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> vgscan</span></span>
|
|||
|
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> lvscan</span></span>
|
|||
|
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> pvscan</span></span></code></pre></figure>
|
|||
|
<p>确保所有的卷组和逻辑卷都处于“active”状态。</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>激活逻辑卷</strong>:如果某个逻辑卷未激活,可以手动激活它:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> vgchange</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -ay</span></span></code></pre></figure>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>修复损坏的 LVM</strong>:使用 <code>lvrepair</code> 和 <code>vgrepair</code> 修复损坏的逻辑卷或卷组。如果 LVM 元数据损坏,可以尝试恢复备份:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> vgcfgrestore</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -f</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /etc/lvm/archive/your_volume_group_name</span></span></code></pre></figure>
|
|||
|
</li>
|
|||
|
</ol>
|
|||
|
<h3 id="45-raid-阵列问题">4.5 RAID 阵列问题<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#45-raid-阵列问题" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
|
|||
|
<h4 id="451-问题描述">4.5.1 问题描述<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#451-问题描述" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<p>如果系统使用软件 RAID 阵列(如 mdadm),在启动时某个 RAID 阵列无法正确加载或同步,可能导致系统启动失败或数据不可访问。</p>
|
|||
|
<h4 id="452-解决方案">4.5.2 解决方案<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#452-解决方案" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<ol>
|
|||
|
<li>
|
|||
|
<p><strong>检查 RAID 阵列状态</strong>:使用 <code>cat /proc/mdstat</code> 查看 RAID 阵列状态,确认所有阵列都在运行。使用 <code>mdadm</code> 命令详细检查 RAID 阵列:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> mdadm</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --detail</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /dev/md0</span></span></code></pre></figure>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>修复 RAID 阵列</strong>:如果 RAID 阵列出现降级(degraded)或设备丢失,可以尝试重新添加丢失的设备:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> mdadm</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --manage</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /dev/md0</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --add</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /dev/sdX</span></span></code></pre></figure>
|
|||
|
<p>如果 RAID 阵列同步失败,可能需要重新同步:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> mdadm</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --grow</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /dev/md0</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --raid-devices=2</span></span></code></pre></figure>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>重建 RAID 阵列</strong>:如果 RAID 阵列损坏严重,需要重新构建。备份数据后,可以重新创建 RAID 阵列并恢复数据:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> mdadm</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --create</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /dev/md0</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --level=1</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --raid-devices=2</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /dev/sda1</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /dev/sdb1</span></span></code></pre></figure>
|
|||
|
</li>
|
|||
|
</ol>
|
|||
|
<h3 id="46-其他文件系统工具">4.6 其他文件系统工具<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#46-其他文件系统工具" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
|
|||
|
<h4 id="461-问题描述">4.6.1 问题描述<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#461-问题描述" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<p>不同的文件系统类型有各自专用的检查和修复工具。未使用正确的工具可能导致检查或修复失败。</p>
|
|||
|
<h4 id="462-解决方案">4.6.2 解决方案<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#462-解决方案" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<ol>
|
|||
|
<li>
|
|||
|
<p><strong>使用文件系统专用工具</strong>:对于 <code>xfs</code> 文件系统,使用 <code>xfs_repair</code> 而不是 <code>fsck</code>:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> xfs_repair</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /dev/sda1</span></span></code></pre></figure>
|
|||
|
<p>对于 <code>btrfs</code> 文件系统,使用 <code>btrfs check</code> 或 <code>btrfs scrub</code>:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> btrfs</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> check</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /dev/sda1</span></span>
|
|||
|
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> btrfs</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> scrub</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> start</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /mnt</span></span></code></pre></figure>
|
|||
|
<p>对于 <code>reiserfs</code> 文件系统,使用 <code>reiserfsck</code>:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> reiserfsck</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --check</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /dev/sda1</span></span></code></pre></figure>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>检查文件系统空间使用情况</strong>:如果文件系统使用率达到 100%,可能导致系统异常。使用 <code>df -h</code> 检查各分区的使用情况,并清理不必要的文件。</p>
|
|||
|
</li>
|
|||
|
</ol>
|
|||
|
<h2 id="5-启动服务的排查与修复">5. 启动服务的排查与修复<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#5-启动服务的排查与修复" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h2>
|
|||
|
<h3 id="51-systemd-服务故障">5.1 Systemd 服务故障<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#51-systemd-服务故障" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
|
|||
|
<h4 id="511-问题描述">5.1.1 问题描述<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#511-问题描述" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<p><code>systemd</code> 是现代 Linux 系统的初始化系统,负责管理系统启动时的服务。如果某些关键服务启动失败,可能导致系统卡住或无法正常启动。</p>
|
|||
|
<h4 id="512-解决方案">5.1.2 解决方案<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#512-解决方案" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<ol>
|
|||
|
<li>
|
|||
|
<p><strong>进入恢复模式</strong>:</p>
|
|||
|
<ul>
|
|||
|
<li>在 GRUB 菜单中选择恢复模式,进入单用户模式或维护模式。</li>
|
|||
|
</ul>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>检查失败的服务</strong>:使用 <code>systemctl</code> 查看启动失败的服务:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">systemctl</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> list-units</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --failed</span></span></code></pre></figure>
|
|||
|
<p>对于识别的失败服务,可以尝试禁用或重新启动:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> systemctl</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> disable</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 服务名</span></span>
|
|||
|
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> systemctl</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> restart</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 服务名</span></span></code></pre></figure>
|
|||
|
<p>检查相关日志文件 <code>/var/log/syslog</code> 或 <code>journalctl</code>,进一步分析失败原因。</p>
|
|||
|
</li>
|
|||
|
</ol>
|
|||
|
<h3 id="52-非-systemd-系统中的服务管理问题">5.2 非 Systemd 系统中的服务管理问题<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#52-非-systemd-系统中的服务管理问题" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
|
|||
|
<h4 id="521-问题描述">5.2.1 问题描述<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#521-问题描述" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<p>并非所有的 Linux 发行版都使用 systemd 作为其初始化系统。一些较旧或轻量级的发行版可能仍然使用 SysVinit、Upstart 或 OpenRC 等初始化系统。如果这些初始化系统配置错误或服务脚本损坏,可能导致系统启动服务失败。</p>
|
|||
|
<h4 id="522-解决方案">5.2.2 解决方案<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#522-解决方案" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<ol>
|
|||
|
<li>
|
|||
|
<p><strong>SysVinit 系统</strong>:使用 <code>service</code> 命令查看和管理服务的状态:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> service</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 服务名</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> status</span></span>
|
|||
|
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> service</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 服务名</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> start</span></span>
|
|||
|
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> service</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 服务名</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> stop</span></span></code></pre></figure>
|
|||
|
<p>如果某个服务无法启动,检查对应的 <code>/etc/init.d/</code> 脚本是否正确,以及相关配置文件是否存在问题。</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>Upstart 系统</strong>:使用 <code>initctl</code> 命令管理 Upstart 服务:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> initctl</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> list</span></span>
|
|||
|
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> initctl</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> status</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 服务名</span></span>
|
|||
|
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> initctl</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> start</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 服务名</span></span>
|
|||
|
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> initctl</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> stop</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 服务名</span></span></code></pre></figure>
|
|||
|
<p>检查 <code>/etc/init/</code> 中的服务配置文件,确保格式和内容正确。</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>OpenRC 系统</strong>:使用 <code>rc-service</code> 命令管理 OpenRC 服务:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> rc-service</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 服务名</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> start</span></span>
|
|||
|
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> rc-service</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 服务名</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> stop</span></span>
|
|||
|
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> rc-service</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 服务名</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> restart</span></span></code></pre></figure>
|
|||
|
<p>确保 <code>/etc/conf.d/</code> 中的配置文件正确配置,并检查 <code>/etc/init.d/</code> 中的服务脚本是否损坏。</p>
|
|||
|
</li>
|
|||
|
</ol>
|
|||
|
<h3 id="53-服务依赖问题">5.3 服务依赖问题<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#53-服务依赖问题" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
|
|||
|
<h4 id="531-问题描述">5.3.1 问题描述<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#531-问题描述" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<p>服务之间的依赖关系是系统启动顺序中的一个重要部分。如果某些关键服务未按顺序启动或启动失败,可能会导致其他服务无法正常工作。</p>
|
|||
|
<h4 id="532-解决方案">5.3.2 解决方案<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#532-解决方案" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<ol>
|
|||
|
<li>
|
|||
|
<p><strong>检查服务依赖关系</strong>:在 systemd 系统中,可以使用以下命令查看服务的依赖关系:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">systemctl</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> list-dependencies</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 服务名</span></span></code></pre></figure>
|
|||
|
<p>确保所有依赖服务都已正确启动且未报告错误。</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>调整服务启动顺序</strong>:</p>
|
|||
|
<p>如果发现某些服务启动顺序不正确,可以通过修改其配置文件或 <code>systemd</code> 的 <code>After</code> 和 <code>Requires</code> 选项来调整服务的启动顺序。例如,在 <code>/etc/systemd/system/服务名.service</code> 中添加:</p>
|
|||
|
</li>
|
|||
|
</ol>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="ini" data-theme="github-light github-dark"><code data-language="ini" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">[Unit]</span></span>
|
|||
|
<span data-line><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">After</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">=network.target</span></span>
|
|||
|
<span data-line><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">Requires</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">=network.target</span></span></code></pre></figure>
|
|||
|
<ol>
|
|||
|
<li><strong>在非 systemd 系统中管理依赖</strong>:对于使用 SysVinit 的系统,可以编辑 <code>/etc/init.d/</code> 中的服务脚本,确保所需的依赖服务已在脚本中指定(通常通过 <code>Required-Start</code> 和 <code>Required-Stop</code> 标注)。</li>
|
|||
|
</ol>
|
|||
|
<h3 id="54-服务配置文件损坏或缺失">5.4 服务配置文件损坏或缺失<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#54-服务配置文件损坏或缺失" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
|
|||
|
<h4 id="541-问题描述">5.4.1 问题描述<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#541-问题描述" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<p>服务的配置文件可能会因为错误修改、升级不兼容或其他原因而损坏或丢失。这会导致服务无法正确启动或工作。</p>
|
|||
|
<h4 id="542-解决方案">5.4.2 解决方案<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#542-解决方案" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<ol>
|
|||
|
<li>
|
|||
|
<p><strong>检查并恢复配置文件</strong>:使用 <code>systemctl status 服务名</code> 检查服务状态,查看是否有配置文件错误提示。</p>
|
|||
|
<p>通过包管理器重新安装相关服务以恢复默认配置文件。例如:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> apt-get</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> install</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --reinstall</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 服务包名</span></span></code></pre></figure>
|
|||
|
<p>如果系统支持,也可以从 <code>/etc/</code> 的备份中恢复配置文件。</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>手动修复配置文件</strong>:根据服务文档或在线资源,手动检查并修复配置文件。确保语法正确,并符合服务所需的配置要求。</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>验证配置文件</strong>:对于一些服务,可以使用自带的验证工具来检查配置文件的正确性。例如,Nginx 提供以下命令来验证配置:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> nginx</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -t</span></span></code></pre></figure>
|
|||
|
</li>
|
|||
|
</ol>
|
|||
|
<h3 id="55-日志分析与错误排查">5.5 日志分析与错误排查<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#55-日志分析与错误排查" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
|
|||
|
<h4 id="551-问题描述">5.5.1 问题描述<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#551-问题描述" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<p>启动服务失败时,日志文件是排查问题的重要资源。通过分析系统日志和服务专用日志,可以获取服务失败的详细原因。</p>
|
|||
|
<h4 id="552-解决方案">5.5.2 解决方案<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#552-解决方案" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<ol>
|
|||
|
<li>
|
|||
|
<p><strong>使用 <code>journalctl</code> 查看日志</strong>:对于 systemd 系统,使用 <code>journalctl</code> 查看系统和服务日志:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> journalctl</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -u</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 服务名</span></span>
|
|||
|
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> journalctl</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -xe</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 查看最近的错误日志</span></span></code></pre></figure>
|
|||
|
<p>分析日志信息,查找具体错误原因。</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>检查 <code>/var/log/</code> 目录中的日志文件</strong>:某些服务会记录日志到 <code>/var/log/</code> 目录下的专用日志文件中,如 <code>/var/log/nginx/error.log</code> 或 <code>/var/log/mysql/error.log</code>。检查这些日志文件以获取详细错误信息。</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>启用详细日志记录</strong>:对于复杂的问题,可以通过修改服务配置文件启用详细日志记录。例如,在 Nginx 中设置更高的日志记录级别:</p>
|
|||
|
</li>
|
|||
|
</ol>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">error_log</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /var/log/nginx/error.log</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> info</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span></code></pre></figure>
|
|||
|
<p>重新启动服务后,检查日志以获取更多调试信息。</p>
|
|||
|
<h3 id="56-服务权限与用户问题">5.6 服务权限与用户问题<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#56-服务权限与用户问题" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
|
|||
|
<h4 id="561-问题描述">5.6.1 问题描述<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#561-问题描述" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<p>服务通常以特定用户身份运行。如果服务没有足够的权限访问所需的资源或配置文件,可能导致启动失败或功能异常。</p>
|
|||
|
<h4 id="562-解决方案">5.6.2 解决方案<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#562-解决方案" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<ol>
|
|||
|
<li>
|
|||
|
<p><strong>检查服务的运行用户</strong>:在 systemd 系统中,可以检查服务文件中的 <code>User</code> 和 <code>Group</code> 设置,确认服务以正确的用户身份运行:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">[Service]</span></span>
|
|||
|
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">User</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">服务用户</span></span>
|
|||
|
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">Group</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">服务组</span></span></code></pre></figure>
|
|||
|
<p>如果运行用户不正确,可以通过修改服务文件或重新分配文件和目录的权限来解决问题。</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>修复权限问题</strong>:使用 <code>chown</code> 和 <code>chmod</code> 命令修复文件和目录的权限。例如:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> chown</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -R</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 服务用户:服务组</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /var/lib/服务名</span></span>
|
|||
|
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> chmod</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 755</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /etc/服务名</span></span></code></pre></figure>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>检查 SELinux 或 AppArmor 配置</strong>:如果系统启用了 SELinux 或 AppArmor,需要确认这些安全模块没有阻止服务的运行。使用以下命令检查 SELinux 日志:</p>
|
|||
|
</li>
|
|||
|
</ol>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> ausearch</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -m</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> avc</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -ts</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> recent</span></span></code></pre></figure>
|
|||
|
<p>根据提示调整 SELinux 或 AppArmor 配置,或者暂时将服务设置为 permissive 模式进行排查。</p>
|
|||
|
<h2 id="6-用户环境的排查与修复">6. 用户环境的排查与修复<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#6-用户环境的排查与修复" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h2>
|
|||
|
<h3 id="61-登录问题">6.1 登录问题<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#61-登录问题" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
|
|||
|
<h4 id="611-问题描述">6.1.1 问题描述<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#611-问题描述" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<p>如果系统进入多用户模式后无法登录,可能是由于用户权限问题、认证模块(如 PAM)配置错误、用户配置文件损坏,或其他与登录管理器、Shell 环境配置相关的问题。</p>
|
|||
|
<h4 id="612-解决方案">6.1.2 解决方案<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#612-解决方案" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<ol>
|
|||
|
<li>
|
|||
|
<p><strong>进入恢复模式</strong>:使用恢复模式或 Live CD/USB 进入系统,修改 <code>/etc/passwd</code>、<code>/etc/shadow</code> 或 <code>/etc/sudoers</code> 文件,确保用户具有正确的权限。</p>
|
|||
|
<p>检查用户是否被锁定或密码是否过期,可以使用以下命令解锁用户并重置密码:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> passwd</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 用户名</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 重置密码</span></span>
|
|||
|
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> usermod</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -U</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 用户名</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 解锁用户</span></span></code></pre></figure>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>修复认证模块(PAM)</strong>:</p>
|
|||
|
<ul>
|
|||
|
<li>检查 PAM 配置文件 <code>/etc/pam.d/</code>,确保没有错误配置导致认证失败。可以将配置文件恢复为默认状态,或参考其他工作系统的配置文件进行修复。</li>
|
|||
|
<li>如果是 SSH 登录问题,检查 <code>/etc/ssh/sshd_config</code> 配置文件,确保未禁用合法用户的登录权限。</li>
|
|||
|
</ul>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>修复登录管理器</strong>:如果问题与登录管理器(如 GDM, LightDM, SDDM)有关,尝试重启登录管理器服务:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> systemctl</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> restart</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> gdm</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 以 GDM 为例</span></span></code></pre></figure>
|
|||
|
<p>检查登录管理器的配置文件,确保没有错误配置影响用户登录。如果登录管理器无法启动,可以尝试切换到另一个管理器,确认问题是否与特定软件相关:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> apt-get</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> install</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> lightdm</span></span>
|
|||
|
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> dpkg-reconfigure</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> lightdm</span></span></code></pre></figure>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>重置用户配置文件</strong>:如果是特定用户的配置文件损坏,可以重命名用户的主目录下的配置文件夹(如 <code>.config</code>),然后重新登录系统:</p>
|
|||
|
</li>
|
|||
|
</ol>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">mv</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /home/username/.config</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /home/username/.config.bak</span></span></code></pre></figure>
|
|||
|
<p>检查 <code>.bashrc</code>、<code>.profile</code> 等 Shell 配置文件,确保没有错误配置导致 Shell 环境无法正常加载。</p>
|
|||
|
<ol>
|
|||
|
<li><strong>检查 Shell 环境配置</strong>:确保用户的默认 Shell 正常工作,检查 <code>/etc/passwd</code> 中的 Shell 设置。如果 Shell 程序损坏或配置错误,可以将用户的 Shell 设置为 <code>/bin/bash</code>:</li>
|
|||
|
</ol>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> usermod</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -s</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /bin/bash</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 用户名</span></span></code></pre></figure>
|
|||
|
<h3 id="62-图形界面问题">6.2 图形界面问题<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#62-图形界面问题" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
|
|||
|
<h4 id="621-问题描述">6.2.1 问题描述<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#621-问题描述" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<p>如果 Linux 系统进入图形界面时出现问题(如黑屏、闪屏或 Xorg 崩溃),通常与显示管理器、图形驱动、桌面环境配置、Xorg 或 Wayland 配置相关。</p>
|
|||
|
<h4 id="622-解决方案">6.2.2 解决方案<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#622-解决方案" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<ol>
|
|||
|
<li>
|
|||
|
<p><strong>检查 Xorg 日志</strong>:使用恢复模式或 TTY 终端(<code>Ctrl + Alt + F1-F6</code>)查看 <code>/var/log/Xorg.0.log</code>,查找与显示器或图形驱动相关的错误信息。检查 Xorg 配置文件 <code>/etc/X11/xorg.conf</code>,确保配置正确。如果配置文件丢失或损坏,可以尝试自动生成新的配置文件:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> X</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -configure</span></span>
|
|||
|
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> mv</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> xorg.conf.new</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /etc/X11/xorg.conf</span></span></code></pre></figure>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>重置图形驱动</strong>:尝试重新安装或更新图形驱动程序。例如,使用 <code>apt</code> 重新安装 NVIDIA 驱动:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> apt-get</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> install</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --reinstall</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> nvidia-driver</span></span></code></pre></figure>
|
|||
|
<p>对于 AMD 或 Intel 显卡,可以安装适当的开源驱动程序(如 <code>xserver-xorg-video-amdgpu</code> 或 <code>xserver-xorg-video-intel</code>)。</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>切换图形服务器(Xorg/Wayland)</strong>:如果系统默认使用 Wayland,但存在兼容性问题,可以切换到 Xorg 进行测试。在 GDM 登录屏幕上选择齿轮图标,切换到 “Xorg” 会话。</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>恢复默认桌面环境配置</strong>:如果问题与特定桌面环境配置有关,可以恢复默认配置或删除用户配置文件:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">rm</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -rf</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> ~/.config/xfce4</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 以 XFCE 为例</span></span></code></pre></figure>
|
|||
|
<p>如果桌面环境崩溃,尝试使用一个不同的桌面环境(如从 GNOME 切换到 KDE),确认问题是否与特定桌面环境有关。</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>修复 Display Manager(显示管理器)</strong>:重启显示管理器服务,或者切换到一个不同的显示管理器以排除问题:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> systemctl</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> restart</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> gdm</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 以 GDM 为例</span></span>
|
|||
|
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> dpkg-reconfigure</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> lightdm</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 切换到 LightDM</span></span></code></pre></figure>
|
|||
|
</li>
|
|||
|
</ol>
|
|||
|
<h3 id="63-用户数据与配置恢复">6.3 用户数据与配置恢复<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#63-用户数据与配置恢复" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
|
|||
|
<h4 id="631-问题描述">6.3.1 问题描述<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#631-问题描述" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<p>用户配置文件或数据丢失、损坏可能导致应用程序无法启动或工作不正常,甚至影响用户登录和桌面环境的加载。</p>
|
|||
|
<h4 id="632-解决方案">6.3.2 解决方案<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#632-解决方案" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<ol>
|
|||
|
<li>
|
|||
|
<p><strong>备份与恢复用户数据</strong>:使用 <code>rsync</code> 或 <code>cp</code> 命令备份用户主目录中的重要数据:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">rsync</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -av</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /home/username</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /backup/location/</span></span></code></pre></figure>
|
|||
|
<p>如果用户配置文件损坏,可以从备份中恢复相关文件或目录。</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>修复用户权限</strong>:</p>
|
|||
|
<p>确保用户主目录及其下文件的权限正确,使用 <code>chown</code> 和 <code>chmod</code> 修复权限问题:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> chown</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -R</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> username:username</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /home/username</span></span>
|
|||
|
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> chmod</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -R</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 755</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /home/username</span></span></code></pre></figure>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>清理缓存与临时文件</strong>:删除用户目录下的缓存和临时文件,防止损坏的缓存影响系统启动:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">rm</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -rf</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> ~/.cache/</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">*</span></span>
|
|||
|
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">rm</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -rf</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /tmp/</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">*</span></span></code></pre></figure>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>检查并修复应用程序配置</strong>:如果某个应用程序无法启动,检查其配置文件是否损坏或丢失。可以删除相关配置文件夹让应用程序重新生成默认配置:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">rm</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -rf</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> ~/.config/应用程序名</span></span></code></pre></figure>
|
|||
|
</li>
|
|||
|
</ol>
|
|||
|
<h2 id="7-硬件兼容性检查">7. 硬件兼容性检查<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#7-硬件兼容性检查" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h2>
|
|||
|
<h3 id="71-硬件驱动问题">7.1 硬件驱动问题<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#71-硬件驱动问题" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
|
|||
|
<h4 id="711-问题描述">7.1.1 问题描述<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#711-问题描述" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<p>虽然假设硬件没有问题,但某些硬件可能与当前的 Linux 内核或驱动版本不完全兼容,导致系统无法正常启动。</p>
|
|||
|
<h4 id="712-解决方案">7.1.2 解决方案<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#712-解决方案" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<ol>
|
|||
|
<li>
|
|||
|
<p><strong>检查硬件驱动兼容性</strong>:在恢复模式或 Live CD/USB 中,使用 <code>lspci</code>、<code>lsusb</code> 等工具查看硬件信息,并检查与硬件相关的内核模块是否加载正常。</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>更新内核或驱动程序</strong>:如果发现某个硬件不兼容当前内核,尝试更新内核或特定驱动程序:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> apt-get</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> update</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> && </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> apt-get</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> upgrade</span></span>
|
|||
|
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> apt-get</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> install</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> linux-generic</span></span></code></pre></figure>
|
|||
|
</li>
|
|||
|
</ol>
|
|||
|
<h3 id="72-新硬件与旧内核的兼容性问题">7.2 新硬件与旧内核的兼容性问题<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#72-新硬件与旧内核的兼容性问题" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
|
|||
|
<h4 id="721-问题描述">7.2.1 问题描述<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#721-问题描述" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<p>当在较老的 Linux 内核版本上使用新硬件时,可能会出现兼容性问题,因为较老的内核可能未包含新硬件的驱动程序或支持。这种情况通常会导致系统无法识别或初始化新硬件,从而引发启动失败或系统不稳定的问题。</p>
|
|||
|
<h4 id="722-解决方案">7.2.2 解决方案<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#722-解决方案" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<ol>
|
|||
|
<li>
|
|||
|
<p><strong>检查内核版本与硬件支持</strong>:使用 <code>uname -r</code> 查看当前内核版本,确认是否支持新硬件。如果发现内核版本较旧,可以考虑升级内核。查阅硬件制造商的文档或社区支持页面,确认推荐使用的内核版本。</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>升级到最新内核版本</strong>:使用以下命令安装最新稳定版内核:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> apt-get</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> install</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> linux-generic-hwe-</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">$(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">lsb_release</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -rs</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span></code></pre></figure>
|
|||
|
<p>或者直接从源代码编译最新的主线内核(适用于高级用户):</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">wget</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.x.tar.xz</span></span>
|
|||
|
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">tar</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -xvf</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> linux-6.x.tar.xz</span></span>
|
|||
|
<span data-line><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">cd</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> linux-6.x</span></span>
|
|||
|
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">make</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> menuconfig</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 配置内核</span></span>
|
|||
|
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">make</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -j$(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">nproc</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">)</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> && </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> make</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> modules_install</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> && </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> make</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> install</span></span>
|
|||
|
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> update-grub</span></span></code></pre></figure>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>使用 Linux 发行版的硬件支持扩展包</strong>:某些 Linux 发行版提供硬件支持扩展包,这些包通常包含额外的驱动和内核模块以支持新硬件。例如,Ubuntu 提供硬件启用堆栈(HWE),可通过以下命令安装:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> apt-get</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> install</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --install-recommends</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> linux-generic-hwe-</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">$(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">lsb_release</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -rs</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span></code></pre></figure>
|
|||
|
</li>
|
|||
|
</ol>
|
|||
|
<h3 id="73-外部设备兼容性问题">7.3 外部设备兼容性问题<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#73-外部设备兼容性问题" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
|
|||
|
<h4 id="731-问题描述">7.3.1 问题描述<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#731-问题描述" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<p>外部设备(如 USB 驱动器、打印机、蓝牙设备等)有时可能无法在 Linux 系统上正常工作,尤其是在未正确加载相应驱动或固件的情况下。这会导致设备无法被识别或无法正常使用。</p>
|
|||
|
<h4 id="732-解决方案">7.3.2 解决方案<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#732-解决方案" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<ol>
|
|||
|
<li>
|
|||
|
<p><strong>检查设备连接与识别</strong>:使用 <code>dmesg</code> 命令检查系统日志,确认外部设备是否被正确识别和连接。例如,插入 USB 设备后,查看 <code>dmesg</code> 输出:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">dmesg</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> grep</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> usb</span></span></code></pre></figure>
|
|||
|
<p>使用 <code>lsusb</code> 或 <code>lspci</code> 查看设备列表,确认系统是否识别了外部设备。</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>安装或更新设备驱动</strong>:对于常见设备,使用包管理器安装相应的驱动程序或固件。例如:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> apt-get</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> install</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> printer-driver-gutenprint</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 打印机驱动</span></span>
|
|||
|
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> apt-get</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> install</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> bluez</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 蓝牙驱动</span></span></code></pre></figure>
|
|||
|
<p>对于特殊设备(如某些厂商特定的硬件),可能需要从厂商网站下载驱动并手动安装。</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>检查并加载固件</strong>:某些外部设备需要特定的固件才能正常工作。使用 <code>dmesg</code> 检查是否有固件加载失败的错误信息,并根据提示安装缺少的固件包。例如:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> apt-get</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> install</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> firmware-linux-nonfree</span></span></code></pre></figure>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>调整设备的电源管理设置</strong>:外部设备可能由于电源管理设置而无法正常工作,尤其是在便携式计算机上。禁用自动挂起或调整电源管理策略:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> powertop</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --auto-tune</span></span></code></pre></figure>
|
|||
|
</li>
|
|||
|
</ol>
|
|||
|
<h3 id="74-biosuefi-固件相关问题">7.4 BIOS/UEFI 固件相关问题<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#74-biosuefi-固件相关问题" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
|
|||
|
<h4 id="741-问题描述">7.4.1 问题描述<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#741-问题描述" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<p>BIOS/UEFI 固件版本过旧或配置不当可能导致硬件兼容性问题,特别是在处理器、内存、存储设备和显卡等关键硬件的初始化过程中。</p>
|
|||
|
<h4 id="742-解决方案">7.4.2 解决方案<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#742-解决方案" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<ol>
|
|||
|
<li>
|
|||
|
<p><strong>更新 BIOS/UEFI 固件</strong>:</p>
|
|||
|
<ul>
|
|||
|
<li>访问硬件制造商的网站,检查是否有更新的 BIOS/UEFI 固件版本可用。下载并按照制造商的指示进行升级。</li>
|
|||
|
<li>注意:更新 BIOS/UEFI 固件存在风险,可能会导致系统无法启动,因此务必备份重要数据并严格按照指导操作。</li>
|
|||
|
</ul>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>调整 BIOS/UEFI 设置</strong>:进入 BIOS/UEFI 设置界面(通常通过按 <code>Del</code>、<code>F2</code>、<code>Esc</code> 或 <code>F10</code> 键),确认以下设置:</p>
|
|||
|
<ul>
|
|||
|
<li><strong>Secure Boot</strong>:对于一些 Linux 发行版,建议禁用 Secure Boot 以避免驱动签名问题。</li>
|
|||
|
<li><strong>Legacy/UEFI Boot Mode</strong>:确保启动模式与操作系统安装时的配置一致。</li>
|
|||
|
<li><strong>SATA 模式</strong>:对于硬盘控制器,尝试切换 SATA 模式(AHCI/IDE),确保与系统兼容。</li>
|
|||
|
<li><strong>内存设置</strong>:检查内存频率和时序,确认是否与硬件配置匹配。</li>
|
|||
|
</ul>
|
|||
|
</li>
|
|||
|
</ol>
|
|||
|
<h3 id="75-硬件故障排查">7.5 硬件故障排查<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#75-硬件故障排查" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
|
|||
|
<h4 id="751-问题描述">7.5.1 问题描述<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#751-问题描述" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<p>虽然假设硬件没有问题,但在某些情况下,硬件故障仍然可能导致启动失败或系统不稳定。内存错误、硬盘损坏或过热问题都可能在启动过程中表现为系统问题。</p>
|
|||
|
<h4 id="752-解决方案">7.5.2 解决方案<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#752-解决方案" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<ol>
|
|||
|
<li>
|
|||
|
<p><strong>内存检测</strong>:使用 <code>memtest86+</code> 工具检查内存模块是否存在错误。大多数 Linux 发行版的启动菜单中包含此工具,可以选择运行以检测内存问题。如果检测到内存错误,考虑更换内存模块。</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>硬盘健康检查</strong>:使用 <code>smartctl</code> 工具检查硬盘的 S.M.A.R.T 状态,以评估硬盘的健康状况:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> smartctl</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -a</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /dev/sda</span></span></code></pre></figure>
|
|||
|
<p>如果发现硬盘存在错误或即将故障,备份数据并考虑更换硬盘。</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>系统温度与散热检查</strong>:使用 <code>sensors</code> 工具检查 CPU 和 GPU 温度,确保系统在正常温度范围内工作:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> apt-get</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> install</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> lm-sensors</span></span>
|
|||
|
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sensors</span></span></code></pre></figure>
|
|||
|
<p>如果温度过高,检查散热器和风扇是否正常工作,并清理机箱内部的灰尘。</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>其他硬件检测</strong>:对于怀疑可能出现问题的其他硬件(如显卡、主板),可以尝试使用替代硬件进行测试</p>
|
|||
|
</li>
|
|||
|
</ol>
|
|||
|
<h2 id="8-恢复与重装系统">8. 恢复与重装系统<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#8-恢复与重装系统" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h2>
|
|||
|
<h3 id="81-数据备份">8.1 数据备份<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#81-数据备份" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
|
|||
|
<p>在执行任何可能导致数据丢失或系统变更的操作之前,备份数据是确保系统恢复能力的关键步骤。通过系统备份,可以防止在系统修复或重装过程中丢失重要数据。</p>
|
|||
|
<h4 id="811-备份策略">8.1.1 备份策略<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#811-备份策略" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<ol>
|
|||
|
<li>
|
|||
|
<p><strong>选择适当的备份方案</strong>:</p>
|
|||
|
<ul>
|
|||
|
<li>根据数据的重要性和系统环境,选择全备份、增量备份或差异备份方案。</li>
|
|||
|
<li>对于关键数据(如用户的家庭目录、数据库文件等),建议采用全备份的方式,而对于不经常变化的大量数据,可以采用增量备份以节省空间。</li>
|
|||
|
</ul>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>确定备份存储位置</strong>:</p>
|
|||
|
<ul>
|
|||
|
<li>使用外部存储设备(如 USB 硬盘、NAS、云存储等)作为备份目标,以确保备份数据在原始系统故障时的安全性。</li>
|
|||
|
<li>使用 RAID 阵列或磁盘镜像技术提高本地存储的可靠性。</li>
|
|||
|
</ul>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>使用适当的工具进行备份</strong>:使用 <code>rsync</code></p>
|
|||
|
<p>工具进行增量备份,确保仅复制变更的数据,节省时间和空间:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">rsync</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -av</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --delete</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /home/username</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /mnt/backup/</span></span></code></pre></figure>
|
|||
|
<p>使用 <code>tar</code> 工具创建完整的归档备份,便于之后的恢复:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">tar</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -cvpzf</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /mnt/backup/username-backup.tar.gz</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /home/username</span></span></code></pre></figure>
|
|||
|
<p>对于企业级备份,可以使用 <code>Bacula</code>、<code>Amanda</code> 或 <code>Duplicity</code> 等备份软件,以实现自动化和远程备份。</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>验证备份有效性</strong>:定期测试备份文件的完整性和可恢复性,确保备份在需要时能够成功恢复:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">tar</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -tvf</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /mnt/backup/username-backup.tar.gz</span></span></code></pre></figure>
|
|||
|
</li>
|
|||
|
</ol>
|
|||
|
<h3 id="82-重装系统">8.2 重装系统<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#82-重装系统" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
|
|||
|
<p>当系统无法修复或需要重新部署时,重装操作系统是一种有效的解决方案。重装过程需要谨慎进行,以避免不必要的数据丢失和系统配置的复杂性。</p>
|
|||
|
<h4 id="821-重装准备">8.2.1 重装准备<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#821-重装准备" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<ol>
|
|||
|
<li>
|
|||
|
<p><strong>准备安装介质</strong>:</p>
|
|||
|
<ul>
|
|||
|
<li>下载并创建最新版本的 Linux 发行版的启动介质(如 USB 启动盘或 DVD)。</li>
|
|||
|
<li>确保安装介质与目标系统的硬件和架构(如 x86_64)兼容。</li>
|
|||
|
</ul>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>检查硬件兼容性</strong>:</p>
|
|||
|
<ul>
|
|||
|
<li>在安装之前,确保系统的硬件已获得新的操作系统版本的支持。检查硬件制造商的文档或社区支持论坛。</li>
|
|||
|
<li>如果使用 UEFI 引导,确保 BIOS/UEFI 设置正确,并禁用或配置 Secure Boot。</li>
|
|||
|
</ul>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>备份当前系统配置</strong>:使用 <code>dpkg --get-selections</code> 或 <code>rpm -qa</code> 命令导出当前系统已安装的软件包列表,以便在重装后快速恢复环境:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">dpkg</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --get-selections</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> ></span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> package-list.txt</span></span></code></pre></figure>
|
|||
|
<p>导出重要配置文件(如 <code>/etc/fstab</code>、网络配置、GRUB 配置等),以便重装后参考和恢复。</p>
|
|||
|
</li>
|
|||
|
</ol>
|
|||
|
<h4 id="822-重装过程">8.2.2 重装过程<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#822-重装过程" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<ol>
|
|||
|
<li><strong>启动安装介质</strong>:
|
|||
|
<ul>
|
|||
|
<li>插入安装介质并启动系统,通常通过按下 <code>F12</code>、<code>Esc</code> 或 <code>Del</code> 键进入启动菜单,从安装介质启动系统。</li>
|
|||
|
</ul>
|
|||
|
</li>
|
|||
|
<li><strong>选择安装类型</strong>:
|
|||
|
<ul>
|
|||
|
<li>在安装向导中,选择安装类型:全新安装、替换现有系统或手动分区。</li>
|
|||
|
<li>对于保留数据的重装,可以选择不格式化数据分区,但建议全新安装以确保系统的稳定性。</li>
|
|||
|
</ul>
|
|||
|
</li>
|
|||
|
<li><strong>配置系统分区</strong>:
|
|||
|
<ul>
|
|||
|
<li>根据需要手动分区或使用自动分区选项。确保根分区 <code>/</code>、交换分区 <code>swap</code>、以及 <code>/home</code> 分区配置合理。</li>
|
|||
|
<li>如果使用 LVM 或 RAID,确保在安装过程中正确配置这些选项。</li>
|
|||
|
</ul>
|
|||
|
</li>
|
|||
|
<li><strong>完成安装并初步配置</strong>:
|
|||
|
<ul>
|
|||
|
<li>按照安装向导完成系统安装,设置主机名、用户账号和密码等基本信息。</li>
|
|||
|
<li>安装完成后,重启系统并移除安装介质。</li>
|
|||
|
</ul>
|
|||
|
</li>
|
|||
|
</ol>
|
|||
|
<h4 id="823-恢复备份和环境">8.2.3 恢复备份和环境<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#823-恢复备份和环境" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
|
|||
|
<ol>
|
|||
|
<li>
|
|||
|
<p><strong>恢复数据备份</strong>:在新系统中挂载外部存储设备,并使用 <code>rsync</code> 或 <code>tar</code> 恢复用户数据:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">rsync</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -av</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /mnt/backup/username</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /home/username/</span></span></code></pre></figure>
|
|||
|
<p>确保恢复的数据权限正确,使用 <code>chown</code> 和 <code>chmod</code> 命令调整权限。</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>恢复软件和配置</strong>:使用导出的包列表重新安装软件:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> dpkg</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --set-selections</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> <</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> package-list.txt</span></span>
|
|||
|
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> apt-get</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> dselect-upgrade</span></span></code></pre></figure>
|
|||
|
<p>手动恢复配置文件或参考备份的配置文件,确保系统服务和网络配置等恢复到之前的状态。</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>更新和优化系统</strong>:完成安装和恢复后,运行系统更新以确保所有软件包处于最新状态:</p>
|
|||
|
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="shell" data-theme="github-light github-dark"><code data-language="shell" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> apt-get</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> update</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> && </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> apt-get</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> upgrade</span></span></code></pre></figure>
|
|||
|
<p>根据需要安装额外的驱动程序和工具,优化系统性能。</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><strong>测试系统功能</strong>:</p>
|
|||
|
<p>测试所有关键功能,包括网络连接、外部设备、图形界面和应用程序,以确保系统恢复正常运行。</p>
|
|||
|
</li>
|
|||
|
</ol></article><hr/><div class="page-footer"></div></div><div class="right sidebar"><div class="graph"><h3>关系图谱</h3><div class="graph-outer"><div id="graph-container" data-cfg="{"drag":true,"zoom":true,"depth":1,"scale":1.1,"repelForce":0.5,"centerForce":0.3,"linkDistance":30,"fontSize":0.6,"opacityScale":1,"showTags":true,"removeTags":[],"focusOnHover":false}"></div><button id="global-graph-icon" aria-label="Global Graph"><svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 55 55" fill="currentColor" xml:space="preserve"><path d="M49,0c-3.309,0-6,2.691-6,6c0,1.035,0.263,2.009,0.726,2.86l-9.829,9.829C32.542,17.634,30.846,17,29,17
|
|||
|
s-3.542,0.634-4.898,1.688l-7.669-7.669C16.785,10.424,17,9.74,17,9c0-2.206-1.794-4-4-4S9,6.794,9,9s1.794,4,4,4
|
|||
|
c0.74,0,1.424-0.215,2.019-0.567l7.669,7.669C21.634,21.458,21,23.154,21,25s0.634,3.542,1.688,4.897L10.024,42.562
|
|||
|
C8.958,41.595,7.549,41,6,41c-3.309,0-6,2.691-6,6s2.691,6,6,6s6-2.691,6-6c0-1.035-0.263-2.009-0.726-2.86l12.829-12.829
|
|||
|
c1.106,0.86,2.44,1.436,3.898,1.619v10.16c-2.833,0.478-5,2.942-5,5.91c0,3.309,2.691,6,6,6s6-2.691,6-6c0-2.967-2.167-5.431-5-5.91
|
|||
|
v-10.16c1.458-0.183,2.792-0.759,3.898-1.619l7.669,7.669C41.215,39.576,41,40.26,41,41c0,2.206,1.794,4,4,4s4-1.794,4-4
|
|||
|
s-1.794-4-4-4c-0.74,0-1.424,0.215-2.019,0.567l-7.669-7.669C36.366,28.542,37,26.846,37,25s-0.634-3.542-1.688-4.897l9.665-9.665
|
|||
|
C46.042,11.405,47.451,12,49,12c3.309,0,6-2.691,6-6S52.309,0,49,0z M11,9c0-1.103,0.897-2,2-2s2,0.897,2,2s-0.897,2-2,2
|
|||
|
S11,10.103,11,9z M6,51c-2.206,0-4-1.794-4-4s1.794-4,4-4s4,1.794,4,4S8.206,51,6,51z M33,49c0,2.206-1.794,4-4,4s-4-1.794-4-4
|
|||
|
s1.794-4,4-4S33,46.794,33,49z M29,31c-3.309,0-6-2.691-6-6s2.691-6,6-6s6,2.691,6,6S32.309,31,29,31z M47,41c0,1.103-0.897,2-2,2
|
|||
|
s-2-0.897-2-2s0.897-2,2-2S47,39.897,47,41z M49,10c-2.206,0-4-1.794-4-4s1.794-4,4-4s4,1.794,4,4S51.206,10,49,10z"></path></svg></button></div><div id="global-graph-outer"><div id="global-graph-container" data-cfg="{"drag":true,"zoom":true,"depth":-1,"scale":0.9,"repelForce":0.5,"centerForce":0.3,"linkDistance":30,"fontSize":0.6,"opacityScale":1,"showTags":true,"removeTags":[],"focusOnHover":true}"></div></div></div><div class="toc desktop-only"><button type="button" id="toc" class aria-controls="toc-content" aria-expanded="true"><h3>目录</h3><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="fold"><polyline points="6 9 12 15 18 9"></polyline></svg></button><div id="toc-content" class><ul class="overflow"><li class="depth-0"><a href="#摘要" data-for="摘要">摘要</a></li><li class="depth-0"><a href="#1-引言" data-for="1-引言">1. 引言</a></li><li class="depth-0"><a href="#2-引导加载阶段的排查" data-for="2-引导加载阶段的排查">2. 引导加载阶段的排查</a></li><li class="depth-1"><a href="#21-biosuefi-设置问题" data-for="21-biosuefi-设置问题">2.1 BIOS/UEFI 设置问题</a></li><li class="depth-1"><a href="#22-grub-引导加载器问题" data-for="22-grub-引导加载器问题">2.2 GRUB 引导加载器问题</a></li><li class="depth-1"><a href="#23-mbr-和-gpt-分区表问题" data-for="23-mbr-和-gpt-分区表问题">2.3 MBR 和 GPT 分区表问题</a></li><li class="depth-1"><a href="#24-efi-引导文件问题" data-for="24-efi-引导文件问题">2.4 EFI 引导文件问题</a></li><li class="depth-1"><a href="#25-引导配置文件如-grubcfg损坏" data-for="25-引导配置文件如-grubcfg损坏">2.5 引导配置文件(如 grub.cfg)损坏</a></li><li class="depth-1"><a href="#26-其他引导加载器问题如-lilo-syslinux" data-for="26-其他引导加载器问题如-lilo-syslinux">2.6 其他引导加载器问题(如 LILO, Syslinux)</a></li><li class="depth-0"><a href="#3-内核加载阶段的排查" data-for="3-内核加载阶段的排查">3. 内核加载阶段的排查</a></li><li class="depth-1"><a href="#31-内核崩溃kernel-panic" data-for="31-内核崩溃kernel-panic">3.1 内核崩溃(Kernel Panic)</a></li><li class="depth-1"><a href="#32-内核模块加载失败" data-for="32-内核模块加载失败">3.2 内核模块加载失败</a></li><li class="depth-1"><a href="#33-内核参数错误" data-for="33-内核参数错误">3.3 内核参数错误</a></li><li class="depth-1"><a href="#34-内核升级或降级问题" data-for="34-内核升级或降级问题">3.4 内核升级或降级问题</a></li><li class="depth-1"><a href="#35-内核和初始内存盘initramfs问题" data-for="35-内核和初始内存盘initramfs问题">3.5 内核和初始内存盘(initramfs)问题</a></li><li class="depth-1"><a href="#36-硬件兼容性与内核驱动问题" data-for="36-硬件兼容性与内核驱动问题">3.6 硬件兼容性与内核驱动问题</a></li><li class="depth-0"><a href="#4-文件系统的排查与修复" data-for="4-文件系统的排查与修复">4. 文件系统的排查与修复</a></li><li class="depth-1"><a href="#41-文件系统完整性检查" data-for="41-文件系统完整性检查">4.1 文件系统完整性检查</a></li><li class="depth-1"><a href="#42-分区挂载问题" data-for="42-分区挂载问题">4.2 分区挂载问题</a></li><li class="depth-1"><a href="#43-文件系统类型不兼容" data-for="43-文件系统类型不兼容">4.3 文件系统类型不兼容</a></li><li class="depth-1"><a href="#44-lvm-逻辑卷管理问题" data-for="44-lvm-逻辑卷管理问题">4.4 LVM 逻辑卷管理问题</a></li><li class="depth-1"><a href="#45-raid-阵列问题" data-for="45-raid-阵列问题">4.5 RAID 阵列问题</a></li><li class="depth-1"><a href="#46-其他文件系统工具
|
|||
|
</script><script type="module">
|
|||
|
let mermaidImport = undefined
|
|||
|
document.addEventListener('nav', async () => {
|
|||
|
if (document.querySelector("code.mermaid")) {
|
|||
|
mermaidImport ||= await import('https://cdnjs.cloudflare.com/ajax/libs/mermaid/10.7.0/mermaid.esm.min.mjs')
|
|||
|
const mermaid = mermaidImport.default
|
|||
|
const darkMode = document.documentElement.getAttribute('saved-theme') === 'dark'
|
|||
|
mermaid.initialize({
|
|||
|
startOnLoad: false,
|
|||
|
securityLevel: 'loose',
|
|||
|
theme: darkMode ? 'dark' : 'default'
|
|||
|
})
|
|||
|
|
|||
|
await mermaid.run({
|
|||
|
querySelector: '.mermaid'
|
|||
|
})
|
|||
|
}
|
|||
|
});
|
|||
|
</script><script src="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.9/contrib/copy-tex.min.js" type="application/javascript"></script><script src="../../../../postscript.js" type="module"></script></html>
|