Beginners' Guide/Installation (简体中文)
Contents |
安装
您将看到一个命令行提示,自动以 root 登陆。
修改语言
键盘布局默认设为us(美式键盘映射),若正在使用非美式键盘布局,通过以下的命令选择相应的键盘映射表:
# loadkeys layout
把 layout 替换成你的键盘布局,如fr,uk, dvorak或be-latin1。[[这里有国家与二位代码的映射表。
多数语言使用多于26个英文字母的字形,因此字体也需要进行相应的修改,否则这些语言的文字会显示成白方块。注意这些名称是区分大小写的:
# setfont Lat2-Terminus16
系统默认将语言设为美式英语。若想在安装过程中使用其他语言(以德语为例),从/etc/locale.gen中去掉相应locale前的#。请选择含UTF-8的行。
按下Ctrl+X退出,在保存提示出现时按下Y和Enter来使用相同的文件名。
# nano /etc/locale.gen
en_US.UTF-8 UTF-8 de_DE.UTF-8 UTF-8
# locale-gen # export LANG=de_DE.UTF-8
记得按下LAlt+LShift启用新的映射
建立网络连接
安装程序会自动运行 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地址,
- 域名 (如果是本地局域网,可以任意取名).
激活接口,(例如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
这时应该已经有一个可用的有线网络了,如果没有,请查阅详细的配置网络页面。
无线网络
如果需要用Wi-Fi连接网络,请采用以下步骤。
现在在安装媒体中已经包含了无线网络驱动和工具。对无线网络硬件有一定的了解是完成无线网络设置的重要前提。注意下面的在安装时执行的快速设置过程中会初始化live环境中的无线网络硬件。安装好系统以后,无线网络设置(或其他无线管理操作)需要再次执行一遍。
并且注意如果安装过程中并不需要无线网络,不需执行下面的步骤。可以在系统安装好之后再设置无线网络功能。
首先确定网络接口名称:
# iw dev
phy#0
Interface wlp3s0
ifindex 3
wdev 0x1
addr 00:21:6a:5e:52:bc
type managed
下面的示例中使用 wlp3s0 作为接口,linksys 作为 ESSID。请根据实际情况修改。
- 启用接口:
# ip link set wlp3s0 up
除了驱动,一小部分无线网卡还需要固件。内核一般会自动探测并加载固件,如果启用网络时,缺少固件的接口会提示错误:SIOCSIFFLAGS: No such file or directory。若不确定,可以用 dmesg 查询内核日志,看看有没有来自无线网卡的固件请求。Intel 芯片组在启动时请求固件的例子:
# dmesg | grep firmware
firmware: requesting iwlwifi-5000-1.ucode
如果没有输出,表示系统的无线芯片不需要固件。
然后使用netctl提供的 wifi-menu 连接到网络:
# wifi-menu wlp3s0
到此,无线网络应该已经可用,如遇问题,请查看无线设置。
手动配置方法,先扫描网路:
# iw dev wlp3s0 scan | grep SSID
连接网络:
# wpa_supplicant -B -i wlp3s0 -c <(wpa_passphrase "ssid" "psk")
将 ssid 替换为实际网络的名称,psk 替换为无线密码,请保留引号。最后,用 dhcp 获取 IP 地址:
# dhcpcd wlp3s0
如果不行,可以试试
# echo 'ctrl_interface=DIR=/run/wpa_supplicant' > /etc/wpa_supplicant.conf # wpa_passphrase <ssid> <passphrase> >> /etc/wpa_supplicant.conf # ip link set <interface> up # May not be needed as dhcpcd should bring it up but may be needed for wpa_supplicant. # wpa_supplicant -B -D nl80211 -c /foobar.conf -i <interface name> # dhcpcd -A <interface name>
xDSL (PPPoE), 模拟调制解调器或者 ISDN
如果你使用拨号网络或者ISDN,请阅读Direct Modem Connection。
位于代理服务器后面
如果使用代理服务器,请 export http_proxy 和 ftp_proxy 变量。查看这里 获取更多信息。
准备存储设备
选择分区表类型
可以选择使用 GUID Partition Table (GPT) 或者 Master Boot Record (MBR). GPT 更现代,建议新安装系统时使用。
- 如果要和 windows 双系统启动,需要仔细阅读 Partitioning#Choosing_between_GPT_and_MBR 作出选择。
- 推荐所有 UEFI 使用 GPT 分区格式,有些 UEFI 固件不支持 UEFI-MBR 启动。
- 有些 BIOS 系统不支持 GPT,参阅and http://rodsbooks.com/gdisk/bios.html 这里
- 如果要安装 Arch Linux 到U盘(USB闪存盘),请阅读Installing Arch Linux on a USB key。
Partitioning tool
新手建议使用图形化的分区工具。GParted 是个很不错的选择。可以从 "live" Linux 发行版 (如 Parted Magic, Ubuntu, Linux Mint, 等等) 启动。硬盘在使用前需要先分区,然后将分区格式化为需要的文件系统.
gparted 可能更容易使用,如果仅要创建几个分区,可以通过fdisk 相关程序快速完成,这些工具安装盘里面已经包含,参阅 Partitioning.
Partition scheme
You can decide into how many partitions the disk should be split, and for which directory each partition should be used in the system. The mapping from partitions to directories (frequently called 'mount points') is the Partition scheme. The simplest, and not a bad choice, is to make just one huge / partition. Another popular choice is to have a / and a /home partition.
如果你想现在设定交换分区,参见 Swap 获取更多信息,使用交换文件的话,修改文件的大小比修改分区大小更方便,但是目前交换文件不支持 Btrfs。
Considerations for dualbooting with windows
If you have an existing OS installation, please keep in mind that if you were to just write a completely new partition table to disk then all the data which was previously on disk would be lost.
The recommended way to setup a linux/windows dual booting system is to first install windows, only using part of the disk for its partitions. When you have finished the windows setup, boot into the linux install environment where you can create additional partitions for linux while leaving the existing windows partitions untouched.
此外,新的预装 Windows 8 电脑都默认使用安全启动。 Arch Linux 当前还不支持安全启动,如果在 BIOS 中关闭安全启动则会出现一些预装的 Windows 8 现无法启动的情况。在某些情况下,同时在 BIOS 中关闭安全启动和 FASTBOOT 选项让 Windows 8 开机无安全启动是很有必要的。 因此,这也许是一个更好的方案 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.
如果你已经分过区,继续 挂载分区. 否则,参考下面的例子。
分区示例
当前安装盘包含如下工具:fdisk, gdisk, cfdisk, cgdisk, parted.
此例使用cfdisk,将 cfdisk 替换为cgdisk可以使用新的GPT分区。
示例硬盘将划分为15GB的根分区/、剩下的作为/home,选择 MBR 或 GPT 其中的一个。
需要再次强调的是,真正的分区取决于个人的选择,此处的示例仅供参考。详细分区介绍请参阅Partitioning.
Using cgdisk to create GPT partitions
# cgdisk /dev/sda
Root:
- Choose New (or press
N) –Enterfor the first sector (2048) – type in "15360M" –Enterfor the default hex code (8300) –Enterfor a blank partition name.
Home:
- Press the down arrow a couple of times to move to the larger free space area.
- Choose New (or press
N) –Enterfor the first sector –Enterto use the rest of the drive (or you could type in the desired size; for example "30G") –Enterfor the default hex code (8300) –Enterfor a blank partition name.
完成之后,分区界面应该类似下面这样:
Part. # Size Partition Type Partition Name
----------------------------------------------------------------
1007.0 KiB free space
1 15.0 GiB Linux filesystem
2 123.45 GiB Linux filesystem
请再次仔细检查分区大小和布局是否正确。
确认无误后,选择Write (或者按 Shift+W) 完成分区,并输入yes将修改写入磁盘,然后退出。如果要重新开始,可以选择 Quit 退出分区程序。
Using fdisk to create MBR partitions
Launch fdisk with:
# fdisk /dev/sda
-
Command (m for help):typeoand pressEnter
Then create the first partition:
-
Command (m for help):typenand pressEnter - Partition type:
Select (default p):pressEnter -
Partition number (1-4, default 1):pressEnter -
First sector (2048-209715199, default 2048):pressEnter -
Last sector, +sectors or +size{K,M,G} (2048-209715199....., default 209715199):type+15Gand pressEnter
Then create a second partition:
-
Command (m for help):typenand pressEnter - Partition type:
Select (default p):pressEnter -
Partition number (1-4, default 2):pressEnter -
First sector (31459328-209715199, default 31459328):pressEnter -
Last sector, +sectors or +size{K,M,G} (31459328-209715199....., default 209715199):pressEnter
Now preview the new partition table:
-
Command (m for help):typepand pressEnter
Disk /dev/sda: 107.4 GB, 107374182400 bytes, 209715200 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x5698d902 Device Boot Start End Blocks Id System /dev/sda1 2048 31459327 15728640 83 Linux /dev/sda2 31459328 209715199 89127936 83 Linux
Then write the changes to disk:
-
Command (m for help):typewand pressEnter
If everything went well fdisk will now quit with the following message:
The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.
In case this doesn't work because fdisk encountered an error, you can use the q command to exit.
创建文件系统
分区之后,还需要用 mkfs 将分区格式化为选定的文件系统。本例中 root 和 home 分区都使用 ext4:
# mkfs.ext4 /dev/sda1 # mkfs.ext4 /dev/sda2
如果你分了一个swap区,不要忘了格式化和启用它:
# mkswap /dev/sdaX # swapon /dev/sdaX
UEFI 系统需要格式化 ESP 分区(通常是 sda1),命令是:
# mkfs.vfat -F32 /dev/sda1
挂载分区
要检查当前磁盘的标识符和布局:
# 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 # mount /dev/sdaX /mnt/boot
选择安装镜像
安装前需要编辑 /etc/pacman.d/mirrorlist,将最想使用的镜像放到前面。mirrorlist 文件也会被pacstrap复制到新系统,所以最好现在就设置好。
ArchLinux 镜像状态 报告了镜像的各种状态,包括网络问题,数据收集问题、上次同步时间等等。如果需要最新的软件包,最好手动检查一下 /etc/pacman.d/mirrorlist,确保文件包含了最新的镜像。
此外 镜像生成器 可以自动根据更新状况生成离你比较近的镜像列表。
用编辑器打开 /etc/pacman.d/mirrorlist 并取消离你近的镜像前的注释(删除前面的 '#' ),然后刷新软件包列表:
# pacman -Syy
传入两个 --refresh 或 -y 会强制 pacman 刷新所有软件包列表,即使刚刚更新过。一般情况下,只要源有了更改,就应该使用 pacman -Syy 命令。
详情请参阅 Mirrors.
安装基本系统
使用 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] 的附加工具例如
make和automake。大部分新手都应该安装它,后续扩展系统会用到它,安装AUR中软件包时,base-devel也是必须的。
如果不知道还需要什么软件,可以先跳过,后面可以用 pacman 安装。
生成 fstab
用下面命令生成 fstab。如果想使用 UUIDs,使用 -U 选项;如果想使用标签,用 -L 选项.
# genfstab -U -p /mnt >> /mnt/etc/fstab # nano /mnt/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" (参阅字段定义).
- 最后一列决定分区在启动时进行磁盘检查的顺序:只有非 Btrfs 格式的(
/)根分区需要将最后一列设为1,其它应该为2或0(参阅fstab#Field definitions). - btrfs和 swap 分区设置成
0,不必进行磁盘检查。
Chroot 到新系统
下面要 chroot 到新安装的系统:
# arch-chroot /mnt
到这一步之后,开始系统的主要配置,如果下面文件不存在,需要手动创建。
理解并完全安装步骤设置是保证系统配置成功的关键。
配置系统
Locale
glibc 和其他一些支持本地化的程序或者库使用 Locales 自动翻译输出各种语言的"独特" 文本, 并且合适的显示地域、货币、时区以及日期格式、字符排列方式和其他一些本地化的特定标准。
需要编辑两个文件:locale.gen 和 locale.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=
时区
将/etc/localtime 软链接到 /usr/share/zoneinfo/Zone/SubZone.其中 Zone 和 Subzone 替换为所在时区,例如
# ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
硬件时间
在 /etc/adjtime 中设置,默认、推荐的设置为UTC。详细信息请阅读Time (简体中文)。
请在同一个机器使用同一个硬件时钟模式,否则它们会覆盖时间导致时间错乱。
可以用下面命令自动生成 /etc/adjtime:
UTC(推荐使用):
-
# hwclock --systohc --utc
localtime,不推荐,但 Windows 默认使用此方式:
-
# 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.
内核模块
/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
配置网络
你需要再次配置网络,但此次是为你所安装的系统而配置。 该过程与前面的配置方法基本相同,不同之处在于我们此刻将使其在计算机启动时自动运行。
有线网络
动态 IP
- 使用 dhcpcd
如果你只使用一个单一的固定有线网络连接,你并不需要网络管理服务的话,你可以简单的使用 dhcpcd 服务. 在这里, interface_name 是你的网卡名称:
# systemctl enable dhcpcd.service
如果不行,试试:
# systemctl enable dhcpcd@interface_name.service
- 使用 netctl
复制一个简单的配置样本 /etc/netctl/examples 到 /etc/netctl/:
# cd /etc/netctl # cp examples/ethernet-dhcp my-network
根据你的需要修改配置文件 (修改 Interface):
# nano my-network
启用这个 my-network 配置:
# netctl enable my-network
- 使用 netctl-ifplugd
或者,你也可以使用 netctl 的 netctl-ifplugd 插件,方便的连接到网络:
安装 ifplugd, 这是被 netctl-ifplugd 所依赖的:
# pacman -S ifplugd
然后启用它.在这里, interface_name 是你的网卡名称:
# systemctl enable netctl-ifplugd@<interface>.service
静态 IP
- 使用 netctl
复制一个简单的配置样本 /etc/netctl/examples 到 /etc/netctl/:
# cd /etc/netctl # cp examples/ethernet-static my-network
根据你的需要修改配置文件 (修改 Interface, Address, Gateway 和 DNS):
# nano my-network
Address 中使用/24这样CIDR 标记方式设置掩码为255.255.255.0。
然后启用刚刚创建的配置文件:
# netctl enable my-network
无线网络
如果你的无线网卡需要固件 (如前所诉 #无线网络 和 这里), 安装包含你所需固件的软件包。大部分情况下 linux-firmware 会包括你需要的固件。对其他网卡来说,他们的固件可能在另外的软件包中。比如:
# pacman -S zd1211-firmware
查看 Wireless Setup 以获取更多信息。
安装 iw 和 wpa_supplicant ,你需要他们来连接网络:
# pacman -S iw wpa_supplicant
添加无线网络
- 使用 wifi-menu
安装 dialog, wifi-menu依赖于他:
# pacman -S dialog
在完成一下部分的安装并重新启动电脑后,你可以使用连接到无线网络 wifi-menu interface_name 连接到无线网络。(interface_name 是你的无线网卡名).
# wifi-menu interface_name
- 使用人工配置netctl配置文件
从 /etc/netctl/examples 复制一份模版到 /etc/netctl:
# cd /etc/netctl # cp examples/wireless-wpa my-network
按照需要修改模版 (modify Interface, ESSID and Key):
# nano my-network
启动时自动启用:
# netctl enable my-network
自动连接到已知网络
Install wpa_actiond, which is required for netctl-auto:
# pacman -S wpa_actiond
激活 netctl-auto 服务, 他会自动连接到已知的网络并且优雅的处理重新连接和漫游:
# systemctl enable netctl-auto@interface_name.service
模拟信号猫,ISDN 或 PPoE DSL
关于xDSL,拨号和 ISDN 连接,参见 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 等。
你需要正确的配置 hooks 如果你的根分区位于USB硬盘,RAID,LVM,或者/usr 是一个单独的分区。
编辑 /etc/mkinitcpio.conf 并使用如下命令重新产生 initramfs 文件:
# mkinitcpio -p linux
设置 Root 密码
用 passwd 设置一个root密码:
# passwd
安装配置启动加载器
For BIOS motherboards
BIOS 系统有三个供选择 - Syslinux 和 GRUB。按个人喜好选择一个启动加载器。
- Syslinux 目前只能加载他所安装的硬盘上的文件。他的配置文件相对来说容易理解。模版如下 这里。
- GRUB 功能丰富且支持更复杂的情况。他的配置文件更像是一种脚本语言,对新手来说可能写起来困难一些。我们推荐你使用自动产生的配置文件。
Syslinux
如果在之前选择使用 GUID 分区表,需要安装gptfdisk。
然后安装 syslinux,使用 syslinux-install_update 命令自动安装文件 (-i), 设置分区为活动分区 (-a), 安装MBR (-m):
# pacman -S syslinux # syslinux-install_update -iam ## 或者syslinux-install_update -iag
编辑 /boot/syslinux/syslinux.cfg,将 / 指向正确的根分区,这是必须的,否则 Arch 启动不起来。将"sda3"修改为实际的根分区。同样,修改LABEL archfallback.
# nano /boot/syslinux/syslinux.cfg
... LABEL arch ... APPEND root=/dev/sda3 rw
Syslinux 的详细使用和配置请阅读Syslinux。
Grub
BIOS 主板上的 GPT 分区需要 "BIOS Boot Partition"。参阅 GPT 指令 和 安装到 GPT BIOS 启动分区。
# pacman -S grub # grub-install --target=i386-pc --recheck --debug /dev/sda
虽然手动配置grub.cfg完全可以工作,建议用户自动生成这个文件。
要搜索硬盘上安装的其它操作系统,请先用 # pacman -S os-prober 安装 os-prober。
# grub-mkconfig -o /boot/grub/grub.cfg
详细配置信息请阅读GRUB。
对于 UEFI 主板
For UEFI systems, several options are available. A complete list of options is available at UEFI Bootloaders. You may find that some options work while others do not. Otherwise, choose one as per your convenience. Here, we give some of the possibilities as examples:
- gummiboot is a minimal UEFI Boot Manager which basically provides a menu for EFISTUB kernels and other UEFI applications. This is recommended UEFI boot method.
- GRUB is a more complete bootloader, useful if you run into problems with Gummiboot.
For both the bootloaders, you need to have the efivarfs mounted at /sys/firmware/efi/efivars so they can be accessed from inside the chroot:
# mount -t efivarfs efivarfs /sys/firmware/efi/efivars
Gummiboot
First install the gummiboot package and then run gummiboot install to install the bootloader to the EFI System Partition:
# pacman -S gummiboot # gummiboot install
You will need to manually create a configuration file to add an entry for Arch Linux to the gummiboot manager. Create /boot/loader/entries/arch.conf and add the following contents, replacing /dev/sdaX with your root partition, usually /dev/sda2:
# nano /boot/loader/entries/arch.conf
title Arch Linux linux /vmlinuz-linux initrd /initramfs-linux.img options root=/dev/sdaX rw
For more information on configuring and using gummiboot, see gummiboot.
GRUB
Install the grub and efibootmgr packages and then run grub-install to install the bootloader:
# pacman -S grub efibootmgr # grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=arch_grub --recheck
Next, while using a manually created grub.cfg is absolutely fine, it is recommended that beginners automatically generate one:
# grub-mkconfig -o /boot/grub/grub.cfg
For more information on configuring and using GRUB, see GRUB.
卸载分区并重启系统
如果还在 chroot 环境,先用 exit 命令退出系统:
# exit
卸载/mnt中挂载的系统:
# umount -R /mnt
重启:
# reboot