Difference between revisions of "Beginners' guide (简体中文)"

From ArchWiki
Jump to: navigation, search
(时区: 移除无法确认也无必要的时区配置)
(update translation)
Line 16: Line 16:
 
[[sr:Beginners' Guide/Installation]]
 
[[sr:Beginners' Guide/Installation]]
 
[[zh-TW:Beginners' Guide/Installation]]
 
[[zh-TW:Beginners' Guide/Installation]]
{{TranslationStatus (简体中文)|Beginners'_Guide/Installation|2013-04-24|255026}}
+
{{TranslationStatus (简体中文)|Beginners'_Guide/Installation|2013-05-04|255856}}
 
{{小贴士|本文是多页文档 '''新手指南 ''' 的一部分,如果想阅读单页文档,请[[Beginners' Guide (简体中文)|点击这里]]。}}
 
{{小贴士|本文是多页文档 '''新手指南 ''' 的一部分,如果想阅读单页文档,请[[Beginners' Guide (简体中文)|点击这里]]。}}
 
</noinclude>
 
</noinclude>
Line 177: Line 177:
 
{{注意| 网卡需要的无线接口固件包在 live 环境中预先安装到了 {{ic|/lib/firmware}},'''但是必须特别安装到实际的系统才能在重启后提供无线功能!''' 向导的后面会介绍软件包的选择和安装。请确保在软件包选择的时候选中需要的无线模块和固件!如有任何疑问,请查看 [[Wireless Setup (简体中文)|无线设置]],这是常见错误。}}
 
{{注意| 网卡需要的无线接口固件包在 live 环境中预先安装到了 {{ic|/lib/firmware}},'''但是必须特别安装到实际的系统才能在重启后提供无线功能!''' 向导的后面会介绍软件包的选择和安装。请确保在软件包选择的时候选中需要的无线模块和固件!如有任何疑问,请查看 [[Wireless Setup (简体中文)|无线设置]],这是常见错误。}}
  
然后使用{{pkg|netcfg}}提供的 wifi-menu 连接到网络:
+
然后使用{{pkg|netctl}}提供的 wifi-menu 连接到网络:
 
  # wifi-menu wlp3s0
 
  # wifi-menu wlp3s0
  
Line 209: Line 209:
 
此例使用'''cfdisk''',将 cfdisk 替换为'''cgdisk'''可以使用新的[[GPT]]分区。
 
此例使用'''cfdisk''',将 cfdisk 替换为'''cgdisk'''可以使用新的[[GPT]]分区。
  
{{注意|如果要设置 GRUB 为 BIOS-GPT 模式,需要创建一个 2 MiB 的 "BIOS 启动分区". 参阅[[GRUB2#GUID Partition Table (GPT) specific instructions|BIOS 启动分区]].}}
+
{{注意|如果要设置 GRUB 为 BIOS-GPT 模式,需要创建一个 2 MiB 的 "BIOS 启动分区". 参阅[[GRUB#GUID Partition Table (GPT) specific instructions|BIOS 启动分区]].}}
  
 
{{注意|如果使用(U)EFI,则需要一个独立的分区保存 UEFI 系统分区,参阅[[Unified_Extensible_Firmware_Interface#Create_an_UEFI_System_Partition_in_Linux|此文]]。推荐所有 UEFI 使用 GPT 分区格式,有些 UEFI 固件不支持 UEFI-MBR 启动。}}
 
{{注意|如果使用(U)EFI,则需要一个独立的分区保存 UEFI 系统分区,参阅[[Unified_Extensible_Firmware_Interface#Create_an_UEFI_System_Partition_in_Linux|此文]]。推荐所有 UEFI 使用 GPT 分区格式,有些 UEFI 固件不支持 UEFI-MBR 启动。}}
Line 630: Line 630:
 
The Linux kernel can act as its own bootloader using EFISTUB. This is the UEFI boot method recommended by developers and simpler compared to {{ic|grub-efi-x86_64}}. The steps below set up rEFInd to provide a menu for EFISTUB kernels, as well as for booting other UEFI bootloaders. Alternative EFISTUB boot managers can be found on the page [[UEFI Bootloaders#Booting EFISTUB]]. Both rEFInd and [[gummiboot]] can detect Windows UEFI bootloaders in case of dual-boot.
 
The Linux kernel can act as its own bootloader using EFISTUB. This is the UEFI boot method recommended by developers and simpler compared to {{ic|grub-efi-x86_64}}. The steps below set up rEFInd to provide a menu for EFISTUB kernels, as well as for booting other UEFI bootloaders. Alternative EFISTUB boot managers can be found on the page [[UEFI Bootloaders#Booting EFISTUB]]. Both rEFInd and [[gummiboot]] can detect Windows UEFI bootloaders in case of dual-boot.
  
1a. Before chrooting, load the {{ic|efivars}} kernel module:
+
1. Mount the UEFI System Partition on {{ic|/mnt/boot/efi}} and chroot back into {{ic|/mnt}}.
 
+
# modprobe efivars      # before chrooting
+
 
+
1b. Mount the UEFI System Partition on {{ic|/mnt/boot/efi}} and chroot back into {{ic|/mnt}}.
+
  
 
2. [[UEFI Bootloaders#Setting up EFISTUB|Copy the kernel and initramfs files]] to {{ic|/mnt/boot/efi}}:
 
2. [[UEFI Bootloaders#Setting up EFISTUB|Copy the kernel and initramfs files]] to {{ic|/mnt/boot/efi}}:
Line 669: Line 665:
 
{{Warning|Using {{ic|efibootmgr}} on Apple Macs may brick the firmware and may need reflash of the motherboard ROM. For Macs, use {{AUR|mactel-boot}}, or "bless" from within OS X.}}
 
{{Warning|Using {{ic|efibootmgr}} on Apple Macs may brick the firmware and may need reflash of the motherboard ROM. For Macs, use {{AUR|mactel-boot}}, or "bless" from within OS X.}}
  
  # efibootmgr -c -g -d /dev/sdX -p Y -w -L "rEFInd" -l '\EFI\refind\refind_x64.efi'
+
  # efibootmgr -c -d /dev/sdX -p Y -w -L "rEFInd" -l '\EFI\refind\refind_x64.efi'
  
 
{{Note|On some systems, the above command will not work properly. It will execute without any visible error, but the UEFI boot menu will not have been correctly updated with a new entry. To determine whether the command executed properly, run {{ic|efibootmgr}} without any arguments and see if a new entry has appeared in the list displayed. If there is no new entry, then it will not be possible to enter rEFInd upon reboot, as the UEFI boot menu has been left unchanged. In this case, you will instead have to enter the UEFI shell and manually add an entry to the UEFI boot menu with the {{ic|bcfg}} command, as described [[Unified Extensible Firmware Interface#bcfg|here]].}}
 
{{Note|On some systems, the above command will not work properly. It will execute without any visible error, but the UEFI boot menu will not have been correctly updated with a new entry. To determine whether the command executed properly, run {{ic|efibootmgr}} without any arguments and see if a new entry has appeared in the list displayed. If there is no new entry, then it will not be possible to enter rEFInd upon reboot, as the UEFI boot menu has been left unchanged. In this case, you will instead have to enter the UEFI shell and manually add an entry to the UEFI boot menu with the {{ic|bcfg}} command, as described [[Unified Extensible Firmware Interface#bcfg|here]].}}

Revision as of 06:13, 3 May 2013

翻译状态: 本文是英文页面 Beginners'_Guide/Installation翻译,最后翻译时间:2013-05-04,点击这里可以查看翻译后英文页面的改动。
提示: 本文是多页文档 新手指南 的一部分,如果想阅读单页文档,请点击这里

安装

您将看到一个命令行提示,自动以 root 登陆。

修改语言

提示: 对于大部分用户,这些是非必需操作。只在这些情况下有需要:打算用母语编辑配置文件,在Wi-Fi密码中使用了变音记号,或需要母语显示的系统信息(如错误信息)。

键盘布局默认设为us(美式键盘映射),若正在使用非美式键盘布局,通过以下的命令选择相应的键盘映射表:

# loadkeys layout

layout 替换成你的键盘布局,如frukbe-latin1这里有完整的键盘映射列表。

多数语言使用多于26个英文字母的字形,因此字体也需要进行相应的修改,否则这些语言的文字会显示成白方块。注意这些名称是区分大小写的:

# setfont Lat2-Terminus16

系统默认将语言设为美式英语。若想在安装过程中使用其他语言(以德语为例),从/etc/locale.gen中去掉相应locale前的#。请选择含UTF-8的行。

按下Template:Keypress退出,在保存提示出现时按下Template:KeypressTemplate:Keypress来使用相同的文件名。

# nano /etc/locale.gen
en_US.UTF-8 UTF-8
de_DE.UTF-8 UTF-8
# locale-gen
# export LANG=de_DE.UTF-8

记得按下Template:Keypress启用新的映射

建立网络连接

Warning: udev 不再按照wlanX, ethX 的方式分配网络接口的名字。如果你是从其他发行版转来,请不要认为有线接口名字就是eth0,无线接口是wlan0,请用ip addr show命令查看接口的名字

自从systemd-197以来,udev现在会分配稳定而可预测的网络接口名字,与之前的方式不同。新的命名会保证在重启之后命名不变,解决了以前重启之后接口命名改变的问题,更多信息请看:http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames .

安装程序会自动运行 dhcpcd 尝试配置有线连接。可以通过 ping 一个网站检查是否成功。

# ping -c 3 www.baidu.com
PING www.a.shifen.com (61.135.169.105) 56(84) bytes of data.
64 bytes from 61.135.169.105: icmp_seq=1 ttl=57 time=0.495 ms
64 bytes from 61.135.169.105: icmp_seq=2 ttl=57 time=0.603 ms
64 bytes from 61.135.169.105: icmp_seq=3 ttl=57 time=0.590 ms

--- www.a.shifen.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1999ms
rtt min/avg/max/mdev = 0.495/0.562/0.603/0.055 ms

如果出现:ping: unknown host 错误,表示网络还不通,先检查网线接触是否良好,无线信号是否足够,然后需要用下面方法手动配置。

如果可以连通的话,继续 #准备硬盘

有线连接

如果使用静态ip配置连接到有线网络,请使用如下方式配置。

首先,禁用自动启动的 dhcpcd 服务:

# systemctl stop dhcpcd

用ip命令查看有线连接的接口名字。

# ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: enp2s0f0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT qlen 1000
    link/ether 00:11:25:31:69:20 brd ff:ff:ff:ff:ff:ff
3: wlp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DORMANT qlen 1000
    link/ether 01:02:03:04:05:06 brd ff:ff:ff:ff:ff:ff

在这个例子中,有线连接的接口名字为enp2s0f0。如果你不确定的话,有线连接一般以"e"开头,一般不会以"lo"或"w"开头。你也可以用iwconfig命令查看哪些接口不是无线的来帮助你判断有线连接的接口名。

# iwconfig
enp2s0f0  no wireless extensions.
wlp3s0    IEEE 802.11bgn  ESSID:"NETGEAR97"  
          Mode:Managed  Frequency:2.427 GHz  Access Point: 2C:B0:5D:9C:72:BF   
          Bit Rate=65 Mb/s   Tx-Power=16 dBm   
          Retry  long limit:7   RTS thr:off   Fragment thr:off
          Power Management:on
          Link Quality=61/70  Signal level=-49 dBm  
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:430   Missed beacon:0
lo        no wireless extensions.

在这个例子中,enp2s0f0和lo都不是无线设备,所以enp2s0f0是有线接口。

你也应该了解以下信息:

  • 静态IP地址,
  • 子网掩码,
  • 网关IP地址,
  • 域名服务器(DNS)IP地址,
  • 域名 (unless a local LAN, in which case you can make it up).

激活接口,(例如enp2s0f0):

# ip link set enp2s0f0 up

添加地址:

# ip addr add <ip 地址>/<子网掩码> dev <接口名>

例如:

# ip addr add 192.168.1.2/24 dev enp2s0f0

更多信息参看: man ip

用类似下面的命令添加网关,ip 地址替换为实际的网关地址:

# ip route add default via <ip 地址>

例如:

# ip route add default via 192.168.1.1

编辑 /etc/resolv.conf 如下, 替换你的DNS服务器IP地址和本地域名:

# nano /etc/resolv.conf
 nameserver 8.8.8.8
 nameserver 114.114.114.114
 search example.com
注意: 目前,你最多只能包含三行nameserver字段.

这时应该已经有一个可用的有线网络了,如果没有,请查阅详细的配置网络页面。

无线网络

如果需要用Wi-Fi连接网络,请采用以下步骤。

现在在安装媒体中已经包含了无线网络驱动和工具。对无线网络硬件有一定的了解是完成无线网络设置的重要前提。注意下面的在安装时执行的快速设置过程中会初始化live环境中的无线网络硬件。安装好系统以后,无线网络设置(或其他无线管理操作)需要再次执行一遍

并且注意如果安装过程中并不需要无线网络,不需执行下面的步骤。可以在系统安装好之后再设置无线网络功能。

首先确定网络接口名称, 一般无线接口以w而不是loe开头.

# iwconfig
enp2s0f0  no wireless extensions.
wlp3s0    IEEE 802.11bgn  ESSID:"NETGEAR97"
          Mode:Managed  Frequency:2.427 GHz  Access Point: 2C:B0:5D:9C:72:BF
          Bit Rate=65 Mb/s   Tx-Power=16 dBm
          Retry  long limit:7   RTS thr:off   Fragment thr:off
          Power Management:on
          Link Quality=61/70  Signal level=-49 dBm
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:430   Missed beacon:0
lo        no wireless extensions.

下面的示例中使用 wlp3s0 作为接口,linksys 作为 ESSID。请根据实际情况修改。

注意: 输出和下面不相似表示驱动没有载入,需要自己加入,详情请查看 无线设置
  • 启用接口:
# ip link set wlp3s0 up

除了驱动,一小部分无线网卡还需要固件。启用网络时,缺少固件的接口会显示:

# ip link set wlp3s0 up
SIOCSIFFLAGS: No such file or directory

若不确定,可以用 dmesg 查询内核日志,看看有没有来自无线网卡的固件请求。

Intel 芯片组在启动时请求固件的例子:

# dmesg | grep firmware
firmware: requesting iwlwifi-5000-1.ucode

如果没有输出,表示系统的无线芯片不需要固件。

注意: 网卡需要的无线接口固件包在 live 环境中预先安装到了 /lib/firmware但是必须特别安装到实际的系统才能在重启后提供无线功能! 向导的后面会介绍软件包的选择和安装。请确保在软件包选择的时候选中需要的无线模块和固件!如有任何疑问,请查看 无线设置,这是常见错误。

然后使用netctl提供的 wifi-menu 连接到网络:

# wifi-menu wlp3s0

到此,无线网络应该已经可用,如遇问题,请查看无线设置

xDSL (PPPoE), 模拟调制解调器或者 ISDN

如果你使用拨号网络或者ISDN,请阅读Direct Modem Connection

位于代理服务器后面

如果使用代理服务器,请 export http_proxyftp_proxy 变量。查看这里 获取更多信息。

准备存储设备

警告: 磁盘分区有时会毁掉原分区内的数据。强烈建议先备份重要的数据。

新手建议使用图形化的分区工具。GParted 是个很不错的选择。可以从 "live" Linux 发行版 (如 Parted Magic, Ubuntu, Linux Mint, 等等) 启动。硬盘在使用前需要先分区,然后将分区格式化为需要的文件系统.

In addition, some newer computers come pre-installed with Windows 8 which will be using Secure Boot. Arch Linux currently does not support Secure Boot, but some Windows 8 installations have been seen not to boot if Secure Boot is turned off in the BIOS. In some cases it is necessary to turn off both Secure Boot as well as Fastboot in the BIOS options in order to allow Windows 8 to boot without Secure Boot. However there are potential security risks in turning off Secure Boot for booting up Windows 8. Therefore, it may be a better option to keep the Windows 8 install intact and have an independent hard drive for the Linux install - which can then be partitioned from scratch using a GPT partition table. Once that is done, creating several ext4/FAT32/swap partitions on the second drive may be a better way forward if the computer has two drives available. This is often not easy or possible on a small laptop. Currently, Secure Boot is still not in a fully stable state for reliable operation, even for Linux distributions that support it.

如果你想现在设定交换分区,参见 Swap 获取更多信息,使用交换文件的话,修改文件的大小比修改分区大小更方便,但是目前交换文件不支持 Btrfs。

如果你已经分过区,继续 挂载分区. 否则,参考下面的例子。

分区示例

当前安装盘包含如下工具:fdisk, gdisk, cfdisk, cgdisk, parted.

Tip: lsblk命令显示连接到系统的硬盘和分区,这样可以确定要使用的分区。

此例使用cfdisk,将 cfdisk 替换为cgdisk可以使用新的GPT分区。

注意: 如果要设置 GRUB 为 BIOS-GPT 模式,需要创建一个 2 MiB 的 "BIOS 启动分区". 参阅BIOS 启动分区.
注意: 如果使用(U)EFI,则需要一个独立的分区保存 UEFI 系统分区,参阅此文。推荐所有 UEFI 使用 GPT 分区格式,有些 UEFI 固件不支持 UEFI-MBR 启动。
注意: 如果你不打算与 windows 双系统启动,建议使用GPT而不是MBR. GPT 分区只能通过gdiskparted完成. GPT中介绍了它的优点。
注意: 如果要安装 Arch Linux 到U盘(USB闪存盘),参见Installing Arch Linux on a USB key

示例硬盘将划分为15GB的根分区/、剩下的作为/home,选择 MBRGPT 其中的一个。

需要再次强调的是,真正的分区取决于个人的选择,此处的示例仅供参考。详细分区介绍请参阅Partitioning.

MBR cfdisk /dev/sda Root:

Home:

GPT cgdisk /dev/sda Root:
Home:

完成之后,MBR 分区界面应该类似下面这样:

Name    Flags     Part Type    FS Type           [Label]         Size (MB)
-------------------------------------------------------------------------
sda1    Boot       Primary     Linux                             15360       #root
sda2               Primary     Linux                             133000      #/home

GPT 分区类似:

Part. #     Size        Partition Type            Partition Name
----------------------------------------------------------------
            1007.0 KiB  free space
   1        15.0 GiB    Linux filesystem
   2        123.45 GiB  Linux filesystem

请再次仔细检查分区大小和布局是否正确。

如果要重新开始,可以选择 Quit 退出分区程序。

确认无误后,选择Write (或者按 Template:Keypress) 完成分区,并输入yes将修改写入磁盘,然后退出

分区之后,还需要用 mkfs 将分区格式化为选定的文件系统。本例中 root 和 home 分区都使用 ext4:

# mkfs.ext4 /dev/sda1
# mkfs.ext4 /dev/sda2

如果你分了一个swap区,不要忘了格式化和启用它:

# mkswap /dev/sdaX
# swapon /dev/sdaX

挂载分区

要检查当前磁盘的标识符和布局:

 # lsblk /dev/sda
注意: 不要在同一个目录挂载多个分区,而且按照顺序挂载很重要。

记下将要安装上 Arch 的磁盘/分区。每个分区都能通过一个数字后缀来辨认。如:sda1即指某一磁盘的第一分区,而sda则表示整个磁盘。

注意要按照顺序挂载,先挂载根分区到/mnt.

 # mount /dev/sda1 /mnt

然后挂载/home分区和其余单独分区(/boot, /var 等)。

然后在 /mnt 中创建 home 目录并挂载分区:

# mkdir /mnt/home
# mount /dev/sda2 /mnt/home

如果是 UEFI 主板,挂载 UEFI 分区:

# mkdir -p /mnt/boot/efi
# mount /dev/sdaX /mnt/boot/efi

选择安装镜像

安装前需要编辑 /etc/pacman.d/mirrorlist,将最想使用的镜像放到前面。mirrorlist 文件也会被pacstrap复制到新系统,所以最好现在就设置好。

注意: ftp.archlinux.org 限速 50KB/s.

ArchLinux 镜像状态 报告了镜像的各种状态,包括网络问题,数据收集问题、上次同步时间等等。如果需要最新的软件包,最好手动检查一下 /etc/pacman.d/mirrorlist,确保文件包含了最新的镜像。

此外 镜像生成器 可以自动根据更新状况生成离你比较近的镜像列表。

用编辑器打开 /etc/pacman.d/mirrorlist 并取消离你近的镜像前的注释(删除前面的 '#' ),然后刷新软件包列表:

# pacman -Syy

传入两个 --refresh-y 会强制 pacman 刷新所有软件包列表,即使刚刚更新过。一般情况下,只要源有了更改,就应该使用 pacman -Syy 命令。

详情请参阅 Mirrors.

注意: Some issues have been reported in the Arch Linux forums regarding network problems that prevent pacman from updating/synchronizing repositories (see [1] and [2]). When installing Arch Linux natively, these issues have been resolved by replacing the default pacman file downloader with an alternative (see Improve Pacman Performance for more details). When installing Arch Linux as a guest OS in VirtualBox, this issue has also been addressed by using "Host interface" instead of "NAT" in the machine properties.

安装基本系统

注意: 安装前请设置系统时间,否则密钥验证会认为密钥过期,验证失败。设置方法位于 Time

使用 pacstrap 脚本安装基本系统:

# pacstrap /mnt base base-devel

如果 pacman 报告安装时遇到错误的签名(error: failed to commit transaction (invalid or corrupted package)),请运行如下命令:

# pacman-key --init && pacman-key --populate archlinux 
base 
来自 [core] 软件源的最小基本系统。
base-devel 
来自 [core] 的附加工具例如makeautomake。大部分新手都应该安装它,后续扩展系统会用到它,安装AUR中软件包时,base-devel也是必须的。

如果不知道还需要什么软件,可以先跳过,后面可以用 pacman 安装。

注意: 如果需要连接无线网络,请选中wireless_tools软件包。一些无线接口还需要 ndiswrapper 和特定 firmware。如果使用 WPA 加密,需要 wpa_supplicant无线设置 页面将帮助您为无线设备选择正确的软件包。

生成 fstab

用下面命令生成 fstab。如果想使用 UUIDs,使用 -U 选项;如果想使用标签,用 -L 选项.

# genfstab -U -p /mnt >> /mnt/etc/fstab
# nano /mnt/etc/fstab
Note: 后面如果出现问题,请不要再次运行genfstab,如果需要,手动编辑/etc/fstab。

使用 -U 选项会用 UUID 指定分区,使用-L会用标签指定分区。

fstab(file systems table的缩写) 是系统配置的一部分,该文件列出所有可用的磁盘和分区,并指明它们初始化的方式或整合至全局文件系统的方式。/etc/fstab 文件一般被mount命令读取,mount 以设备上的文件系统为参数,将其添加到主目录结构。在启动过程执行到 3/4 左右的时候,/etc/fstab 会调用 mount -a,mount 读取/etc/fstab 以确定挂载时使用的选项。如果 noauto 位于 /etc/fstab 中的文件系统之后,mount -a 不会在启动时挂载它。 仅根分区需要在最后使用 "1",其它可以使用 "2" 或 "0" (参阅字段定义).

Warning: /etc/fstab文件在运行genfstab后应该被检查一下。如果之前你生成了一个EFI系统分区,那么 genfstab给EFI分区添加了错误的选项,会导致无法启动。因此你需要移除EFI分区的所有选项,除了noatime. 对其他分区, 替换"codepage=cp437""codepage=437" , 会挂载失败导致systemd进入恢复模式否则,在linux 3.8应该会被修复。

此外,只有(/)根分区需要将最后一列设为1其它应该为20 (参阅fstab#Field definitions).

Chroot 到新系统

下面要 chroot 到新安装的系统:

# arch-chroot /mnt
注意: 可以使用arch-chroot /mnt /bin/bash进入 bash shell.

到这一步之后,开始系统的主要配置,如果下面文件不存在,需要手动创建。

理解并完全安装步骤设置是保证系统配置成功的关键。

配置系统

Locale

glibc 和其他一些支持本地化的程序或者库使用 Locales 自动翻译输出各种语言的"独特" 文本, 并且合适的显示地域、货币、时区以及日期格式、字符排列方式和其他一些本地化的特定标准。

需要编辑两个文件:locale.genlocale.conf.

  • 默认情况下 /etc/locale.gen 是一个仅包含注释文档的空文件。选定你需要的本地化类型(移除前面的#即可), 比如中文系统可以使用:
en_US.UTF-8 UTF-8
zh_CN.GB18030 GB18030
zh_CN.GBK GBK
zh_CN.UTF-8 UTF-8
zh_CN GB2312

然后运行:

# locale-gen

每次glibc更新之后就会运行 locale-gen 一次, 重新生成 /etc/locale.gen 指定的本地化文件。

  • locale.conf 文件默认不存在,一般设置LANG就行了,它是其它设置的默认值。
/etc/locale.conf
LANG=zh_CN.UTF-8
LC_TIME=en_GB.UTF-8

要使用其它 LC_* 变量,先运行 locale 查看可用选项。高级示例可以参阅here.不建议使用LC_ALL变量,因为它会覆盖全部设置。

终端字体和键盘映射

编辑/etc/vconsole.conf.

KEYMAP
可用的键盘映射位于/usr/share/kbd/keymaps. 注意此设置仅对 TTY 起作用,不改变图形窗口或X的设置。
FONT 
可用字体位于 /usr/share/kbd/consolefonts/,一般可用留空。
FONT_MAP 
可选设置,定义要加载的映射,请参考 man setfont。可以删除或者留空。

Example:

KEYMAP=us
FONT=
Note: 详情参阅 Console fontsman vconsole.conf.

时区

/etc/localtime 软链接到 /usr/share/zoneinfo/Zone/SubZone.其中 ZoneSubzone 替换为所在时区,例如

# ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

硬件时间

/etc/adjtime 中设置,默认、推荐的设置为UTC。详细信息请阅读Time (简体中文)

请在同一个机器使用同一个硬件时钟模式,否则它们会覆盖时间导致时间错乱。

可以用下面命令自动生成 /etc/adjtime

UTC(推荐使用):

注意: 硬件时钟使用 UTC 不代表显示时间时使用 UTC.
# hwclock --systohc --utc

localtime,不推荐,但 Windows 默认使用此方式:

警告: 使用 localtime 可能导致一些无法修复的 bug。但目前还没有取消此设置选项的计划。
# hwclock --systohc --localtime

如果要和 Windows 进行双系统启动:

  • Recommended: Set both Arch Linux and Windows to use UTC. A quick registry fix is needed. Also, be sure to prevent Windows from synchronizing the time on-line, because the hardware clock will default back to localtime. If you want such functionality (NTP sync), you should use ntpd on your Arch Linux installation instead.
  • Not recommended: Set Arch Linux to localtime and disable any time-related services, like ntpd.service. This will let Windows take care of hardware clock corrections and you will need to remember to boot into Windows at least two times a year (in Spring and Autumn) when DST kicks in. So please don't ask on the forums why the clock is one hour behind or ahead if you usually go for days or weeks without booting into Windows.

内核模块

Tip: 一般情况下 udev 会自动加载需要的模块,大部分用户都不需要手动修改。这里只需要加入真正需要的模块。

/etc/modules-load.d/中保存内核启动时加入模块的配置文件。每个配置文件以/etc/modules-load.d/<program>.conf的格式命名。配置文件中包含需要装入的内核列表,每个一行。空行和以 #; 开头的行直接被忽略。示例:

/etc/modules-load.d/virtio-net.conf
# Load virtio-net.ko at boot
virtio-net

Hostname

按喜好设置主机名

# echo myhostname > /etc/hostname
注意: 现在已经不需要再编辑/etc/hosts.

配置网络

你需要再次配置网络,但此次是为你所安装的系统而配置。 该过程与前面的配置方法基本相同,不同之处在于我们此刻将使其在计算机启动时自动运行。

注意: 了解更多网络配置相关信息, 请访问 配置网络Wireless 设置.

Wired

Dynamic IP
Warning: A bug has been noted in the install ISO, in which the name your interface has during installation differs from the one it will have upon reboot. See Bug #33923 for more details.
Use the command ip link (shows interface names) after rebooting into your installed system to find out if you are affected by this. If so, you will have to redo the configuration described below with the correct interface name.

If you only use a single fixed wired network connection, you do not need a network management service and can simply enable the dhcpcd service. Here, interface_name is your wired interface:

# systemctl enable dhcpcd@interface_name.service

And that's it.

Move on to the next step: Create an initial ramdisk environment.

Alternatively, you can use netctl's netctl-ifplugd, which gracefully handles dynamic connections to new networks:

Install ifplugd, which is required for netctl-ifplugd:

# pacman -S ifplugd

Then enable for interface that you want:

# systemctl enable netctl-ifplugd@<interface>.service

Or, you can create a profile for your interface (no need ifplugd):

Copy a sample profile from /etc/netctl/examples to /etc/netctl/:

# cd /etc/netctl
# cp examples/ethernet-dhcp .

Edit the profile as needed (modify Interface):

# nano ethernet-dhcp

Enable the ethernet-dhcp profile:

# netctl enable ethernet-dhcp
Static IP

Copy a sample profile from /etc/netctl/examples to /etc/netctl/:

# cd /etc/netctl
# cp examples/ethernet-static .

Edit the profile as needed (modify Interface, Address, Gateway and DNS):

# nano ethernet-static

Then enable above created profile:

# netctl enable ethernet-static

Wireless

You will need to install additional programs to be able to configure and manage wireless network profiles for netcfg.

NetworkManager and Wicd are other popular alternatives.

  • Install the required packages:
# pacman -S wireless_tools wpa_supplicant wpa_actiond dialog

If your wireless adapter requires a firmware (as described in the above Establish an internet connection section and also here), install the package containing your firmware. For example:

# pacman -S zd1211-firmware

See Wireless Setup and WPA supplicant for more info.

  • After finishing the rest of this installation and rebooting, you can connect to the network with wifi-menu interface_name (where interface_name is the interface of your wireless chipset), which will generate a profile file in /etc/network.d named after the SSID. There are also templates available in /etc/network.d/examples/ for manual configuration.
# wifi-menu interface_name
Warning: If you're using wifi-menu, this must be done *after* your reboot when you're no longer chrooted. The process spawned by this command will conflict with the one you have running outside of the chroot. Alternatively, you could just configure a network profile manually using the templates previously mentioned so that you don't have to worry about using wifi-menu at all.
  • Enable the net-auto-wireless service, which will connect to known networks and gracefully handle roaming and disconnects:
# systemctl enable net-auto-wireless.service
Note: From Netcfg#Net-Auto-Wireless: wireless-wpa-config profiles do not work with net-auto-wireless. Convert them to wireless-wpa-configsection or wireless-wpa instead.
Note: Netcfg also provides net-auto-wired, which can be used in conjunction with net-auto-wireless.
Note: Wpasupplicant could be fail with message "WPA Authentication/Association Failed". In that case, see this link for a solution.
  • Make sure that the correct wireless interface (e.g. wlp3s0) is set in /etc/conf.d/netcfg:
# nano /etc/conf.d/netcfg
WIRELESS_INTERFACE="wlp3s0"

It is also possible to define a list of network profiles that should be automatically connected, using the AUTO_PROFILES variable in /etc/conf.d/netcfg. If AUTO_PROFILES is not set, all known wireless networks will be tried.

Analog modem, ISDN or PPoE DSL

For xDSL, dial-up and ISDN connections, see Direct Modem Connection.

创建初始 ramdisk 环境

注意: 大部分用户都不需要在安装时修改此文件。

如有需要,配置 /etc/mkinitcpio.conf(参阅 mkinitcpio) ,然后执行以下命令创建RAM盘:

# mkinitcpio -p linux

此文件负责微调初始内存文件系统 initramfs。(曾被称为初始化内存磁盘或 "initrd")。initramfs 是启动时供内核读取的压缩镜像。目的是引导系统使其能够读取根文件系统。所以它需要装入 IDE、SCSI、SATA 或 USB/FW 等设备所需模块。initramfs 手动或通过 udev 装入所需的模块后,会将控制权交给内核,继续启动过程。因此 initramfs 仅需要包含读取根文件系统的必要文件。大部分内核模块都是在初始化过程中由 udev 装入。

如果根文件系统使用 RAID 或 LVM,必须配置正确的 HOOKS。详情请查看 RAID /etc/mkinitcpio。如果使用非 US 键盘,请添加 "keymap " 钩子以载入本地键盘映射。如果使用 USB 键盘,请添加 "usbinput" 。否则,如果出了什么问题无法启动,系统会要求输入密码以进行维护,但确无法使用键盘。将 Arch 安装到外部硬盘、CF 卡或 SD 卡时,记得添加 "usb"。最好加入 fsck 以在系统启动时进行磁盘检查。示例:

HOOKS="base udev autodetect pata scsi sata usb filesystems keymap usbinput fsck"

如果需要通过如下设备启动,请按需要配置 HOOKS: USB 设备、FireWire、PCMCIA、NFS、软 RAID、LVM2 卷、加密卷 和 DSDT 等。

Here you need to set the right hooks if the root is on a USB drive, if you use RAID, LVM, or if /usr is on a separate partition.

Edit /etc/mkinitcpio.conf as needed and re-generate the initramfs image with:

# mkinitcpio -p linux
Note: Arch VPS installations on QEMU (e.g. when using virt-manager) may need virtio modules in mkinitcpio.conf to be able to boot.
# nano /etc/mkinitcpio.conf
MODULES="virtio virtio_blk virtio_pci virtio_net"

设置 Root 密码

passwd 设置一个root密码:

# passwd

安装配置启动加载器

For BIOS motherboards

BIOS 系统由三个供选择 - Syslinux, GRUB, 和 LILO. 按个人喜好选择一个启动加载器,下面仅介绍 Syslinux 和 GRUB。

  • Syslinux is (currently) limited to loading only files from the partition where it was installed. Its configuration file is considered to be easier to understand. An example configuration can be found here.
  • GRUB is more feature-rich and supports more complex scenarios. Its configuration file(s) is similar more to a scripting language, which may be difficult for beginners to manually write. It is recommended that they automatically generate one.
Syslinux

Install the syslinux package and then use the syslinux-install_update script to automatically install the files (-i), mark the partition active by setting the boot flag (-a), and install the MBR boot code (-m):

Note: If you have partitioned the drive as GPT, install gptfdisk package, as well (pacman -S gptfdisk), because it contains sgdisk, which will be used to set the GPT-specific boot flag.
# pacman -S syslinux
# syslinux-install_update -iam

编辑 /boot/syslinux/syslinux.cfg,将 / 指向正确的根分区,这是必须的,否则 Arch 启动不起来。将"sda3"修改为实际的根分区。同样,修改LABEL archfallback.

# nano /boot/syslinux/syslinux.cfg
...
LABEL arch
 ...
 APPEND root=/dev/sda3 ro

Syslinux 的详细使用和配置请阅读Syslinux

Grub
Note: For GPT-partitioned drives on BIOS motherboards, GRUB needs a 2 MiB "BIOS Boot Partition".
Note: Please do not use something like /dev/sda1 in the below command.

Install the grub-bios package and then run grub-install /dev/sda:

# pacman -S grub-bios
# grub-install --recheck /dev/sda
# cp /usr/share/locale/en\@quot/LC_MESSAGES/grub.mo /boot/grub/locale/en.mo

虽然手动配置grub.cfg完全可以工作,建议用户自动生成这个文件。

要搜索硬盘上安装的其它操作系统,请先用 # pacman -S os-prober 安装 os-prober

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

详细配置信息请阅读GRUB

For UEFI motherboards

For UEFI boot, the drive needs to be GPT-partitioned, and a UEFI System Partition (512 MiB or larger, type EF00, formatted with FAT32) must be present and mounted on /boot/efi. If you have followed this guide from the beginning, you've already done all of these.

While there are other UEFI bootloaders available, using EFISTUB is recommended. Below are instructions for setting up EFISTUB and GRUB (of course you choose only one of them).

Note: Syslinux does not yet support UEFI.
EFISTUB

The Linux kernel can act as its own bootloader using EFISTUB. This is the UEFI boot method recommended by developers and simpler compared to grub-efi-x86_64. The steps below set up rEFInd to provide a menu for EFISTUB kernels, as well as for booting other UEFI bootloaders. Alternative EFISTUB boot managers can be found on the page UEFI Bootloaders#Booting EFISTUB. Both rEFInd and gummiboot can detect Windows UEFI bootloaders in case of dual-boot.

1. Mount the UEFI System Partition on /mnt/boot/efi and chroot back into /mnt.

2. Copy the kernel and initramfs files to /mnt/boot/efi:

# mkdir -p /boot/efi/EFI/arch/
# cp /boot/vmlinuz-linux /boot/efi/EFI/arch/vmlinuz-arch.efi
# cp /boot/initramfs-linux.img /boot/efi/EFI/arch/initramfs-arch.img
# cp /boot/initramfs-linux-fallback.img /boot/efi/EFI/arch/initramfs-arch-fallback.img

Every time the kernel and initramfs files are updated in /boot, they need to be updated in /boot/efi/EFI/arch. This can be automated using systemd.

3. For the rEFInd boot manager, install refind-efi and efibootmgr:

# pacman -S refind-efi efibootmgr

4. Install rEFInd to the UEFI System Partition (summarized from UEFI Bootloaders#Using rEFInd):

# mkdir -p /boot/efi/EFI/refind
# cp /usr/lib/refind/refind_x64.efi /boot/efi/EFI/refind/refind_x64.efi
# cp /usr/lib/refind/config/refind.conf /boot/efi/EFI/refind/refind.conf
# cp -r /usr/share/refind/icons /boot/efi/EFI/refind/icons

5. Create a refind_linux.conf file with the kernel parameters to be used by rEFInd:

# nano /boot/efi/EFI/arch/refind_linux.conf
"Boot to X"          "root=/dev/sdaX ro rootfstype=ext4 systemd.unit=graphical.target"
"Boot to console"    "root=/dev/sdaX ro rootfstype=ext4 systemd.unit=multi-user.target"
Note: refind_linux.conf is copied in the directory /boot/efi/EFI/arch/ where the initramfs and the kernel have been copied to in step 2.
Note: In refind_linux.conf, sdaX refers to your root file system, not your boot partition, if you created them separately.

6. Add rEFInd to UEFI boot menu using efibootmgr. Replace X and Y with the drive and partition of the UEFI System Partition. For example, in /dev/sdc5, X is "c" and Y is "5".

Warning: Using efibootmgr on Apple Macs may brick the firmware and may need reflash of the motherboard ROM. For Macs, use mactel-bootAUR, or "bless" from within OS X.
# efibootmgr -c -d /dev/sdX -p Y -w -L "rEFInd" -l '\EFI\refind\refind_x64.efi'
Note: On some systems, the above command will not work properly. It will execute without any visible error, but the UEFI boot menu will not have been correctly updated with a new entry. To determine whether the command executed properly, run efibootmgr without any arguments and see if a new entry has appeared in the list displayed. If there is no new entry, then it will not be possible to enter rEFInd upon reboot, as the UEFI boot menu has been left unchanged. In this case, you will instead have to enter the UEFI shell and manually add an entry to the UEFI boot menu with the bcfg command, as described here.
GRUB
Note: In case you have a system with 32-bit EFI, like pre-2008 Apple Macs, install grub-efi-i386 instead of grub-efi-x86_64.
# pacman -S grub-efi-x86_64 efibootmgr
# grub-install --efi-directory=/boot/efi --bootloader-id=arch_grub --recheck
# cp /usr/share/locale/en\@quot/LC_MESSAGES/grub.mo /boot/grub/locale/en.mo

Next, while using a manually created grub.cfg is absolutely fine, it's recommended that beginners automatically generate one:

Tip: To automatically search for other operating systems on your computer, install os-prober (pacman -S os-prober) before running the next command.
# grub-mkconfig -o /boot/grub/grub.cfg
Note: grub-install should create a new entry in the UEFI boot menu. If it doesn't, you will instead have to enter the UEFI shell and manually add an entry to the UEFI boot menu with the bcfg command, as described here.

For more information on configuring and using GRUB, see GRUB.

卸载分区并重启系统

如果还在 chroot 环境,先用 exit 命令退出系统:

# exit

卸载/mnt中挂载的系统:

# umount /mnt/{boot,home,}

重启:

# reboot
提示: 确保移除安装媒介并修改 BIOS 中的启动选项;否则可能会启动后会回到安装界面!

Template:Beginners' Guide navigation (简体中文)