从零开始的 Arch 体验生活

2018-07-09 1680点热度 0人点赞 0条评论

仅以此文献祭给不会安装 Arch 的萌新们。


1 、下载 ArchLinux

先杀只程序员祭天


2 、安装 ArchLinux

官方 Wiki 参考 [链接]


2.1 、更新本地时间

[email protected] ~ # timedatectl set-ntp true
[email protected] ~ # ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime


2.2 、分配并格式化分区

[email protected] ~ # cfdisk /dev/sda
按首字母执行对应功能,保存请按 W,并输入 yes 。

[email protected] ~ # mkfs.fat -F32 /dev/sda1
mkfs.fat 4.1 (2017-01-24)

[email protected] ~ # mkfs.ext4 /dev/sda3
mke2fs 1.44.2 (14-May-2018)
/dev/sda3 contains a ext4 file system
last mounted on /mnt on Tue Jul 10 02:33:19 2018
Proceed anyway? (y,N) y
Creating filesystem with 4692731 4k blocks and 1175040 inodes
Filesystem UUID: c8241e99-8718-4bc3-9534-23ed66fd4b28
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000

Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

格式化 Swap 分区,并挂载
[email protected] ~ # mkswap /dev/sda2
[email protected] ~ # swapon /dev/sda2

查看 Swap 分区挂载是否成功
[email protected] ~ # free -h

将分区一对一挂载
[email protected] ~ # mount /dev/sda3 /mnt
[email protected] ~ # mkdir /mnt/boot
[email protected] ~ # mount /dev/sda1 /mnt/boot


2.3 、安装 Arch 基础系统

修改包管理器 Pacman 的源地址,改为仅国内源
[email protected] ~ # cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak
[email protected] ~ # cat /etc/pacman.d/mirrorlist.bak | grep -A 1 China | grep -v '\-\-' > /etc/pacman.d/mirrorlist

安装基本系统
[email protected] ~ # pacstrap /mnt base base-devel

导出新系统分区挂载情况
[email protected] ~ # genfstab -U /mnt >> /mnt/etc/fstab


2.4 、配置 Arch 新系统

切换根
[email protected] ~ # arch-chroot /mnt

2.4.1 、安装所需要的包
[[email protected] /]# pacman -Syy
[[email protected] /]# pacman -S vim
[[email protected] /]# pacman -S openssh
[[email protected] /]# pacman -S net-tools
[[email protected] /]# pacman -S linux-headers

(可选操作)
[[email protected] /]# pacman -S base base-devel
[[email protected] /]# pacman -Syu

2.4.2 、修改时区并写入
[[email protected] /]# ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
[[email protected] /]# hwclock --systohc

2.4.3 、修改 hostname
[roo[email protected] /]# echo archlinux.starryvoid.com > /etc/hostname

2.4.4 、修改密码
[[email protected] /]# passwd

2.4.5 、修改 hosts 与 resolv
[[email protected] /]# vim /etc/hosts

127.0.0.1 localhost
::1 localhost
127.0.1.1 localhost.localdomain

[[email protected] /]# vim /etc/resolv.conf

nameserver 8.8.8.8

2.4.6 、修改系统语言格式
[[email protected] /]# vim /etc/locale.gen

en.US.UTF-8
zh_CN.UTF-8
zh_TW.UTF-8

[[email protected] /]# locale-gen
en.US.UTF-8... done
zh_CN.UTF-8...done
zh_TW.UTF-8...done
[[email protected] /]# echo LANG=en_US.UTF-8 > /etc/locale.conf

2.4.7 、配置 systemd-boot 引导 [链接]
[[email protected] /]# bootctl install

2.4.8 、修改引导界面选项
[[email protected] /]# vim /boot/efi/loader/entries/arch.conf

default arch
timeout 0
editor 0

2.4.9 、修改启动项
[[email protected] /]# vim /boot/efi/loader/loader.conf

title Arch Linux
linux /vmlinuz-linux
initrd /initramfs-linux.img
options root=PARTUUID=c8241e99-8718-4bc3-9534-23ed66fd4b28 rw

所需的 PartUUID 在这里查看
[[email protected] /]# blkid

最后退出,保存。
[[email protected] /]# exit
[email protected] ~ # reboot


3 、进入 ArchLinux

3.1 、配置静态网卡地址

cp /etc/netctl/examples/ethernet-static /etc/netctl/ens32.cfg

vim /etc/netctl/ens32.cfg

Interface=ens32
Connection=ethernet
IP=static
Address=('10.1.10.2/24')
Gateway=('10.1.10.1')
DNS=('10.1.10.1')

systemctl start netctl
netctl enable ens32.cfg
netctl reenable ens32.cfg

3.2 、配置动态获取地址

systemctl start dhcpcd

StarryVoid

Have a good time