1
0
wiki/Technology/OperatingSystem/Linux/2.安装/Linux-下-0-1-手动安装-Arch-Linux.html

436 lines
559 KiB
HTML
Raw Permalink Normal View History

2024-10-10 16:56:32 +08:00
<!DOCTYPE html>
<html lang="zh"><head><title>Linux 下 0-1 手动安装 Arch 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&amp;family=Noto Serif Simplified Chinese:wght@400;700&amp;family=Source Sans Pro:ital,wght@0,400;0,600;1,400;1,600&amp;display=swap"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><meta property="og:title" content="Linux 下 0-1 手动安装 Arch Linux"/><meta property="og:description" content="本文提供了一个详细的指南,用于手动安装 Arch Linux包括从分区到安装桌面环境的完整步骤。."/><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="本文提供了一个详细的指南,用于手动安装 Arch Linux包括从分区到安装桌面环境的完整步骤。."/><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-下-0-1-手动安装-Arch-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.829,0-1.5,0.672-1.5,1.5v3c0,0.828,0.671,1.5,1.5,1.5s1.5-0.672,1.5-1.5v-3C19,29.672,18.329,29,17.5,29z M17.5,7 C11.71,7,7,11.71,7,17.5S11.71,28,17.5,28S
<p>这里以 Arch Linux 为例,因为它是一个极简主义的发行版,允许你从头开始定制系统。可以根据实际情况选择参考 <a href="https://wiki.archlinux.org/title/Installation_guide" class="external">Arch Linux 官方的安装手册<svg aria-hidden="true" class="external-icon" viewBox="0 0 512 512"><path d="M320 0H288V64h32 82.7L201.4 265.4 178.7 288 224 333.3l22.6-22.6L448 109.3V192v32h64V192 32 0H480 320zM32 32H0V64 480v32H32 456h32V480 352 320H424v32 96H64V96h96 32V32H160 32z"></path></svg></a>,也可以选择阅读下面的文章。</p>
<h2 id="0前期准备">0.前期准备<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#0前期准备" 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>
<ol>
<li>
<p><strong>获取 Arch Linux ISO 文件</strong>:从 Arch Linux <a href="https://archlinux.org/download/" class="external">官方网站下载<svg aria-hidden="true" class="external-icon" viewBox="0 0 512 512"><path d="M320 0H288V64h32 82.7L201.4 265.4 178.7 288 224 333.3l22.6-22.6L448 109.3V192v32h64V192 32 0H480 320zM32 32H0V64 480v32H32 456h32V480 352 320H424v32 96H64V96h96 32V32H160 32z"></path></svg></a> 最新的 ISO 文件。</p>
</li>
<li>
<p><strong>创建可引导的 USB 安装盘</strong>:使用 <code>dd</code><code>Rufus</code> 创建一个可引导的 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;"> dd</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> if=/path/to/archlinux.iso</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> of=/dev/sdX</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> bs=4M</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> status=progress</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> &amp;&amp; </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sync</span></span></code></pre></figure>
<p>这里 <code>/dev/sdX</code> 是你的 USB 设备。</p>
</li>
</ol>
<h2 id="1启动并进入-arch-linux-环境">1.启动并进入 Arch Linux 环境<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#1启动并进入-arch-linux-环境" 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="11-从-usb-启动">1.1 从 USB 启动<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#11-从-usb-启动" 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>电脑开机选择从 USB 启动,进入 Arch Linux 的 Live 环境。</p>
<h3 id="12-网络连接">1.2 网络连接<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#12-网络连接" 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>首先,确保网络接口已启动。通常在最小系统中,不会有图形化的网络管理工具,因此我们需要通过命令行手动管理网络接口。(可以使用 <code>ip</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:#6A737D;--shiki-dark:#6A737D;"># 查看网络接口</span></span>
<span data-line><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># 这将列出所有网络接口以及它们的状态(`UP` 或 `DOWN`)。</span></span>
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">ip</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> link</span></span>
<span data-line> </span>
<span data-line><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># 如果接口状态为 DOWN使用以下命令启动它。</span></span>
<span data-line><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># 注意将 enp0s3 替换为你实际的网络接口名称。</span></span>
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">ip</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> link</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> set</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> enp0s3</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> up</span></span>
<span data-line> </span>
<span data-line><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># 手动为某个网络接口配置静态 IP 地址。</span></span>
<span data-line><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># 192.168.1.100/24 是你要设置的 IP 地址和子网掩码。</span></span>
<span data-line><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># enp0s3 是你要配置的网络接口。</span></span>
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">ip</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> addr</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> add</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 192.168.1.100/24</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> dev</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> enp0s3</span></span>
<span data-line> </span>
<span data-line><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># 配置默认网关,确保网络接口能够访问外部网络</span></span>
<span data-line><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># 192.168.1.1 是默认网关的 IP 地址(通常是路由器的 IP 地址)。</span></span>
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">ip</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> route</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> add</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> default</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> via</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 192.168.1.1</span></span>
<span data-line> </span>
<span data-line><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># 查看网络配置</span></span>
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">ip</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> addr</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> show</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> enp0s3</span></span>
<span data-line> </span>
<span data-line><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># 测试网络连接</span></span>
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">ping</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -c</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 4</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> baidu.com</span></span></code></pre></figure>
<h3 id="13-配置-dns可选">1.3 配置 DNS可选<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#13-配置-dns可选" 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>如果 <code>ping</code> 域名失败,但 <code>ping</code> IP 地址成功,则可能是 DNS 配置有问题。</p>
<p>编辑或创建 <code>/etc/resolv.conf</code> 文件,并添加公共 DNS 服务器,如 Google 的 DNS</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;">echo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;nameserver 223.5.5.5&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> ></span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /etc/resolv.conf</span></span>
<span data-line><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">echo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;nameserver 8.8.8.8&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> >></span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /etc/resolv.conf</span></span></code></pre></figure>
<h3 id="14-同步时间">1.4 同步时间<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#14-同步时间" 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>
<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;">timedatectl</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> set-ntp</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> true</span></span></code></pre></figure>
<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-查看磁盘">2.1 查看磁盘<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#21-查看磁盘" 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>
<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;">fdisk</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -l</span></span></code></pre></figure>
<p>这个命令会列出所有的磁盘及其分区。假设你的目标磁盘是 <code>/dev/sda</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;">Disk</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /dev/sda:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 50</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> GiB,</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 53687091200</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> bytes,</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 104857600</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> sectors</span></span>
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">Units:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> sectors</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> of</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 1</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> *</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 512</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> =</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 512</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> bytes</span></span>
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">Sector</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> size</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> (logical/physical): 512 bytes / 4096 bytes</span></span>
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">I/O</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> size</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> (minimum/optimal): 4096 bytes / 4096 bytes</span></span>
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">Disklabel</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> type:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> gpt</span></span>
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">Disk</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> identifier:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX</span></span>
<span data-line> </span>
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">Device</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Start</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> End</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Sectors</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Size</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Type</span></span>
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">/dev/sda1</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 2048</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 1050623</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 1048576</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 512M</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> EFI</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> System</span></span>
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">/dev/sda2</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 1050624</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 42008575</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 40957952</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 20G</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Linux</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> filesystem</span></span>
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">/dev/sda3</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 42008576</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 104857566</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 62848991</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 30G</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Linux</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> filesystem</span></span></code></pre></figure>
<p>在这个示例中,磁盘 <code>/dev/sda</code> 上有三个分区,其中 <code>/dev/sda1</code> 是 EFI 系统分区,<code>/dev/sda2</code> 是根分区,<code>/dev/sda3</code> 是 Home 分区。</p>
<h3 id="22-分区磁盘">2.2 分区磁盘<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#22-分区磁盘" 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>接下来,我们将使用 <code>fdisk</code> 来创建新的分区。以下是使用 <code>fdisk</code> 工具创建分区的详细步骤。</p>
<p><strong>2.2.1 启动 <code>fdisk</code></strong></p>
<p>使用以下命令启动 <code>fdisk</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;">fdisk</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /dev/sda</span></span></code></pre></figure>
<p>进入 <code>fdisk</code> 后,命令行会切换到交互模式,你将看到一个提示符类似 <code>Command (m for help):</code></p>
<p><strong>2.2.2 创建 EFI 系统分区</strong></p>
<ol>
<li>
<p>输入 <code>n</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;">Command</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> (m </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">for</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> help</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">): n</span></span></code></pre></figure>
</li>
<li>
<p>选择分区类型,通常默认是 <code>primary</code>,直接按 <code>Enter</code></p>
</li>
<li>
<p>选择分区号(一般是 1<code>Enter</code></p>
</li>
<li>
<p>选择起始扇区,默认从 2048 开始,按 <code>Enter</code></p>
</li>
<li>
<p>输入分区大小。例如,为 EFI 系统分区分配 512MB+512M</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;">Last</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> sector,</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> +sectors</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> or</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> +size{K,M,G,T,P}</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> (2048-104857599, </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">default</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 104857599</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">): +512M</span></span></code></pre></figure>
</li>
<li>
<p>设置分区类型为 EFI 系统分区(类型代码为 <code>1</code>),输入 <code>t</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;">Command</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> (m </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">for</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> help</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">): t</span></span>
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">Selected</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> partition</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 1</span></span>
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">Hex</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> code</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> (type </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">L</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> to</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> list</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> all</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> codes</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">): 1</span></span></code></pre></figure>
</li>
</ol>
<p><strong>2.2.3 创建 root 根分区</strong></p>
<ol>
<li>
<p>同样输入 <code>n</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;">Command</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> (m </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">for</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> help</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">): n</span></span></code></pre></figure>
</li>
<li>
<p>选择分区类型和分区号2然后按 <code>Enter</code></p>
</li>
<li>
<p>选择起始扇区,默认即可,按 <code>Enter</code></p>
</li>
<li>
<p>输入分区大小,例如,分配 20GB 给根分区(+20G</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;">Last</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> sector,</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> +sectors</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> or</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> +size{K,M,G,T,P}</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> (1050624-104857599, </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">default</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 104857599</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">): +20G</span></span></code></pre></figure>
</li>
</ol>
<p><strong>2.2.4 创建 Home 分区</strong></p>
<ol>
<li>
<p>输入 <code>n</code> 创建 Home 分区:</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;">Command</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> (m </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">for</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> help</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">): n</span></span></code></pre></figure>
</li>
<li>
<p>选择分区类型和分区号3然后按 <code>Enter</code></p>
</li>
<li>
<p>选择起始扇区,默认即可,按 <code>Enter</code></p>
</li>
<li>
<p>直接按 <code>Enter</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;">Last</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> sector,</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> +sectors</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> or</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> +size{K,M,G,T,P}</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> (42008576-104857599, </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">default</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 104857599</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">): </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&lt;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">Press Enter</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">></span></span></code></pre></figure>
</li>
</ol>
<p><strong>2.2.5 保存分区表并退出</strong></p>
<ol>
<li>
<p>输入 <code>w</code> 写入分区表并退出 <code>fdisk</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;">Command</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> (m </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">for</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> help</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">): w</span></span></code></pre></figure>
</li>
</ol>
<p>此时,新分区已经创建并保存到磁盘中。</p>
<h3 id="23-格式化分区">2.3 格式化分区<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#23-格式化分区" 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>现在,使用 <code>mkfs</code> 命令格式化新创建的分区:</p>
<p><strong>2.3.1 格式化 EFI 分区</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;">mkfs.fat</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -F32</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /dev/sda1</span></span></code></pre></figure>
<p><strong>2.3.2 格式化根分区</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;">mkfs.ext4</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /dev/sda2</span></span></code></pre></figure>
<p><strong>2.3.3 格式化 Home 分区</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;">mkfs.ext4</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /dev/sda3</span></span></code></pre></figure>
<h3 id="24-交换分区可选">2.4 交换分区(可选)<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#24-交换分区可选" 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>
<p><strong>2.4.1 创建交换分区</strong></p>
<ol>
<li>
<p>在分区时,创建一个适合你系统需求大小的交换分区。例如,创建一个 2GB 的交换分区。</p>
</li>
<li>
<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;">mkswap</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /dev/sda4</span></span></code></pre></figure>
</li>
<li>
<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;">swapon</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /dev/sda4</span></span></code></pre></figure>
</li>
</ol>
<p><strong>2.4.2 创建交换文件(可选)</strong></p>
<p>如果你不想使用交换分区,可以使用以下步骤创建交换文件:</p>
<ol>
<li>
<p>创建一个 2GB 的交换文件:</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;">dd</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> if=/dev/zero</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> of=/mnt/swapfile</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> bs=1M</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> count=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">2048</span></span></code></pre></figure>
</li>
<li>
<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;">mkswap</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /mnt/swapfile</span></span></code></pre></figure>
</li>
<li>
<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;">swapon</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /mnt/swapfile</span></span></code></pre></figure>
</li>
<li>
<p>为了确保在系统重启后交换文件仍然有效,你需要将其添加到 <code>/etc/fstab</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:#005CC5;--shiki-dark:#79B8FF;">echo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> '/mnt/swapfile none swap sw 0 0'</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> tee</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -a</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /etc/fstab</span></span></code></pre></figure>
</li>
</ol>
<p>至此,你已经成功地完成了磁盘分区并格式化了各个分区。接下来,你可以继续安装操作系统的其他部分。</p>
<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-挂载根分区">3.1 挂载根分区<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#31-挂载根分区" 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>
<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:#6A737D;--shiki-dark:#6A737D;"># 挂载 root 根分区</span></span>
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">mount</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /dev/sda2</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /mnt</span></span></code></pre></figure>
<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>
<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:#6A737D;--shiki-dark:#6A737D;"># 创建 boot 目录,并挂载</span></span>
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">mkdir</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /mnt/boot</span></span>
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">mount</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /dev/sda1</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /mnt/boot</span></span>
<span data-line> </span>
<span data-line><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># 创建 home 目录,并挂载</span></span>
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">mkdir</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /mnt/home</span></span>
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">mount</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /dev/sda3</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /mnt/home</span></span></code></pre></figure>
<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>
<p>可以手动编辑 <code>/etc/pacman.d/mirrorlist</code>,将最快的镜像放在顶部。</p>
<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>
<p>使用 <code>pacstrap</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;">pacstrap</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /mnt</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> base</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> linux</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> linux-firmware</span></span></code></pre></figure>
<h3 id="43-生成-fstab">4.3 生成 Fstab<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#43-生成-fstab" 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>手动生成文件系统表,并将其写入 <code>fstab</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;">genfstab</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -U</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /mnt</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> >></span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /mnt/etc/fstab</span></span></code></pre></figure>
<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-进入-chroot-环境">5.1 进入 Chroot 环境<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#51-进入-chroot-环境" 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>
<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;">arch-chroot</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /mnt</span></span></code></pre></figure>
<h3 id="52-设置系统时区">5.2 设置系统时区<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#52-设置系统时区" 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>
<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;">ln</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -sf</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /usr/share/zoneinfo/Asia/Shanghai</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /etc/localtime</span></span>
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">hwclock</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --systohc</span></span></code></pre></figure>
<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>
<p>手动编辑 <code>/etc/locale.gen</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;">locale-gen</span></span>
<span data-line><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">echo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;LANG=en_US.UTF-8&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> ></span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /etc/locale.conf</span></span></code></pre></figure>
<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>
<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;">echo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;your_hostname&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> ></span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /etc/hostname</span></span></code></pre></figure>
<h3 id="55-设置-hosts-文件">5.5 设置 Hosts 文件<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#55-设置-hosts-文件" 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>
<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;">echo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;127.0.0.1 localhost&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> ></span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /etc/hosts</span></span>
<span data-line><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">echo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;::1 localhost&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> >></span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /etc/hosts</span></span>
<span data-line><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">echo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;127.0.1.1 your_hostname.localdomain your_hostname&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> >></span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /etc/hosts</span></span></code></pre></figure>
<h3 id="56-设置-root-密码">5.6 设置 Root 密码<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#56-设置-root-密码" 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>
<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;">passwd</span></span></code></pre></figure>
<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>
<p>根据你的系统BIOS 或 UEFI安装 GRUB 或 systemd-boot。</p>
<h3 id="61-对于-uefi-系统">6.1 对于 UEFI 系统<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#61-对于-uefi-系统" 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>
<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;">pacman</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -S</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> grub</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> efibootmgr</span></span>
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">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</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;">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>
<h3 id="62-对于-bios-系统">6.2 对于 BIOS 系统<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#62-对于-bios-系统" 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>
<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;">pacman</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -S</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> grub</span></span>
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">grub-install</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --target=i386-pc</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /dev/sda</span></span>
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">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>
<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>
<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:#6A737D;--shiki-dark:#6A737D;"># 退出 chroot 并卸载</span></span>
<span data-line><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">exit</span></span>
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">umount</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -R</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /mnt</span></span>
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">reboot</span></span></code></pre></figure>
<p>如果一切正常,你现在应该能够从硬盘启动进入新安装的 Arch Linux 系统。</p>
<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>
<p>如果网络未连接,请先重复 1.2 和 1.3 步骤。</p>
<h3 id="72-安装-networkmanager-管理网络">7.2 安装 NetworkManager 管理网络<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#72-安装-networkmanager-管理网络" 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>通过安装 NetworkManager你可以快速在最小化系统中配置网络确保系统能连接到互联网并正常工作。</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;">pacman</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -S</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> networkmanager</span></span>
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">systemctl</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> enable</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> NetworkManager</span></span>
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">systemctl</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> start</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> NetworkManager</span></span></code></pre></figure>
<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>
<p>首先,重启 Linux 确定 NetworkManager 工作正常,然后确保你的系统是最新的:</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;">reboot</span></span>
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> pacman</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -Syu</span></span></code></pre></figure>
<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>
<p>在 Arch Linux 上安装一个基本的桌面环境 (Desktop Environment, DE) 需要经过几个步骤,包括安装 X Window 系统、显卡驱动程序以及实际的桌面环境。以下是详细的步骤说明。</p>
<h3 id="81-安装-x-window-系统">8.1 安装 X Window 系统<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#81-安装-x-window-系统" 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>X Window 系统是 Linux 上大多数桌面环境的基础。你需要安装 <code>xorg</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;"> pacman</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -S</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> xorg-server</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> xorg-apps</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> xorg-xinit</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> xterm</span></span></code></pre></figure>
<ul>
<li><code>xorg-server</code> 是 X 服务器。</li>
<li><code>xorg-apps</code> 是一些有用的 X 应用程序。</li>
<li><code>xorg-xinit</code> 是 X 启动器。</li>
<li><code>xterm</code> 是一个基本的终端仿真器,供测试 X 环境使用。</li>
</ul>
<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-对于-intel-显卡">8.2.1 对于 Intel 显卡<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#821-对于-intel-显卡" 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>
<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;"> pacman</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -S</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> xf86-video-intel</span></span></code></pre></figure>
<h4 id="822-对于-nvidia-显卡">8.2.2 对于 NVIDIA 显卡:<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#822-对于-nvidia-显卡" 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>
<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:#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;"> pacman</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -S</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> nvidia</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> nvidia-utils</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> nvidia-settings</span></span>
<span data-line> </span>
<span data-line><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;"> pacman</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -S</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> xf86-video-nouveau</span></span></code></pre></figure>
<h4 id="823-对于-amd-显卡">8.2.3 对于 AMD 显卡<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#823-对于-amd-显卡" 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>
<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;"> pacman</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -S</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> xf86-video-amdgpu</span></span></code></pre></figure>
<h3 id="83-安装桌面环境">8.3 安装桌面环境<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#83-安装桌面环境" 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="831-安装-gnome-桌面环境">8.3.1 安装 GNOME 桌面环境<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#831-安装-gnome-桌面环境" 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>GNOME 是一个功能齐全的桌面环境,适合需要稳定和易用性的用户。</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;"> pacman</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -S</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> gnome</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> gnome-extra</span></span></code></pre></figure>
<p>安装完成后,启用 <code>gdm</code>GNOME Display Manager</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;"> enable</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> gdm</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;"> start</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> gdm</span></span></code></pre></figure>
<h4 id="832-安装-kde-plasma-桌面环境">8.3.2 安装 KDE Plasma 桌面环境<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#832-安装-kde-plasma-桌面环境" 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>KDE Plasma 是一个高度可定制的桌面环境,适合喜欢自定义的用户。</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;"> pacman</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -S</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> plasma</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> kde-applications</span></span></code></pre></figure>
<p>安装完成后,启用 <code>sddm</code>Simple Desktop Display Manager</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;"> enable</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> sddm</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;"> start</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> sddm</span></span></code></pre></figure>
<h4 id="833-安装-xfce-桌面环境">8.3.3 安装 XFCE 桌面环境<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#833-安装-xfce-桌面环境" 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>XFCE 是一个轻量级且资源占用较低的桌面环境,适合性能较弱的机器。</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;"> pacman</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -S</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> xfce4</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> xfce4-goodies</span></span></code></pre></figure>
<p>你可以选择安装 <code>lightdm</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;"> pacman</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -S</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> lightdm</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> lightdm-gtk-greeter</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;"> enable</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;"> systemctl</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> start</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> lightdm</span></span></code></pre></figure>
<h3 id="84-使用-startx-启动">8.4 使用 <code>startx</code> 启动<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#84-使用-startx-启动" 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>如果你不使用显示管理器而是手动使用 <code>startx</code> 启动桌面环境,需要编辑 <code>.xinitrc</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;">nano</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> ~/.xinitrc</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:#6A737D;--shiki-dark:#6A737D;"># GNOME</span></span>
<span data-line><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">exec</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> gnome-session</span></span>
<span data-line><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># KDE Plasma</span></span>
<span data-line><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">exec</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> startplasma-x11</span></span>
<span data-line><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># XFCE</span></span>
<span data-line><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">exec</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> startxfce4</span></span></code></pre></figure>
<p>保存并退出,然后通过 <code>startx</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;">startx</span></span></code></pre></figure>
<h3 id="85-重启系统并登录">8.5 重启系统并登录<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#85-重启系统并登录" 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>重启系统后,你应该会被引导至图形登录界面。如果使用了显示管理器(如 GDM、SDDM 或 LightDM你可以选择相应的桌面环境并登录。</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;"> reboot</span></span></code></pre></figure>
<p>通过这些步骤,你将成功安装并配置一个基本的桌面环境,并能够在 Arch Linux 上运行图形化应用程序。如果有任何问题或需要进一步的帮助,请随时提问。</p>
<h2 id="9完整的工作环境">9.完整的工作环境<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#9完整的工作环境" 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>如果要将 Arch Linux 从一个最小的基础系统升级为一个功能齐全的工作环境,你需要安装和配置一些常用的工具和软件包。以下是一个全面的步骤指南,帮助你将 Arch Linux 系统完善到适合日常使用的状态。</p>
<h3 id="91-更新系统">9.1 更新系统<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#91-更新系统" 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>
<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;"> pacman</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -Syu</span></span></code></pre></figure>
<h3 id="92-安装基础开发工具">9.2 安装基础开发工具<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#92-安装基础开发工具" 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>
<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;"> pacman</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -S</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> base-devel</span></span></code></pre></figure>
<p><code>base-devel</code> 包括 <code>gcc</code><code>make</code><code>binutils</code> 等常用的开发工具。</p>
<h3 id="93-安装网络工具">9.3 安装网络工具<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#93-安装网络工具" 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>一些常用的网络工具,如 <code>wget</code><code>curl</code><code>net-tools</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;"> pacman</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -S</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> wget</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> curl</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> net-tools</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> openssh</span></span></code></pre></figure>
<h3 id="94-安装文件系统和磁盘管理工具">9.4 安装文件系统和磁盘管理工具<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#94-安装文件系统和磁盘管理工具" 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>
<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;"> pacman</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -S</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> dosfstools</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> exfat-utils</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> ntfs-3g</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> gparted</span></span></code></pre></figure>
<ul>
<li><code>dosfstools</code><code>exfat-utils</code>:支持 FAT 和 exFAT 文件系统。</li>
<li><code>ntfs-3g</code>:支持 NTFS 文件系统。</li>
<li><code>gparted</code>:一个图形化的分区管理工具。</li>
</ul>
<h3 id="95-安装常用编辑器">9.5 安装常用编辑器<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#95-安装常用编辑器" 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>
<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;"> pacman</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -S</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> vim</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> nano</span></span></code></pre></figure>
<ul>
<li><code>vim</code>:功能强大的文本编辑器。</li>
<li><code>nano</code>:简单易用的文本编辑器。</li>
</ul>
<h3 id="96-安装常用终端工具">9.6 安装常用终端工具<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#96-安装常用终端工具" 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>
<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;"> pacman</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -S</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> htop</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> tmux</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> screen</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> neofetch</span></span></code></pre></figure>
<ul>
<li><code>htop</code>:互动的进程查看器。</li>
<li><code>tmux</code><code>screen</code>:终端复用器,允许在单个终端中运行多个会话。</li>
<li><code>neofetch</code>:显示系统信息的工具。</li>
</ul>
<h3 id="97-安装常用压缩工具">9.7 安装常用压缩工具<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#97-安装常用压缩工具" 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>
<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;"> pacman</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -S</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> unzip</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> p7zip</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> tar</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> gzip</span></span></code></pre></figure>
<h3 id="98-安装常用字体">9.8 安装常用字体<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#98-安装常用字体" 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>
<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;"> pacman</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -S</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> ttf-dejavu</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> ttf-liberation</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> noto-fonts</span></span></code></pre></figure>
<h3 id="99-安装浏览器">9.9 安装浏览器<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#99-安装浏览器" 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>
<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;"> pacman</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -S</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> firefox</span></span></code></pre></figure>
<p>你也可以选择 <code>chromium</code>,或者在 AUR 中安装 <code>google-chrome</code></p>
<h3 id="910-安装常用的多媒体工具">9.10 安装常用的多媒体工具<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#910-安装常用的多媒体工具" 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>
<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;"> pacman</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -S</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> vlc</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> mpv</span></span></code></pre></figure>
<ul>
<li><code>vlc</code>:功能强大的媒体播放器。</li>
<li><code>mpv</code>:轻量级的媒体播放器。</li>
</ul>
<h3 id="911-安装办公软件">9.11 安装办公软件<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#911-安装办公软件" 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>如果需要办公软件,可以安装 LibreOffice</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;"> pacman</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -S</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> libreoffice-fresh</span></span></code></pre></figure>
<h3 id="912-安装-aur-助手">9.12 安装 AUR 助手<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#912-安装-aur-助手" 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>Arch User Repository (AUR) 包含了大量社区维护的软件包,安装一个 AUR 助手会方便很多。<code>yay</code> 是一个常用的 AUR 助手。</p>
<p>首先,确保你安装了 <code>git</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;"> pacman</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -S</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> git</span></span></code></pre></figure>
<p>然后,克隆 <code>yay</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:#005CC5;--shiki-dark:#79B8FF;">cd</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /opt</span></span>
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> git</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> clone</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> https://aur.archlinux.org/yay.git</span></span>
<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:#24292E;--shiki-dark:#E1E4E8;"> $USER</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">:</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">$USER </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">yay</span></span>
<span data-line><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">cd</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> yay</span></span>
<span data-line><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">makepkg</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -si</span></span></code></pre></figure>
<p>安装完成后,你可以通过 <code>yay -S &lt;package_name></code> 安装 AUR 软件包。</p>
<h3 id="913-安装实用工具">9.13 安装实用工具<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#913-安装实用工具" 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>
<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;"> pacman</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -S</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> ranger</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> fzf</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> fd</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> ripgrep</span></span></code></pre></figure>
<ul>
<li><code>ranger</code>:终端文件管理器。</li>
<li><code>fzf</code>:模糊查找工具。</li>
<li><code>fd</code><code>ripgrep</code>:快速文件和内容查找工具。</li>
</ul>
<h3 id="914-安装打印和扫描支持">9.14 安装打印和扫描支持<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#914-安装打印和扫描支持" 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>
<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;"> pacman</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -S</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> cups</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> hplip</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> simple-scan</span></span></code></pre></figure>
<ul>
<li><code>cups</code>:打印服务管理器。</li>
<li><code>hplip</code>HP 打印机驱动(适用于 HP 打印机用户)。</li>
<li><code>simple-scan</code>:简单易用的扫描工具。</li>
</ul>
<h3 id="915-安装虚拟机支持">9.15 安装虚拟机支持<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#915-安装虚拟机支持" 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>如果你打算在 Arch Linux 上运行虚拟机,安装 <code>VirtualBox</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;"> pacman</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -S</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> virtualbox</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> virtualbox-host-modules-arch</span></span></code></pre></figure>
<h3 id="916-启用常用服务">9.16 启用常用服务<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#916-启用常用服务" 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>
<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;"> enable</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> sshd</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;"> enable</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> cups</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;"> enable</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> NetworkManager</span></span></code></pre></figure>
<h3 id="917-安装额外的文件系统支持">9.17 安装额外的文件系统支持<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#917-安装额外的文件系统支持" 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>支持额外的文件系统,例如 <code>btrfs</code><code>zfs</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;"> pacman</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -S</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> btrfs-progs</span></span></code></pre></figure>
<p>如果需要 ZFS 支持,可以从 AUR 安装 <code>zfs-linux</code></p>
<h3 id="918-清理不需要的包">9.18 清理不需要的包<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#918-清理不需要的包" 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>
<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;"> pacman</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -Rns</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> $(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">pacman</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -Qdtq</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span></code></pre></figure></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="{&quot;drag&quot;:true,&quot;zoom&quot;:true,&quot;depth&quot;:1,&quot;scale&quot;:1.1,&quot;repelForce&quot;:0.5,&quot;centerForce&quot;:0.3,&quot;linkDistance&quot;:30,&quot;fontSize&quot;:0.6,&quot;opacityScale&quot;:1,&quot;showTags&quot;:true,&quot;removeTags&quot;:[],&quot;focusOnHover&quot;: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="{&quot;drag&quot;:true,&quot;zoom&quot;:true,&quot;depth&quot;:-1,&quot;scale&quot;:0.9,&quot;repelForce&quot;:0.5,&quot;centerForce&quot;:0.3,&quot;linkDistance&quot;:30,&quot;fontSize&quot;:0.6,&quot;opacityScale&quot;:1,&quot;showTags&quot;:true,&quot;removeTags&quot;:[],&quot;focusOnHover&quot;: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="#0前期准备" data-for="0前期准备">0.前期准备</a></li><li class="depth-0"><a href="#1启动并进入-arch-linux-环境" data-for="1启动并进入-arch-linux-环境">1.启动并进入 Arch Linux 环境</a></li><li class="depth-1"><a href="#11-从-usb-启动" data-for="11-从-usb-启动">1.1 从 USB 启动</a></li><li class="depth-1"><a href="#12-网络连接" data-for="12-网络连接">1.2 网络连接</a></li><li class="depth-1"><a href="#13-配置-dns可选" data-for="13-配置-dns可选">1.3 配置 DNS可选</a></li><li class="depth-1"><a href="#14-同步时间" data-for="14-同步时间">1.4 同步时间</a></li><li class="depth-0"><a href="#2磁盘分区" data-for="2磁盘分区">2.磁盘分区</a></li><li class="depth-1"><a href="#21-查看磁盘" data-for="21-查看磁盘">2.1 查看磁盘</a></li><li class="depth-1"><a href="#22-分区磁盘" data-for="22-分区磁盘">2.2 分区磁盘</a></li><li class="depth-1"><a href="#23-格式化分区" data-for="23-格式化分区">2.3 格式化分区</a></li><li class="depth-1"><a href="#24-交换分区可选" data-for="24-交换分区可选">2.4 交换分区(可选)</a></li><li class="depth-0"><a href="#3挂载分区" data-for="3挂载分区">3.挂载分区</a></li><li class="depth-1"><a href="#31-挂载根分区" data-for="31-挂载根分区">3.1 挂载根分区</a></li><li class="depth-1"><a href="#32-创建必要的目录并挂载" data-for="32-创建必要的目录并挂载">3.2 创建必要的目录并挂载</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-生成-fstab" data-for="43-生成-fstab">4.3 生成 Fstab</a></li><li class="depth-0"><a href="#5系统配置" data-for="5系统配置">5.系统配置</a></li><li class="depth-1"><a href="#51-进入-chroot-环境" data-for="51-进入-chroot-环境">5.1 进入 Chroot 环境</a></li><li class="depth-1"><a href="#52-设置系统时区" data-for="52-设置系统时区">5.2 设置系统时区</a></li><li class="depth-1"><a href="#53-设置系统语言" data-for="53-设置系统语言">5.3 设置系统语言</a></li><li class="depth-1"><a href="#54-设置系统主机名" data-for="54-设置系统主机名">5.4 设置系统主机名</a></li><li class="depth-1"><a href="#55-设置-hosts-文件" data-for="55-设置-hosts-文件">5.5 设置 Hosts 文件</a></li><li class="depth-1"><a href="#56-设置-root-密码" data-for="56-设置-root-密码">5.6 设置 Root 密码</a></li><li class="depth-0"><a href="#6引导加载程序" data-for="6引导加载程序">6.引导加载程序</a></li><li class="depth-1"><a href="#61-对于-uefi-系统" data-for="61-对于-uefi-系统">6.1 对于 UEFI 系统</a></li><li class="depth-1"><a href="#62-对于-bios-系统" data-for="62-对于-bios
</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>