前期准备
开始安装
启动
从 CD 启动,选择第一项 Boot Arch Linux (x86_64)
检查网络
[email protected] ~ $ ping -c 4 1.2.4.8
# 如果网络不通,可以启用 DHCP 功能(一般默认开启)
[email protected] ~ $ systemctl start dhcpcd
系统分区
分区规划
分区 | 大小 | 挂载点 |
---|---|---|
/dev/sda1 | 1G | /boot |
/dev/sda2 | 10G | / |
/dev/sda4 | 2G | swap |
/dev/sda3 | 7G | /home |
创建分区
[email protected] ~ $ lsblk # 查看磁盘信息
[email protected] ~ $ parted /dev/sda # 使用 parted 分区
# parted 命令 1000MB=1GB
(parted) mklabel msdos # 创建 MBR/msdos 分区表
(parted) mkpart primary ext4 1m 1g # 大小为 1G
(parted) set 1 boot on # 设置 boot 为启动目录
(parted) mkpart primary ext4 1g 11g
(parted) mkpart primary linux-swap 11g 13g
(parted) mkpart primary ext4 13g 100%
(parted) print # 查看分区是否正确
(parted) quit # 退出 parted 交互界面
格式化分区
# 格式化分区为 ext4 格式
[email protected] ~ $ mkfs.ext4 /dev/sda1
[email protected] ~ $ mkfs.ext4 /dev/sda2
[email protected] ~ $ mkfs.ext4 /dev/sda4
[email protected] ~ $ mkswap /dev/sda3 # 格式化为 swap
[email protected] ~ $ swapon /dev/sda3 # 启用 swap
挂载分区
[email protected] ~ $ mount /dev/sda2 /mnt
[email protected] ~ $ mkdir /mnt/{boot,home}
[email protected] ~ $ mount /dev/sda1 /mnt/boot
[email protected] ~ $ mount /dev/sda4 /mnt/home
安装系统
[email protected] ~ $ sed -i '/Score/{/China/!{n;s/^/#/}}' /etc/pacman.d/mirrorlist # 注释所有非中国的软件源
[email protected] ~ $ pacman -Syy # 更新本地数据库
[email protected] ~ $ pacstrap /mnt base base-devel # 安装基本系统
系统配置
生成 fstab
[email protected] ~ $ genfstab -U -p /mnt >> /mnt/etc/fstab # 自动生成 fstab
进入新系统
# 将配置文件复制到 /mnt,chroot 进入
[email protected] ~ $ arch-chroot /mnt /bin/bash
语言设置
[[email protected] /]$ vi /etc/locale.gen # 反注释 en_US.UTF-8 和 zh_CN.UTF-8
[[email protected] /]$ locale-gen # 生成 locale
[[email protected] /]$ echo LANG=en_US.UTF-8 > /etc/locale.conf # 设置默认 locale
时区设置
[[email protected] /]$ ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
时间设置
[[email protected] /]$ hwclock --systohc --utc # 使用 UTC 时间
设置主机名
[[email protected] /]$ echo HostName > /etc/hostname # 将主机名写入到 hostname
[[email protected] /]$ sed -i '/localhost/s/$/\t'"HostName"'/g' /etc/hosts # 将主机名添加到 hosts 中
网络
[[email protected] /]$ systemctl enable dhcpcd.service # 设置为自动启动
创建 ramdisk
默认创建
root 密码
[[email protected] /]$ passwd # 设置密码
安装引导
[[email protected] /]$ pacman -S grub os-prober # 安装 GRUB
[[email protected] /]$ grub-install --recheck /dev/sda # 将引导信息写到 sda
[[email protected] /]$ grub-mkconfig -o /boot/grub/grub.cfg # 生成配置文件 grub.cfg
重启
[[email protected] /]$ exit # 退出安装环境
[email protected] ~ $ umount /mnt/{boot,home} # 卸载挂载点
[email protected] ~ $ umount /mnt
[email protected] ~ $ reboot
参考:
- Arch Linux 中文论坛 Arch Linux 安装指南
- 雾里看花 Linux 安装笔记
- 写于: 2016.01
- 修改于: 2016.02.27
- 重新排列步骤
- 增加
sed
命令使用
- 第三次修改: 2016.03.13
- 简化
主机名设置
- 删除
创建 ramdisk
- 简化